Difficulty installing ggplot2 in R

I'm working on a Mac running macOR Monterey and for some reason my R does not allow me to install the ggplot2 package. When I use install.packages("ggplot2") and run it I get the following message "One or more of the packages to be updated are currently loaded. Restarting R prior to install is highly recommended. RStudio can restart R before installing the requested packages. All work and data will be preserved during restart. Do you want to restart R prior to install?" when i select yes, the message continues to pop up, when I hit no the package does not install. I've tried restarting R and my entire computer and no luck. Please help!

By any chance do you load any packages before trying to install ggplot2, either manually or via a .Rprofile file which loads packages on startup?

1 Like

I don't believe so, but how can I check that?

Apologies, I'm quite new to R studio.

Thanks!

Rough approach but from a clear start issue the command

 sessionInfo()

There should be no other attached packages:

Packages can be loaded automatically in two ways, as @tjpalanca said, by the presence of a Rprofile startup file (that loads packages) but also by restoring your previous environment.

Rprofile type files can be found in three locations, the first one for the R version-level is called Rprofile.site and is located at R_HOME/etc/ being R_HOME the R's installation folder, the second one for the user-level called .Rprofile can be found at your user's HOME folder and the third one for the project-level also called .Rprofile can be found at your current working directory. Each one, if present, overwrites the previous one. You can check if any of these files are present and if the content is loading any packages.

Also, you can try disabling the "Restore .RData" option to avoid restoring your previous environment.

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.