x.
unlink(x, recursive=F)
TRUE directories are deleted recursively.
TRUE
means that the file was removed.
The
error attribute gives a short
description of why the C unlink or rmdir functions failed.
When using
unlink to remove a file
created within a function,
it is good programming style to use
on.exit(unlink(file))
so that the
file will be removed even if the function is exited abnormally.
unlink will remove files and directories,
but only empty directories unless
recursive=TRUE.
You can also use
rmdir to remove a directory
and everything in it.
# set up temp file and remove on exit
foo <- function() {
file <- tempfile("junk")
on.exit(unlink(file))
...
}