[R] deleting a directory
Tony Plate
tplate at acm.org
Tue Aug 1 18:23:38 CEST 2006
?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
> day 01
> svn rev 38247
> language R
> version.string Version 2.3.1 (2006-06-01)
>
>
> Thanks,
>
> --sundar
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list