Brian Wiley
Brian Wiley

Reputation: 505

I do NOT want my global environment to clear in R on exit

Even if I indicate "NOT" in a Google search, there is literally no result for this. Everybody wants to clear their global environment.

I am just starting with R so I want to keep all my data and variables so I can play around. Every time I exit R it clears the global environment unless I save the image to a work space .RData file.

How can I keep all my environment intact without have to save twice every time?

Upvotes: 4

Views: 12923

Answers (1)

lbusett
lbusett

Reputation: 5932

If you use RStudio, you can just set the option "Global Options" --> "Save workspace as .RData on exit" to "Always", and the environment will be saved automatically and loaded the next time you open the same project.

AFAIK, saving to a RData file is the easiest way to save the "state" of your environment across sessions. Incidentally, if you do not want to save your objects somewhere, how can you expect to be able to retrieve them afterwards ?

Upvotes: 7

Related Questions