How to remove a directory in R?
In this article, we will discuss how to remove a directory using R programming language.
To remove a directory in R we use unlink(). This function deletes the named directory.
Syntax: unlink(directory-name, recursive = BOOLEAN)
- directory-name: a character vector with the names of the directories to be deleted.
- recursive: BOOLEAN TRUE/FALSE, if true directory is deleted recursively otherwise only empty directories are deleted.
Return: It returns normally 0 for success, 1 for failure. Not deleting a non-existent file is not a failure so in that case return 0.
Note: File naming conventions depend on the platform.
Directory in use:
Example: Removing directory using R programming language
Final Directory after running the above code: