如何在适用于Mac的R版本3.2.1中安装ggp​​lot2

时间:2015-08-06 14:22:36

标签: r ggplot2 install packages osx-mountain-lion

我刚刚下载了R和Rstudio的新Mac版本,但是当我尝试通过Rstudio界面安装ggp​​lot2时收到以下错误消息。有替代方法吗?

> 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) 

我的会话信息是:

> 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

我不知道它是否有意义,但我和其他许多我尝试过的套餐有类似的问题,包括心理和Hmisc。我能够安装dplyr(版本0.4.2)。我尝试回到早期版本的R,但我发现的Mac版本太旧了: https://cran.r-project.org/bin/macosx/old/index-old.html

3 个答案:

答案 0 :(得分:5)

我通过进入Rstudio,然后单击工具然后单击选项来解决我的问题。然后我从弹出框中选择了包。这会弹出“程序包安装”屏幕,点击CRAN镜像旁边的“更改”,然后选择名为USA(CA 1)的镜像 - 加州大学伯克利分校。

答案 1 :(得分:1)

我也遇到了这个问题,最后通过取消选中Tools-> Global Options-> Packages中的“使用HTTP的安全下载方法”选项解决了这个问题。

答案 2 :(得分:0)

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