开发者

How can I remove temporary folders under Windows with R?

开发者 https://www.devze.com 2023-03-10 13:54 出处:网络
After a session I would like to clean up my temporary folders, like for instance d <- tempfile() d开发者_开发百科ir.create(d)

After a session I would like to clean up my temporary folders, like for instance

d <- tempfile()
d开发者_开发百科ir.create(d)
setwd(d)
# now work and sweave and latex etc

How can I remove d and its elements? file.remove fails.


Try unlink("d", recursive=TRUE). That should delete the folder and its contents.


Try ?unlink. Depends on what os you are using but this:

unlink(d, recursive=TRUE)

Should work. If you want to delete the contents and reuse the folder you could try this:

file.remove(dir(d, full.names=TRUE))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号