I'm new to R and I'm just trying to get through some tutorials.
我是R的新手,我只是想通过一些教程。
When I try installing ggplot2, I get this error.
当我尝试安装ggplot2时,我得到了这个错误。
Error in library(ggplot2) : There is no package called 'ggplot2'
I tried these in R and RStudio.
我在R和RStudio中尝试过这些。
install.packages("ggplot2", dep=T)
install.packages('ggplot2', repos='http://cran.us.r-project.org')
remove.packages("ggplot2")
but I get the error
但是我得到了误差。
(Error in remove.packages : there is no package called 'ggplot2')
This is what I get from install.packages("ggplot2")
这是我从install.package(“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
I removed all ggplot2 files manually then tried to install again. Here's my result.
我手动删除了所有的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’
>
2 个解决方案
#1
1
When having this issue I would suggest :
在讨论这个问题时,我建议:
- try turning it off and on again
- 试着把它关掉。
- update R to last version if possible
- 如果可能的话,更新R到最后一个版本。
- remove manually all the folders related to the relevant package and retry the installation
- 手动删除与相关包相关的所有文件夹,并重试安装。
- change your default library location : How do you change library location in R?
- 更改您的默认库位置:如何在R中更改库位置?
#2
1
Steps
步骤
1)Go To Tools
1)去工具
2)Install Packages
2)安装包
3)In Packages Text Box Type ggplot2
3)在包文本框类型ggplot2中。
4)Check the checkbox install dependencies
4)检查复选框安装依赖项。
#1
1
When having this issue I would suggest :
在讨论这个问题时,我建议:
- try turning it off and on again
- 试着把它关掉。
- update R to last version if possible
- 如果可能的话,更新R到最后一个版本。
- remove manually all the folders related to the relevant package and retry the installation
- 手动删除与相关包相关的所有文件夹,并重试安装。
- change your default library location : How do you change library location in R?
- 更改您的默认库位置:如何在R中更改库位置?
#2
1
Steps
步骤
1)Go To Tools
1)去工具
2)Install Packages
2)安装包
3)In Packages Text Box Type ggplot2
3)在包文本框类型ggplot2中。
4)Check the checkbox install dependencies
4)检查复选框安装依赖项。