【发布时间】:2017-10-16 15:09:31
【问题描述】:
我是 R 新手,我只是想通过一些教程。
当我尝试安装 ggplot2 时,出现此错误。
Error in library(ggplot2) : There is no package called 'ggplot2'
我在 R 和 RStudio 中尝试过这些。
install.packages("ggplot2", dep=T)
install.packages('ggplot2', repos='http://cran.us.r-project.org')
remove.packages("ggplot2")
但我得到了错误
(Error in remove.packages : there is no package called 'ggplot2')
这是我从 install.packages("ggplot2") 得到的
> install.packages("ggplot2")
Installing package into ‘.../R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = ".../R/win-library/3.4"' is not writable
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/ggplot2_2.2.1.zip'
Content type 'application/zip' length 2784566 bytes (2.7 MB)
downloaded 2.7 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘ggplot2’
The downloaded binary packages are in
C:...\AppData\Local\temp\RtmpqaGNpr\downloaded_packages
我手动删除了所有 ggplot2 文件,然后尝试再次安装。这是我的结果。
> install.packages("ggplot2")
Installing package into ‘.../R/win-library/3.4’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://ftp.osuosl.org/pub/cran/bin/windows/contrib/3.4/ggplot2_2.2.1.zip'
Content type 'application/zip' length 2784566 bytes (2.7 MB)
downloaded 2.7 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
Warning: unable to move temporary installation ‘...\R\win-library\3.4\file26b43a54980\ggplot2’ to ‘...\R\win-library\3.4\ggplot2’
The downloaded binary packages are in
C:...\AppData\Local\temp\Rtmpq0T9a6\downloaded_packages
> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’
> library("ggplot2")
Error in library("ggplot2") : there is no package called ‘ggplot2’
这些代码是使用 R 3.4.2 运行的
【问题讨论】:
-
install.packages行有什么错误?那个可能更相关。 -
最好从其源获得
ggplot。您应该安装包devtools,然后使用devtools::install_github("tidyverse/ggplot2")安装ggplot。这是一个链接:github.com/tidyverse/ggplot2 -
library不安装包,只是让它可用,首先运行install.packages("ggplot2"),然后运行library(ggplot2) -
几天前我在
purrr遇到了这个问题,我关闭了所有 R 会话,手动删除了现有文件,之后安装顺利 -
你可以尝试更改默认安装文件夹,检查这个:stackoverflow.com/questions/2698269/…