[R] loading data from a specified directory

Thomas Lumley tlumley at u.washington.edu
Mon Sep 9 16:23:57 CEST 2002


On Mon, 9 Sep 2002, Sam McClatchie wrote:
>    for (i in 1:length(f))
>        paste("t.",f[1], sep="")
> <-read.table(paste("/home/smc/manuscripts/mesopelagic_fish/biomass_spectrum/we0000",f[1],sep=""),
> header=F)

As has been pointed out, this isn't a problem with loading data from a
specified directory.  If you want to assign to a constructed variable name
you can do it with either assign() or by constructing an expression with
substitute() and evaluating it.

However, you typically don't want to do that -- it's usually easier to
stick all the things in a list.

datasets<-vector("list",length(f))
for (fi in f){
   datasets[[fi]]<-read.table(paste("/long/directory/name/",fi,sep=""))
}


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list