[R] loop through files and create object

Daniel Caro dcarov at googlemail.com
Tue Jul 20 13:52:07 CEST 2010


Hi R users,

I am a newbie and therefore the naive question. Sorry but I was unable
to find an answer online. I would like to read 47 data sets
(country1.raw, country2.raw, ... country47.raw) and save into a matrix
each time (data1, data2, ....data47).

for (i in 1:47){
data(?) <- read.csv(file.path("country", i, ".raw", fsep = ""), header = TRUE)
}

The read.cvs statement seems to be right, but how to include "i" in
"data" for it to create 47 matrices and not 1 (the last one).

Thank you,
Daniel



More information about the R-help mailing list