r - R 中出现错误 - [错误 : could not find function "qplot"]

标签 r ggplot2

原始R版本

R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

> library(ggplot2)
Error in library.dynam(lib, package, package.lib) : 
  DLL ‘colorspace’ not found: maybe not installed for this architecture?
In addition: Warning message:
package ‘ggplot2’ was built under R version 3.2.3 
Error: package or namespace load failed for ‘ggplot2’
> qplot(weights, prices, color = types)
Error: could not find function "qplot"

....嗨,运行 ggplot2 时遇到一些问题,我正在尝试完成基本的在线教程,然后问题是尝试在其中一个练习中运行 qplot,然后我得到了上面列出的错误,我在之前的帮助查找中阅读了一些内容,经历了以下 Action :

  • install.packages("proto")
  • install.packages('ggplot2', dep = TRUE),
  • 重新启动 R - 仍然出现错误。还有其他“答案”吗?

@MLavoie,迈克·怀斯

> install.packages('ggplot2', dependencies = TRUE)
Installing package into ‘C:/Users/Sony/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/ggplot2_2.0.0.zip'
Content type 'application/zip' length 1977368 bytes (1.9 MB)
downloaded 1.9 MB

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\Sony\AppData\Local\Temp\RtmpY97TTR\downloaded_packages
> library("ggplot2", lib.loc="~/R/win-library/3.2")
Error in get(Info[i, 1], envir = env) : 
  cannot open file 'C:/Users/Sony/Documents/R/win-library/3.2/scales/R/scales.rdb': No such file or directory
Error: package or namespace load failed for ‘ggplot2’

session 信息:

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2movies_0.0.1

loaded via a namespace (and not attached):
[1] colorspace_1.2-6 plyr_1.8.3       tools_3.2.3      gtable_0.1.2     Rcpp_0.12.3      grid_3.2.3       munsell_0.4.2   

最佳答案

安装ggp​​lot2后我遇到了同样的错误。有两种解决方法:

1) 在调用 qplot() 之前需要加载“library(ggplot2)”

library(ggplot2)
qplot(factor(CLASS), VOLUME, data = abalone, geom = "boxplot")

2)我随机发现在代码前面添加“ggplot2::”也可以使其工作,而无需调用库。

ggplot2::qplot(factor(CLASS), VOLUME, data = abalone, geom = "boxplot")

关于r - R 中出现错误 - [错误 : could not find function "qplot"],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34826635/

相关文章:

R 计算有条件的连续天数

r - 添加更改时自动重新加载 Shiny 的应用程序

r - SparkR foreach 循环

r - 如何在ggplot2中指定图形的大小而与轴标签无关

r - 为什么我对球体的核密度估计不起作用?

r - 使用 R 解释外部使用的符号公式

r - 在不同层使用 ggplot2 绘制多条 ROC 曲线

r - ggplot2 绘制比数据框中更多的点,geom_point + facet_grid

r - 如何在 R 中以固定网格模式绘制 "matrix"

r - 控制ggplot2中多层图的图例