我已经安装了R和RStudio,但我相信我已经正确设置了环境变量。我已经安装了ggplot2及其依赖项,但即使在以管理员身份运行RStudio之后我也无法加载ggplot2。以下是一些瞥见:
> install.packages("ggplot2", dependencies = TRUE)
Installing package into ‘C:/Users/mosen/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
然后我会看到从各种CRAN网址安装依赖软件包的通知,然后解压缩这些软件包....
package ‘knitr’ successfully unpacked and MD5 sums checked
package ‘rmarkdown’ successfully unpacked and MD5 sums checked
package ‘svglite’ successfully unpacked and MD5 sums checked
package ‘ggplot2’ successfully unpacked and MD5 sums checked
等。然后经过一定的验证,我收到了消息,
The downloaded source packages are in
‘C:\Users\mosen\AppData\Local\Temp\RtmpCOIHuQ\downloaded_packages’
我可以看到此目录中的压缩文件。然而,
> load("ggplot2")
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the
connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file 'ggplot2', probable reason 'No such
file or directory'
请帮忙!我的工作目录是" C:/ Users / mosen / Documents"。
答案 0 :(得分:2)
我认为您library(ggplot2)
之后只需要require(ggplot2)
或load(ggplot2)
而不是install.packages("ggplot2")
。 Load("...")
是一个加载数据集的函数,而不是启用包中的函数。