On Linux (RH7.1) with R installed from CRAN rpms: I have many files with miscellaneous names *.dat. I would like to successively open each one, run some functions on them, and then write some output numbers to *.summary. I have succeeded in doing this when I type in each file name individually for the data input, but have not found a way to search files in a directory and grab the *.dat. If somebody could tell me syntax or example of how to find the files, and get the basename in order to create the new file name, I would be grateful. I tried mydat<-system("ls *.dat") but mydat does not catch the return. Thanks for your many helps in the past... -- Paul E. Johnson email: pauljohn at ukans.edu Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66045 FAX: (785) 864-5700 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Paul E Johnson <pauljohn at ukans.edu> writes:> I tried > mydat<-system("ls *.dat") > but mydat does not catch the return. > Thanks for your many helps in the past...You might want to read the help page for system() with some attention to the "intern" argument... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 13 Aug 2001, Peter Dalgaard BSA wrote:> Paul E Johnson <pauljohn at ukans.edu> writes: > > > I tried > > mydat<-system("ls *.dat") > > but mydat does not catch the return. > > Thanks for your many helps in the past... > > You might want to read the help page for system() with some attention > to the "intern" argument...Or just use the list.files() function, which is portable across operating systems. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 13 Aug 2001, Paul E Johnson wrote:> On Linux (RH7.1) with R installed from CRAN rpms: > > I have many files with miscellaneous names *.dat. I would like to > successively open each one, run some functions on them, and then write > some output numbers to *.summary. I have succeeded in doing this when I > type in each file name individually for the data input, but have not > found a way to search files in a directory and grab the *.dat. If > somebody could tell me syntax or example of how to find the files, and > get the basename in order to create the new file name, I would be > grateful. > > I tried > mydat<-system("ls *.dat") > but mydat does not catch the return. > Thanks for your many helps in the past... >list.files(pattern="*.dat") may help? Roger -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no and: Department of Geography and Regional Development, University of Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._