Prevent R from creating R.Data and R.History files

0

I have a script created in R and every time it is executed it leaves two files in the folder, a .Rdata and a .RHistory.

I have put this at the end of my script, but it does not work since you see that it creates the files once it is finished.

if (file.exists(".RData") == TRUE) {
  file.remove(".RData")
}
if (file.exists(".Rhistory") == TRUE) {
  file.remove(".Rhistory")
}

I have to say that I'm pretty new at this.

Thanks for your help.

    
asked by Luxpbi 21.05.2018 в 10:11
source

2 answers

0

Start R in --no-save mode. Query R --help .

You can add this to your shortcuts (in Windows, for example, in the following way in properties)

Source: Here

    
answered by 21.05.2018 в 12:48
0

If you are looking to run a Script in a non-interactive way, the appropriate or indicated way is to do it using the command Rscript . This command is part of all distributions R and by default it does not save the environment when you exit, as you can normally do with the interactive version type Rgui or Rstudio . The execution is not too complex:

Rscript.exe Script.R # En windows
Rscript Script.R # En Linux
    
answered by 21.05.2018 в 16:33