R 3.4.2库(ggplot2)中的错误:没有名为“ ggplot2”的软件包

man*_*son 6 r ggplot2

我是R的新手,我只是想尝试一些教程。

当我尝试安装ggp​​lot2时,出现此错误。

Error in library(ggplot2) : There is no package called 'ggplot2'
Run Code Online (Sandbox Code Playgroud)

我在R和RStudio中尝试了这些。

install.packages("ggplot2", dep=T)

install.packages('ggplot2', repos='http://cran.us.r-project.org')

remove.packages("ggplot2")
Run Code Online (Sandbox Code Playgroud)

但我得到了错误

(Error in remove.packages : there is no package called 'ggplot2')
Run Code Online (Sandbox Code Playgroud)

这就是我从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
Run Code Online (Sandbox Code Playgroud)

我手动删除了所有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’
> 
Run Code Online (Sandbox Code Playgroud)

小智 6

脚步

  1. 转到工具

  2. 安装套件

  3. 包装内文本框类型 ggplot2

  4. 选中复选框安装依赖项


Moo*_*per 1

当遇到这个问题时,我建议:

  • 尝试将其关闭然后再次打开
  • 如果可能的话将 R 更新到最新版本
  • 手动删除与相关包相关的所有文件夹并重试安装
  • 更改默认库位置:如何更改 R 中的库位置?