[R] Automatic File Reading

Richard M. Heiberger rmh at temple.edu
Wed Oct 18 21:17:19 CEST 2006


Wensui Lui asks:
> is there a similar way to read all txt or csv files with same
> structure from a folder?



On Windows I use this construct to find all files with the specified wild card name.
I used the "\\" in the file paths with the translate=FALSE, because the "/" in
the DOS switches "/w/B" must not be translated.  On Windows this picks up
both lower and upper case filenames

A similar construct can be written for Unix.  

tmp <- shell('dir c:\\HOME\\rmh\\tmp\\*.R /w/B', intern=TRUE, translate=FALSE)  ##msdos
for (i in tmp) source(paste("c:\\HOME\\rmh\\tmp\\", i, sep=""))



More information about the R-help mailing list