0

I am importing a list of csv files from a directory, and I have to map these csv files to some excel file that has the annotations (ie which columns should be included, what genotype was used for each column)

currently I have a loop which generates a bunch of variables for the csv files using

assign(paste0(dirname,'-',csvname[i]), read.csv(paste0(datedir,'/',csvname[i])))

and a loop for a bunch of excel files usigng

 assign(paste0(dirname,'_', timefolder), read.xlsx(paste0(timedir,'/',excelname[i]), sheet = 2))

Now I would like to create another loop where I iterate through the excel files, read the description and annotate the csv files based on those descriptions (ie, change the column name to the genotype listed in one of the excel files)

I don't know how to read through all the variables generated iteratively. I've tried to store the variable names as string list, but I can't use or evaluate it.

Any suggestions?

lmo
  • 35,764
  • 9
  • 49
  • 57
bli
  • 1
  • 1
    Read [this post](http://stackoverflow.com/questions/17499013/how-do-i-make-a-list-of-data-frames). In particular, gregor's answer. – lmo Mar 01 '17 at 21:08
  • 1
    We really need a canonical question/answer to refer to when people try to manipulate dynamic variable names instead of using lists. – Konrad Rudolph Mar 01 '17 at 21:13
  • 1
    One of the most common R questions on SO is importing data from multiple files in a directory into dataframes and most answers do not use `assign`. We advise you to take a look at the hundreds of examples. – Parfait Mar 01 '17 at 21:13

0 Answers0