Re: [R] deleting a directory

2006-08-01 Thread Tony Plate
?unlink says that unlink() can remove directories (and has a 'recursive' 
argument).  'unlink' is in the "SEE ALSO" section in ?file.remove.

-- Tony Plate

Sundar Dorai-Raj wrote:
> Hi, all,
> 
> I'm looking a utility for removing a directory from within R. Currently, 
> I'm using:
> 
> foo <- function(...) {
>mydir <- tempdir()
>dir.create(mydir, showWarnings = FALSE, recursive = TRUE)
>on.exit(system(sprintf("rm -rf %s", mydir)))
>## do some stuff in "mydir"
>invisible()
> }
> 
> However, this is assumes "rm" is available. I know of ?dir.create, but 
> there is no opposite. And ?file.remove appears to work only on files and 
> not directories.
> 
> Any advice? Or is my current approach the only solution?
> 
>  > R.version
> _
> platform   i386-pc-mingw32
> arch   i386
> os mingw32
> system i386, mingw32
> status
> major  2
> minor  3.1
> year   2006
> month  06
> day01
> svn rev38247
> language   R
> version.string Version 2.3.1 (2006-06-01)
> 
> 
> Thanks,
> 
> --sundar
> 
> __
> R-help@stat.math.ethz.ch 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.
>

__
R-help@stat.math.ethz.ch 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.


Re: [R] deleting a directory

2006-08-01 Thread Sundar Dorai-Raj
Please ignore. I forgot ?unlink had a recursive argument.

Thanks.

--sundar

Sundar Dorai-Raj wrote:
> Hi, all,
> 
> I'm looking a utility for removing a directory from within R. Currently, 
> I'm using:
> 
> foo <- function(...) {
>   mydir <- tempdir()
>   dir.create(mydir, showWarnings = FALSE, recursive = TRUE)
>   on.exit(system(sprintf("rm -rf %s", mydir)))
>   ## do some stuff in "mydir"
>   invisible()
> }
> 
> However, this is assumes "rm" is available. I know of ?dir.create, but 
> there is no opposite. And ?file.remove appears to work only on files and 
> not directories.
> 
> Any advice? Or is my current approach the only solution?
> 
>  > R.version
>_
> platform   i386-pc-mingw32
> arch   i386
> os mingw32
> system i386, mingw32
> status
> major  2
> minor  3.1
> year   2006
> month  06
> day01
> svn rev38247
> language   R
> version.string Version 2.3.1 (2006-06-01)
> 
> 
> Thanks,
> 
> --sundar
> 
>

__
R-help@stat.math.ethz.ch 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.


[R] deleting a directory

2006-08-01 Thread Sundar Dorai-Raj
Hi, all,

I'm looking a utility for removing a directory from within R. Currently, 
I'm using:

foo <- function(...) {
   mydir <- tempdir()
   dir.create(mydir, showWarnings = FALSE, recursive = TRUE)
   on.exit(system(sprintf("rm -rf %s", mydir)))
   ## do some stuff in "mydir"
   invisible()
}

However, this is assumes "rm" is available. I know of ?dir.create, but 
there is no opposite. And ?file.remove appears to work only on files and 
not directories.

Any advice? Or is my current approach the only solution?

 > R.version
_
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)


Thanks,

--sundar

__
R-help@stat.math.ethz.ch 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.