Hi @serge! Welcome!
Since your problem is not identical (it apparently needs its own solution), it is better if you start a new topic. You can link to any previous related topics if you want to clarify what you’ve already read/tried. In keeping with this philosophy, I’m moving your post to its own topic.
To your specific problem:
The key thing to include when seeking help for package installation issues is all of the console output you see when you try to install the package. To share that here, you should copy and paste it from the console (no screenshots please!) and use the little
</> button at the top of the posting box to format the output as code. This makes it easier for helpers to read and keeps the forum software from garbling it.
Another thing that is often helpful is the output of running
sessionInfo(). Same rules for copy-pasting and formatting apply.
Without seeing the console output you get when you try to install
ggplot2, I can’t say for sure what’s wrong, but here are a few things to try:
- Always restart your R session (RStudio Session menu) before and after installing packages
- Given the error message above, you may have a failed
ggplot2 installation that needs to be cleaned up. Try running
remove.packages("ggplot2"), and then try installing again. If
remove.packages() doesn’t work, you may need to go look for the
ggplot2 folder in your library and delete it yourself.
- You seem to be running a version of R that is 2 years old. Pre-compiled packages are no longer made available for older versions of R, so the longer you run old versions of R, the more likely it is that you will have to compile packages or their dependencies from source. On Windows, this often requires having the RTools installed (a set of external software tools for building R and R packages from source). Unless you have a very good reason for running older R, I recommend updating R and then trying all of this again. Your package installation life will generally be much easier if you keep R itself updated.