R: Delete Files and Directories

unlink {base} | R Documentation

## Delete Files and Directories

### Description

`unlink` deletes the file(s) or directories specified by `x`.

### Usage

    unlink(x, recursive = FALSE)

### Arguments

`x` | a character vector with the names of the file(s) or directories to be deleted. Wildcards (normally ``*`' and ``?`') are allowed.
`recursive` | logical. Should directories be deleted recusively?

### Details

If `recusive = FALSE` directories are not deleted, not even empty ones.

`file.remove` can only remove files, but gives more detailed error information.

### Value

The return value of the corresponding system command, `rm -f`, normally `0` for success, `1` for failure. Not deleting a non-existent file is not a failure.

### Note

Prior to R version 1.2.0 the default on Unix was `recursive = TRUE`, and on Windows empty directories could be deleted.

### See Also

`file.remove`.

[Package Contents]