[R] Re: (read many files)
Thomas Petzoldt
thpe at hhbio.wasser.tu-dresden.de
Tue Feb 24 15:11:55 CET 2004
Claudia Paladini wrote:
>
> Dear ladies and gentlmen, I want to import a directory with about 400
> files (.dat) in R. I know how to import a single file (with scan...)
> but I've good no idea how to import 400 at once. Can you help me ?
> Thanks a lot! Claudia
setwd("c:/myfiles/")
## list.files uses regular expressions.
## For reading all files which start with "S" use for example:
files <- list.files(pattern="^S.*")
## then read the data within a loop, e.g.:
dat2 <- NULL
for (f in files) {
dat <- read.table(f)
dat2 <- rbind(dat2, dat)
}
Thomas P.
More information about the R-help
mailing list