How to remove a directory in R?

前端 未结 4 1903
有刺的猬
有刺的猬 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 20:50

    For those stumbling on this, I normally resort to using 'shell' command here to completely delete the folder.

    Using 'system' will print a 127 error if the folder is non-empty.

    The following is the simple nuclear option - deleting the folder in its entirety (no questions asked):

    Loc <- "C:/file has spaces/hence the form below/"
    shell( glue::glue("rmdir /s /q \"{Loc}\" ") )
    

提交回复
热议问题