Skip to content
Back to formatted view

Raw Message

Message-ID: <403B5BAB.1030704@hhbio.wasser.tu-dresden.de>
Date: 2004-02-24T14:11:55Z
From: Thomas Petzoldt
Subject: (read many files)
In-Reply-To: <200402241334.i1ODYZQ25352@mailgate5.cinetic.de>

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.