ggplot2:我无法理解的错误消息 [英] ggplot2: Error message that I can't understand
问题描述
我有以下类型的数据帧"df1":
I have a data frame "df1" of the following kind:
set.seed(2)
df1 = data.frame(Var1=rep(c('a','b','c','d'),3),
Var2=rep(c('aa','bb','cc'),each=4),
value=rnorm(12))
我尝试创建此图:
ggplot(df1) + geom_bar(aes(x=Var2,y=value),stat="identity") + facet_wrap(~Var1)
,我收到以下我不理解的错误消息:
and I get the following error message that I don't understand:
formal classes cannot be used without the methods package
怎么了?顺便说一句,我找不到名为方法的程序包.
What's wrong ? I can't find a package called methods by the way.
这是我的sessionInfo()
Here is my sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] fr_CH.UTF-8/fr_CH.UTF-8/fr_CH.UTF-8/C/fr_CH.UTF-8/fr_CH.UTF-8
attached base packages:
[1] utils graphics methods stats base
other attached packages:
[1] agricolae_1.1-4 reshape2_1.2.2 lattice_0.20-15 ggplot2_0.9.3.1 data.table_1.8.8
loaded via a namespace (and not attached):
[1] colorspace_1.2-2 datasets_3.0.1 dichromat_2.0-0 digest_0.6.3 grDevices_3.0.1 grid_3.0.1 gtable_0.1.2
[8] labeling_0.1 lme4_0.999999-2 MASS_7.3-26 Matrix_1.0-12 munsell_0.4 nlme_3.1-109 plyr_1.8
[15] proto_0.3-10 RColorBrewer_1.0-5 scales_0.2.3 stats4_3.0.1 stringr_0.6.2 tools_3.0.1
谢谢
推荐答案
我遇到了相同的错误消息,并找到了解决方案,但上下文不同.
I encountered the same error message and found a solution but in a different context.
在集群上运行R脚本时发生错误.有趣的是,同一脚本在笔记本电脑上可以很好地工作(在测试数据的子集期间).
The error happened while running an R script on a cluster. Interestingly the same script worked fine on a laptop (during testing with a subset of the data).
在我的上下文中,解决方案是导入用于预处理数据的包.我的意思是我以前保存了使用"Seurat"包创建的RDS文件.在新的会话中读取RDS文件时,在本地计算机上运行时,"Seurat"软件包将自动加载.但是,在群集上,在读取RDS文件之前,我必须使用library()命令专门加载程序包.这就是解决问题并停止混淆的错误消息的原因.
The solution in my context was to import the package with which the data was preprocessed. What I mean is that I previously saved an RDS file created using the package "Seurat". When reading the RDS file in a new session the package "Seurat" would load automatically when ran on a local machine. However on the cluster I had to specifically load the package with the library() command, before reading the RDS file. This is what solved the problem and stopped the obfuscated error message.
这篇关于ggplot2:我无法理解的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!