unlink(x, recursive = FALSE, force = FALSE)
x | a character string that specifies a file or directory name, or a vector that specifies a set of files or directories. The names are interpreted literally; that is, you cannot use UNIX regular expression expansions to specify file or directory names. |
recursive | a logical value. If TRUE, the directories are deleted recursively. If FALSE (the default), directories are never deleted. |
force | This argument is not yet implemented. a logical value. If TRUE, the restrictive permissions of the file or directory is changed as possible to allow it to be removed like rm -f command. The default is FALSE. |
# set up temp file and remove on exit foo <- function() { file <- tempfile("junk") on.exit(unlink(file)) # do something with file TRUE }file1 <- tempfile("test") res <- unlink("test") res res <- unlink("test1") res
unlink("res_test", force = TRUE) # "res_test" is a file with restrictive permissions.