Skip to content
Prev 30387 / 398513 Next

Reading in multiple files

Try:

tmpf <- list.files("c:/temp")
dat <- read.csv(tmpf[1])
for (f in tmpf[-1]) {
    dat <- rbind(dat, read.csv(f)
}

If the data are all numeric, reading them as matrices could be a lot more
efficient.  Or you can specify the colclass argument to speed up read.csv().

Another way is to concatenate all the files into one (using things like
`cat') outside of R, and read it in at once.

HTH,
Andy
------------------------------------------------------------------------------