First line of every R script?

I agree with @greg - it's way better to do this outside of your script than inside of it. Apart from objects and packages there are many other global settings (e.g. options(), par(), environment variables) that won't get cleanly reset. I also highly recommend never saving or loading your workspace:

That ensures you always get a clean slate when you restart RStudio, and forces you to record all important steps in code.

17 Likes