[R] Removing directory?
Henrik Bengtsson
hb at stat.berkeley.edu
Thu Mar 1 00:01:08 CET 2007
Hi,
I'm trying to remove/delete a directory usingR. I've tried the
following with no success:
% Rterm --vanilla
> getwd()
[1] "C:/Documents and Settings/hb/braju.com.R/aroma.affymetrix/test"
> dir.create("foo")
> file.info("foo")
size isdir mode mtime ctime atime
foo 0 TRUE 777 2007-02-28 14:52:10 2007-02-28 14:52:10 2007-02-28 14:52:10
# Using file.remove()
> res <- sapply(c("foo", "foo/", "foo\\", "./foo", "./foo/"), file.remove)
> res
foo foo/ foo\\ ./foo ./foo/
FALSE FALSE FALSE FALSE FALSE
# Using unlink()
> res <- sapply(c("foo", "foo/", "foo\\", "./foo", "./foo/"), unlink)
> res
foo foo/ foo\\ ./foo ./foo/
1 0 0 1 0
# Directory is still there
> file.info("foo")
size isdir mode mtime ctime atime
foo 0 TRUE 777 2007-02-28 14:52:10 2007-02-28 14:52:10 2007-02-28 14:52:10
I've tried the above from a different directory too, i.e.
setwd("C:/"), with no success. Using absolute pathnames the same.
This is on WinXP R v2.4.1:
> sessionInfo()
R version 2.4.1 Patched (2007-01-13 r40470)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON
ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
Thanks
Henrik
More information about the R-help
mailing list