How to remove a directory in R?

前端 未结 4 1902
有刺的猬
有刺的猬 2021-02-06 20:15

After some research I found out that the following works:

unlink(\"mydir\")

and you have to use the recursive option in case you w

4条回答
  •  情歌与酒
    2021-02-06 21:08

    Here's a wrapper function for you if you really need to see an error msg:

    .unlink <- function(x, recursive = FALSE, force = FALSE) {
      if (unlink(x, recursive, force) == 0)
        return(invisible(TRUE))
      stop(sprintf("Failed to remove [%s]", x))
    }
    

提交回复
热议问题