scan a directory and then make a string vector consisting of file names
On Thu, 2007-05-31 at 21:18 -0500, Taka Matzmoto wrote:
Dear R-users,
I am looking for a way to scan a directory and then make a string vector
consisting of the file names in the directory.
For example, under c:\temp\
there are 4 files
a.txt, b.txt, c.txt, and d.txt
I would like to have a string vector
c("a.txt","b.txt","c.txt","d.txt")
How do I do that?
Thanks
Taka,
See ?list.files
For example:
list.files("c:/temp", pattern = "\\.txt")
Note the use of the forward slash in the 'path' argument. See R Windows
FAQ:
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file
HTH,
Marc Schwartz