I have partially built a package in R.
I have 2 instances of Rstudio running. I have the package open in one instance and a project i am working on in another. As i am working on my project i find that i need to add additional functionality to the package. So i go to the package, add the functionality, build it, then return the project i am working on. This additional functionality is not available to me in my project. I find i have to restart R each time (Ctrl + shift + F10) but i lose everything in my environment. Of course i could save the environment before closing, but i still have to close Rstudio. I am finding this frustrating and time consuming
I am sure i am approaching this all wrong so what is the best way to be deal with this? thanks
# replace "mypackage" with your package's name
detach("package:mypackage", unload = TRUE)
What I do: accept it as a pain. If you keep your work in scripts, you can just rerun those. Or if you're the "free explorer" type, then you can re-run the commands from the history pane. Hopefully it won't take too long. I like to use this kind of time as an excuse to browse these forums.
Would you mind marking your use of unloadNamespace as the solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: