[R] deleting a directory

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Tue Aug 1 17:59:38 CEST 2006


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
> day            01
> svn rev        38247
> language       R
> version.string Version 2.3.1 (2006-06-01)
> 
> 
> Thanks,
> 
> --sundar
> 
>



More information about the R-help mailing list