Skip to content
Back to formatted view

Raw Message

Message-ID: <41A5EBF2.3030600@stat.wisc.edu>
Date: 2004-11-25T14:28:02Z
From: Douglas Bates
Subject: Automatic file reading
In-Reply-To: <3E838AED-3E16-11D9-9A35-000D933565E8@mail.nih.gov>

Sean Davis wrote:
> If you simply want read all files in a given directory, you can do 
> something like:
> 
> fullpath = "/home/andersm/tmp"
> filenames <- dir(fullpath,pattern="*")
> pair <- sapply(filenames,function(x) 
> {read.table(paste(fullpath,'/',x,sep=""))})

Slightly off-topic but it is more portable to use the file.path function 
instead of paste when creating a file name.