Search code examples
rggplot2installationpackageosx-mountain-lion

How to install ggplot2 in R version 3.2.1 for Mac


I just downloaded new Mac versions of R and Rstudio, but am getting the following error message when I try to install ggplot2 through the Rstudio interface. Is there an alternative approach?

> install.packages("ggplot2")
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib
Warning in install.packages :
  package ‘ggplot2’ is not available (for R version 3.2.1)
Installing package into ‘/Users/tom.glaser/Library/R/3.2/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib
Warning in install.packages :
  package ‘ggplot2’ is not available (for R version 3.2.1)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/macosx/contrib/3.2
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.1) 

My session info is:

> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.8.5 (Mountain Lion)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.2.1

I don't know if it's significant, but I'm having similar problems with many other packages I've tried, including psych and Hmisc. I was able to install dplyr (version 0.4.2). I tried going back to an earlier version of R, but the Mac versions I found were too old: https://cran.r-project.org/bin/macosx/old/index-old.html


Solution

  • I solved my problem by going into Rstudio, and clicking on Tools and then Options. I then selected Packages from the pop-up box. This popped up the Package Installation screen, where I clicked on "Change" next to CRAN mirror, and then selected the mirror called USA (CA 1) - University of California, Berkeley.