Read them into a list; much easier to handle: myList <- lapply(filenames, read.csv)
On Fri, Oct 29, 2010 at 5:16 AM, Sarah Moens <sara...@telenet.be> wrote: > Hi all, > > I've been trying to find a solution for the problem of reading > multiple files and storing them in a variable that contains the names > by which I want to call the datasets later on. > > For example (5 filenames): > > - The filenames are stored in one variable: > filenames = paste(paste('name', '_', 1:5, sep = ''), '.csv', sep = '') > > - Subsequently I have a variable just containing the meaningful names > for the dataset > meaningfulnames = c('name1','name2'...,'name5') > > - I want to link each of these names to the data that is read > > for (i in 1:5) > { > meaningfulnames[i] = read.csv(filenames[i], header = TRUE, sep = ',') > } > > > I need to read in quite a lot of datafiles. I have a code doing this > one at a time, but since the number of datafiles I need to read will > increase in the future, I want to make sure I have a more flexible > solution for this. > > Thanks a lot for your help. I have tried to look in the help pages and > also came across dbfread, but I can't seem to find something I can use > or understand at this point. > > > Sarah > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.