Taka Matzmoto
2007-Jun-01 02:18 UTC
[R] scan a directory and then make a string vector consisting of file names
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, _________________________________________________________________ Make every IM count. Download Messenger and join the i?m Initiative now. It?s free. http://im.live.com/messenger/im/home/?source=TAGHM_June07
Marc Schwartz
2007-Jun-01 02:39 UTC
[R] 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
Bill.Venables at csiro.au
2007-Jun-01 04:31 UTC
[R] scan a directory and then make a string vector consisting offile names
Would you believe it's> list.files()See ?list.files for variants. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: (I don't have one!) Home Phone: +61 7 3286 7700 mailto:Bill.Venables at csiro.au http://www.cmis.csiro.au/bill.venables/ -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Taka Matzmoto Sent: Friday, 1 June 2007 12:19 PM To: r-help at stat.math.ethz.ch Subject: [R] scan a directory and then make a string vector consisting offile names 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, _________________________________________________________________ Make every IM count. Download Messenger and join the i'm Initiative now. It's free. http://im.live.com/messenger/im/home/?source=TAGHM_June07