简体   繁体   English

ggplot2:我无法理解的错误消息

[英]ggplot2: Error message that I can't understand

I have a data frame "df1" of the following kind: 我有以下类型的数据框“ df1”:

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))

I try to create this plot: 我尝试创建此图:

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. 顺便说一下,我找不到称为方法的程序包。

Here is my sessionInfo() 这是我的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   

Thank you 谢谢

I encountered the same error message and found a solution but in a different context. 我遇到了相同的错误消息,但是在不同的上下文中找到了解决方案。

The error happened while running an R script on a cluster. 在群集上运行R脚本时发生错误。 Interestingly the same script worked fine on a laptop (during testing with a subset of the data). 有趣的是,相同的脚本在笔记本电脑上运行良好(在测试数据的子集期间)。

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". 我的意思是我以前保存了使用“ Seurat”包创建的RDS文件。 When reading the RDS file in a new session the package "Seurat" would load automatically when ran on a local machine. 在新的会话中读取RDS文件时,在本地计算机上运行时,“ Seurat”软件包将自动加载。 However on the cluster I had to specifically load the package with the library() command, before reading the RDS file. 但是,在群集上,在读取RDS文件之前,我必须使用library()命令专门加载程序包。 This is what solved the problem and stopped the obfuscated error message. 这就是解决问题并停止混淆的错误消息的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM