In R Studio on my Mac, I've been trying to update ggplot2 from 2.2.1 to 3.1.0 in order to use ggtern. Unfortunately this keeps going round in circles and not working, and I'm a beginner who just doesn't know what to try next! I am using the newest version of R Studio.
I've tried
update.package("ggplot2") which resulted in
update.packages(ggplot2)
Error in update.packages(ggplot2) : object 'ggplot2' not found
And I've tried to update packages from the Output pane. That got into a loop where R Studio asked me to restart R because one or more package to be updated is currently loaded and R needs to restart prior to making the updates. I ended up stopping the loop by not restarting, which then appeared to run an install but ended:
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
I'm afraid that I don't really know how best to explain what I'm seeing, or communicate this in the forum, but I'm hoping I can get a pointer in the right direction. Ultimately I need to make some ternary diagrams, hence my wish to use ggtern...
Warning: When installing a package from github in this way, you might need to install newer versions of other packages. Always be ready to play a bit of "Whack-A-Mole..."
OK, I understand the difference between GitHub and cran so I can see how those lines work. Thanks.
Just a thought: when I began with R Studio, I installed the Tidyverse, of which ggplot2 is a part, so can I do something at that level 'globally' rather then having to wrangle individual packages?
If removing tidyverse as a package successfully removes the component packages, then re-installing tidyverse from source might bring in everything new.
The problem we sometimes run into is that an R installation will only bring in the most recent version of a package known to work with that version of R, not the newest known version of the package. Thus we often need to "force" R to bring in newer versions via source-based installs. I'm not sure how a tidyverse install handles this (ie I'm not sure if installing tidyverse from source actually installs the component packages from source).
I've tried that a couple of times, but the details in the console then always end with this:
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/6q/5g00q97d24z6jg9qwbf0g4x80000gn/T/RtmpcUWv5T/downloaded_packages’
In the list of packages, I can see ggplot2 (version 2.2.1), but the check box next to it is unticked. I've tried to install from the packages list too, but same result.
restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggplot2’
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/6q/5g00q97d24z6jg9qwbf0g4x80000gn/T/RtmpcUWv5T/downloaded_packages’
I don't understand the huge lines of content that ran through the console while it was working, but I can now see a more recent version of ggplot2 in my packages list (hurrah! that means I should be able to load ggtern) and I just loaded ggplot2 and ran one of my histograms and it worked a dream.
Thank you very much, this means a great deal to me. With more practice and experience I can only become more proficient in R, but it's support of people who know what they are doing that makes it possible.
I'm glad I could help If your question's been answered (even by you!), would you mind choosing a 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:
Unfortunately I now have a related problem, trying to access ggtern. Does this (below) mean that I first need to get the package 'robust base' before being able to use ggtern?
library(ggtern)
Error: package or namespace load failed for ‘ggtern’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘robustbase’
In addition: Warning message:
package ‘ggtern’ was built under R version 3.4.4
Just to add a note here, usually you don't need to install the dependencies separately. install.packages defaults to dependencies = NA, i.e. c("Depends", "Imports", "LinkingTo"). If you use TRUE (as Andres did in his solution above), it adds Suggests to the aforementioned list.
Since it seems that it doesn't seem to work for you, and you received this warning message, I think that there's a chance your R version is outdated. You can update it to the latest version 3.6.1, which will probably be useful.
Thank you for explaining that. I'm using R Studio (and I'm in the most recent version of that), because that's how R was introduced to me. What does that mean I have to do if I want to make use of ggtern?