Reset the list of packages back to initial installed state

I've started writing a large project today, but I need to get the list of packages (in the packages window, with the checkboxes) back to what a new user would see. I've been experimenting and planning for a while now, and have accumulated a large number of packages that I can't seem to trim down to what were there when I did a fresh install.

So far, I have used Session > Clear Workspace and Session > Terminate R. After quitting R Studio, I renamed .rstudio-desktop, .Rhistory, and .RData to have "-backup" appended to their names, so I assume they're cleared and will be regenerated when I restart R.

When I restart Rstudio, I notice the package psych is still there. I had also installed the tidyverse before my attempt to get back to nothing,, and I don't think its packages (ggplot2, readr, dplyr, and others) should still be there. Yet they are! And that library I imported for the 2nd Edition of The Statistical Sleuth, the Sleuth2 package, is still there. And when I say "there", I'm looking at the User Libraries section of the RStudio window.

I assume there's something I'm missing. I assume what I'm trying to do isn't impossible, but I suspect there's something in the interaction between R and RStudio I've not reset. Somehow, maybe the packages are still in R, stored in a place I don't yet know to clear out.

To refresh the session and start from scratch you can press Ctrl/Cmd + Shift + F10 .

However, before you do that, make sure you go to "Tools" -> "Global Options" -> "Workspace". "Save workspace to .RData on exit" should be "Never" and "Restore ..." should be unchecked.

If that's what you have, the Ctrl/Cmd + Shift + F10 will start you from the clean session that your users will see in the beginning.

1 Like

Thank you mishabakyasin for your quick response!

I'm on Mac OS X, so I had to do things a shade different: There's no "Workspace" in my global Options window. However, there are options in the General tab: Restore .RData into workspace at startup, which I unchecked, and in the same window I changed Save Workspace to .Rdata to Never. I then pressed the command/⌘ + Shift + F10 and saw "Restarting R Session".

Still, the packages I named above are listed in the user library section.

The packages are listed because they are still installed, one option would by edith your .libPaths() to just include the packages that are installed system wide and not for your specific user, on windows this would be something like

.libPaths()
#> [1] "C:/Program Files/R/R-3.5.2/library"

If you have not installed packages systems wide, then with this method you should end up with just the base r packages listed.

Other option would by uninstall R, delete the content of your .libPaths() and re install R.

1 Like

That is a good hint, andresrcs. I'm one of those people who use Mac OS X and Linux, but (as the saying says), I don't do Windows.

So I need to find out the equivalent of .libpaths() on a Mac. I installed another package and R told me it was installed at /Users/leecreighton/Library/R/3.5/library. I go there, and I see all my packages, and when I delete them, they're gone!

Thanks!

Just to clarify .libPaths() it's a R command and works independently of the OS

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.