[R] Automatic file reading

Douglas Bates bates at stat.wisc.edu
Thu Nov 25 15:28:02 CET 2004


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.




More information about the R-help mailing list