How to delete temporary folders under Windows using R?

After the session, I would like to clear my temporary folders, for example,

d <- tempfile() dir.create(d) setwd(d) # now work and sweave and latex etc 

How to remove d and its elements? file.remove does not work.

+6
source share
2 answers

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

+7
source

Try ?unlink . Depends on what you use, but this:

 unlink(d, recursive=TRUE) 

Must work. If you want to delete the contents and reuse the folder, you can try the following:

 file.remove(dir(d, full.names=TRUE)) 
+4
source

Source: https://habr.com/ru/post/889755/


All Articles