I always start my scripts with:
rm(list=ls())
to clear my workspace to avoid conflicts between different scripts. However, I'm looking for a way to also set all changed options to their default state. For instance, in some scripts I need to change the SS type by setting:
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
In other scripts I need to use the default option (and since it is default I do not specify it directly) that is:
options(contrasts=c(unordered="contr.treatment", ordered="contr.poly"))
but if a script with the changed options was just used before, the option is obviously changed without me noticing it.
Is there a command that I could put on top of my scripts to reset R to default options?
op <- options(...); your stuff here; options(op)
.