[R] Reading in a series of files using a for loop

Thomas Jackson tom_j87 at hotmail.com
Thu Nov 19 18:29:10 CET 2009


Dear R Users,

I am trying to read in a series of csv files which vary by the letter on the end of he file name.  When I input what seems to be a logical for loop I get an error message that doesn't make sense to me.  

> for(i in 1:12){ paste("G&P", LETTERS[i],sep='') <-read.csv(paste("/Users/thomasjackson/Data/GEP&CO/GEP&CO",LETTERS[i],"/HPLC_",LETTERS[i],"12.csv",sep=''), header=T, sep=',')}


Error in paste("G&P", LETTERS[i], sep = "") <- read.csv(paste("/Users/thomasjackson/Data/GEP&CO/GEP&CO",  : 
  target of assignment expands to non-language object


For example the first file name is HPLC_A12.csv in the folder GEP&COA

Thanks for any help,
Thomas Jackson



More information about the R-help mailing list