user3614783
user3614783

Reputation: 841

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

Upvotes: 4

Views: 16381

Answers (4)

Alycia Currie
Alycia Currie

Reputation: 1

I also solved the issue by instead of typing it in the script. I went to > tools >install packages > ggplots2 > install. I don't know why that was any different but it installed.

Upvotes: 0

Amrit Dillon
Amrit Dillon

Reputation: 1

If nothing works, try this:

  1. ggplot2 installation on MAC by AMRIT DHILLON

    (a) Open https://cran.r-project.org/web/packages/ggplot2/index.html and download ggplot2 (tzg) file for MAC [DIRECT LINK TO DOWNLOAD IS HERE]: https://cran.r-project.org/bin/macosx/mavericks/contrib/3.3/ggplot2_2.2.0.tgz

    (b) Open ggplot2.tgz file with Archive Utility and it will be extracted in a Folder.

    (c) Copy ggplot2 Folder.

    (d) While pressing Option key, Select Go from Finder's Menu, and select and open Library ( Hidden file, only become visible when you select GO while holding Option Key).

    (e) From Library go to a Library folder of R: Library > R > 3.3 > Library (Paste ggplot2 folder here)

    (f) Restart R and you are good to go.

Regards, Amrit Dhillon

Upvotes: 0

wangjiezhe
wangjiezhe

Reputation: 121

I got to this problem also, and finally solved it by uncheck the "Use secure download method for HTTP" option in Tools->Global Options->Packages.

Upvotes: 1

user3614783
user3614783

Reputation: 841

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.

Upvotes: 5

Related Questions