Re: [R] deleting a file
Achim Zeileis wrote: On Tue, 16 Nov 2004 15:43:12 - Roger Gill wrote: Dear all, I have a very simple question. Simple, that is, if you know the answer. Yes, look at ?file.remove Z ... and file.path() in order to specify the location in an OS independent way. Uwe Ligges I wish to delete a file in a given directory after having first checked its existence. I issue the following commands path<-'c:example/R/' Thus creating the directory. indicator<-length(grep(filename,path)) If indicator is greater than zero then the file exists. Now I wish to remove this file. However, I would like to make the code compatible for Linux/Windows and Macs. In Linux I would issue the command system('rm paste(path,'filename',sep='')') and this works just fine. It does not however work for windows, and I have no idea whether it would work on a mac. Is there a single command thay escapes me? Best Wishes Roger Gill __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] deleting a file
On Tue, 16 Nov 2004 15:43:12 - Roger Gill wrote: > Dear all, > > I have a very simple question. Simple, that is, if you know the > answer. Yes, look at ?file.remove Z > I wish to delete a file in a given directory after having first > checked its existence. I issue the following commands > > path<-'c:example/R/' > > Thus creating the directory. > > indicator<-length(grep(filename,path)) > > If indicator is greater than zero then the file exists. Now I wish to > remove this file. However, I would like to make the code compatible > for Linux/Windows and Macs. > > In Linux I would issue the command > > system('rm paste(path,'filename',sep='')') > > and this works just fine. It does not however work for windows, and I > have no idea whether it would work on a mac. > > Is there a single command thay escapes me? > > Best Wishes > > Roger Gill > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] deleting a file
You may be interested in one of dir.create(), file.exists(), or unlink(). -roger Roger Gill wrote: Dear all, I have a very simple question. Simple, that is, if you know the answer. I wish to delete a file in a given directory after having first checked its existence. I issue the following commands path<-'c:example/R/' Thus creating the directory. indicator<-length(grep(filename,path)) If indicator is greater than zero then the file exists. Now I wish to remove this file. However, I would like to make the code compatible for Linux/Windows and Macs. In Linux I would issue the command system('rm paste(path,'filename',sep='')') and this works just fine. It does not however work for windows, and I have no idea whether it would work on a mac. Is there a single command thay escapes me? Best Wishes Roger Gill __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] deleting a file
> In Linux I would issue the command > system('rm paste(path,'filename',sep='')') > and this works just fine. It does not however work for windows, and I have > no idea whether it would work on a mac. > Is there a single command thay escapes me? Yes. help("file.remove") __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] deleting a file
Dear all, I have a very simple question. Simple, that is, if you know the answer. I wish to delete a file in a given directory after having first checked its existence. I issue the following commands path<-'c:example/R/' Thus creating the directory. indicator<-length(grep(filename,path)) If indicator is greater than zero then the file exists. Now I wish to remove this file. However, I would like to make the code compatible for Linux/Windows and Macs. In Linux I would issue the command system('rm paste(path,'filename',sep='')') and this works just fine. It does not however work for windows, and I have no idea whether it would work on a mac. Is there a single command thay escapes me? Best Wishes Roger Gill __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html