我是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’
>
答案 0 :(得分:5)
步骤
转到工具
安装包
在包文本框中键入ggplot2
选中复选框安装依赖项
答案 1 :(得分:1)
遇到这个问题时,我建议:
答案 2 :(得分:1)
您需要更新R版本并执行此操作,但是您需要再次安装所有软件包:
工具>全局选项> R版本(更改)>选择“使用计算机的默认R ...”
答案 3 :(得分:0)
尝试直接从命令提示符启动R客户端,然后发出以下指令: install.packages(“ ggplot2”,lib =“ C:/Users/YourUser/Documents/R/win-library/3.3”)