1

我写了以下代码

install.packages('ggplot2', dep = TRUE)
.libPaths(c("C:/Users/Dhanu/Documents/R/win-library/3.3", "C:/Program Files/R/R-3.3.3/library"))
library(ggplot2)

安装 ggplot2 库后出现以下错误。

> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’
4

4 回答 4

1

软件包对您使用的 R 版本非常敏感。我建议移动到最新版本的 R (3.5.1),然后尝试安装ggplot2

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
...
...
> install.packages('ggplot2')
...
> library(ggplot2)
> 
于 2018-07-31T17:18:00.200 回答
0

您能否检查当前工作目录中是否有 ggplot 文件夹C:/Users/Dhanu/Documents/R/win-library/3.3"

于 2018-07-31T17:32:42.440 回答
0

安装了最新版本的 R 并通过再次安装库解决了问题

于 2018-09-01T19:25:44.283 回答
0

工具 > 全局选项 > R 版本(更改) > 使用您机器的默认版本

然后您需要更新您的 R ( https://cran.r-project.org/ ) 并再次安装所有软件包

于 2020-09-02T13:42:42.167 回答