Hello, I am trying to create directories with R. I would like R to create directories because it is platform independent. I tried using file() and searching in "R Data Import/Export" but I did not succeed. I think it must be some function since exists the unlink to remove directories (and files). Pau
?dir.create On Mon, 2006-03-27 at 13:07 +0200, pau carre wrote:> Hello, I am trying to create directories with R. I would like R to > create directories because it is platform independent. I tried using > file() and searching in "R Data Import/Export" but I did not succeed. > I think it must be some function since exists the unlink to remove > directories (and files). > > Pau > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! R-project.org/posting-guide.html
I think you need to use system("mkdir") or whatever is appropriate for your OS. Making directories is a function of the OS, not of R. If you need to make a truly cross-platform solution, you might need to check within your code what OS is being used, and call the appropriate system statement. (I think you can do this, but have never needed to.) That would be particularly important if you need to specify paths. Sarah On 3/27/06, pau carre <pau.carre@gmail.com> wrote:> > Hello, I am trying to create directories with R. I would like R to > create directories because it is platform independent. I tried using > file() and searching in "R Data Import/Export" but I did not succeed. > I think it must be some function since exists the unlink to remove > directories (and files). > > Pau > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html >-- Sarah Goslee stringpage.com [[alternative HTML version deleted]]
On Mon, 27 Mar 2006, pau carre wrote:> Hello, I am trying to create directories with R. I would like R to > create directories because it is platform independent. I tried using > file() and searching in "R Data Import/Export" but I did not succeed. > I think it must be some function since exists the unlink to remove > directories (and files).?dir.create [help.search("directory") leads to files(base) File and Directory Manipulation on which page it is documented.] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, stats.ox.ac.uk/~ripley University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
help.search("directory") would have given you: R.home(base) Return the R Home Directory files(base) File and Directory Manipulation getwd(base) Get or Set Working Directory list.files(base) List the Files in a Directory/Folder unlink(base) Delete Files and Directories and then ?files would have told you there's dir.create() and how to use it. Andy From: pau carre> > Hello, I am trying to create directories with R. I would like > R to create directories because it is platform independent. I > tried using > file() and searching in "R Data Import/Export" but I did not > succeed. I think it must be some function since exists the > unlink to remove directories (and files). > > Pau > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html > >
See ?dir.create, and take care at the 'recursive' argument in case you have to create several subdir levels at once. Best, Philippe Grosjean Sarah Goslee wrote:> I think you need to use system("mkdir") or whatever is appropriate > for your OS. Making directories is a function of the OS, not of R. If > you need to make a truly cross-platform solution, you might need > to check within your code what OS is being used, and call the > appropriate system statement. (I think you can do this, but have > never needed to.) That would be particularly important if you need to > specify paths. > > Sarah > > On 3/27/06, pau carre <pau.carre at gmail.com> wrote: > >>Hello, I am trying to create directories with R. I would like R to >>create directories because it is platform independent. I tried using >>file() and searching in "R Data Import/Export" but I did not succeed. >>I think it must be some function since exists the unlink to remove >>directories (and files). >> >>Pau >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide! >>R-project.org/posting-guide.html >> > > > > > -- > Sarah Goslee > stringpage.com > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! R-project.org/posting-guide.html > >