Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to silently remove files in R

Tags:

r

Given the following code:

x <- 1
save(x, file = "x")
file.remove("x")

The file.remove() command successfully removes the x file. However, it returns TRUE to the R console. How do I keep it from doing that?

I've tried things like file.remove("x", silent = TRUE), but it seems that whatever I add to the function is interpreted as a file name, since the above returns cannot remove file 'TRUE', reason 'No such file or directory'.

like image 982
Waldir Leoncio Avatar asked Dec 15 '22 19:12

Waldir Leoncio


1 Answers

Try wrapping the call with invisible

x <- 1
save(x, file = "x")
invisible(file.remove("x"))
like image 87
Rich Scriven Avatar answered Dec 29 '22 00:12

Rich Scriven