dirname <- "c:/work/raw_data_files" dirlist <- dir(dirname, pattern="\\.txt$", full.names=TRUE)
The pattern matches all file names ending with ".txt", full.names=TRUE means to include the directory name at the front of each file name. Look at help("dir") for details. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of nalluri pratap > Sent: Thursday, April 04, 2013 7:57 AM > To: r-help@r-project.org > Subject: [R] pipe or system command > > Hi, > > In SAS I have something like > > %let dirname = c:\work\raw_data_files; > filename DIRLIST pipe "dir /B &dirname\*.txt"; > > Can someone help me to convert this to R. I tried with system and pipe, but > It actually > creates a file on the disk which I don't like. I just need to have a > reference to the file and > use it in the analysis. > > Thanks, > Pratap > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.