Skip to content

creation of objects

2 messages · Patrick Buetzberger, Brian Ripley

#
Hi there,

I'm a new R user and I've got a little problem:
I would like to read several files at once (which works) and create R
objects for each individual file (which doesen't work) within a loop:
this is the way I've tried to program this:

fn<-list.files(path =
"/home/klimet/patrick/LAEGEREN/NEBEL/FOGEVENT2000/", pattern=NULL,
all.files=FALSE, full.names=FALSE)
for(i in seq(1,nfn,1)){

fin<-paste("/home/klimet/patrick/LAEGEREN/NEBEL/FOGEVENT2000/",fn[i],sep="")

    fi <- as.matrix(read.table(fin,skip=1))
}

The i in fin and fi should create new objects for every loop with i
being the number, like f1, f2,f3 and so  on. The way I did it, it reads
i as a character and overwrites the object in every loop.

Thanks for any hints....

Patrick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patrick.vcf
Type: text/x-vcard
Size: 339 bytes
Desc: Card for Patrick Buetzberger
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020122/a47b51b7/patrick.vcf
#
On Tue, 22 Jan 2002, Patrick Buetzberger wrote:

            
?assign, something like

assign(paste("f", i, sep = ""), as.matrix(read.table(fin,skip=1)))

Overwriting fn seems fine to me.