how to delete a directory in r code example Example: R remove directory unlink("mydir", recursive=TRUE)