[R] assigning NA's

Patrick Buetzberger patrick at giub.unibe.ch
Tue Jan 22 18:36:19 CET 2002


I've had a question a few moments ago about how to create multiple
objects from multiple files within a loop. Thanks for the quick answers,

it worked with "assign", like this:

for(i in seq(1,nfn,1)){
 fin<-paste("/home/klimet/patrick/LAEGEREN/NEBEL/FOGEVENT2000/",fn[i],sep="")

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

I've tried to use the same command for assigning NA's to missing values
(=-999)  in each object created with above loop, like this:
for(i in seq(1,nfn,1)){
 assign(paste("f", i, sep = "")[paste("f", i, sep = "") < -500.], NA)
}

This did not work, it created an error "invalid first argument"
I've also tried:
for(i in seq(1,nfn,1)){
 paste("f", i, sep = "")[paste("f", i, sep = "") < -500.] <- NA
}


This also created an error. Any clues about how to handle this problem?
Thanks again,

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/4e7d77e2/patrick.vcf


More information about the R-help mailing list