R给出了ggplot2表达式的奇怪错误:object' rversion'未找到

时间:2014-05-29 00:22:47

标签: r ggplot2 rstudio

我在Ubuntu 14.04 64位,Rstudio 0.97.551,R 3.1.0中遇到此错误。 我怀疑这是一个与系统环境或rstudio有关的错误,但我提供所有细节以防万一。 我正在使用facet_grid绘制一组图表。当我使用ggplot2

使用以下表达式时,我有一个不可重现的错误
censored_plot <- ggplot(aes(x=lcdm.breaks,y=value,color=diag_groups),
    data=subset(stats.df, test.type %in%
        c("kruskal","levene.hov","anova.homosk","anova.heterosk")))+
    facet_grid(side~test.type)+geom_line()
print(censored_plot)

错误是

Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'rversion' not found
Graphics error: Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'rversion' not found

不可重复的意思是我可以重复相同的表达式而不会出现错误。 例如,之前在同一会话中,

censored_plot <- ggplot(aes(x=lcdm.breaks,y=value,color=diag_groups),
    data=subset(stats.df, test.type%in%   
        c("lillie","kruskal","anova.homosk","anova.heterosk")))+        
    facet_grid(side~test.type)+geom_line()

print(censored_plot)

我得到了理想的情节

censored_plot.2 <- ggplot(aes(x=lcdm.breaks,y=value,colour=diag_groups),
    data=subset(stats.df, test.type%in% 
        c("levene.hov" ,"wilcox.less", "wilcox.less.holm.corr" , "wilcox.greater.holm.corr")))+ 
    facet_grid(side~test.type)+geom_line()
print(censored_plot.2)

Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'rversion' not found
Graphics error: Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'rversion' not found

好的,那不是一个完美的例子。所以我稍后在会话中有以下表达式:

> censored_plot.3 <- ggplot(aes(x=lcdm.breaks,y=value,color=diag_groups),
                           data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
                   facet_grid(side~test.type,drop=TRUE)+geom_line()
> print(censored_plot.3)

Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'rversion' not found
Graphics error: Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'rversion' not found

接着是

> censored_plot.3 <- ggplot(aes(x=lcdm.breaks,y=value,color=diag_groups),
                           data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
                   facet_grid(side~test.type,drop=TRUE)+geom_line()
> print(censored_plot.3)

没有错误。我得到了想要的情节

如果其他人收到此错误:您并不孤单。

编辑:

这些是导致错误的子集的组合 我将使用%str1%来表示 ggplot(aes(x=lcdm.breaks,y=value,color=diag_groups),缩短了代码

> censored_plot.3 <-  %str1% data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
+   facet_grid(side~test.type,drop=TRUE)+geom_point()
> print(censored_plot.3)
##No error

> censored_plot.3 <-  %str1% data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
   facet_grid(side~test.type,drop=TRUE)+geom_line()
> print(censored_plot.3)
##No error

> censored_plot <-  %str1% data=subset(stats.df,
                                     test.type%in% c("lillie","kruskal","anova.homosk","anova.heterosk")))+        
                           facet_grid(side~test.type)+geom_line()
> print(censored_plot)
##No error 


> censored_plot.2 <-%str1% data=subset(stats.df, 
                                     test.type%in% c("levene.hov" ,"wilcox.less", "wilcox.less.holm.corr" , "wilcox.greater.holm.corr")))+ 
                   facet_grid(side~test.type)+geom_line()
> print(censored_plot.2)
#Error


> censored_plot.3 <- %str1% data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
                   facet_grid(side~test.type,drop=TRUE)+geom_line()
> print(censored_plot.3)
## No error

censored_plot.lil <-  %str1% data=subset(stats.df,
                                     test.type%in% c("lillie")))+        
   facet_grid(side~test.type)+geom_line()
> print(censored_plot.lil)
# No error

 censored_plot <-  %str1% data=subset(stats.df,
                                     test.type%in% c("kruskal","levene.hov","anova.homosk","anova.heterosk")))+        
                           facet_grid(side~test.type)+geom_line()
> print(censored_plot)
#Error


censored_plot.2 <-  %str1%  data=subset(stats.df, 
                                     test.type%in% c("wilcox.less", "wilcox.less.holm.corr" , "wilcox.greater.holm.corr")))+ 
                   facet_grid(side~test.type)+geom_line()
> print(censored_plot.2)
# Error



> censored_plot.3 <- %str1% data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
                   facet_grid(side~test.type,drop=TRUE)+geom_line()
> print(censored_plot.3)
#Error

censored_plot.3 <-  %str1% data=subset(stats.df, 
                                       test.type%in% c( "t.less", "t.less.holm.corr", "t.greater.holm.corr" )))+                          
                   facet_grid(side~test.type,drop=TRUE)+geom_line()
> print(censored_plot.3)
#no error

> censored_plot.2 <-  %str1% data=subset(stats.df, 
                                     test.type%in% c("wilcox.less", "wilcox.less.holm.corr" , "wilcox.greater.holm.corr")))+ 
                   facet_grid(side~test.type)+geom_line()
> print(censored_plot.2)
#no error

> censored_plot.lil <-  %str1% data=subset(stats.df,
                                     test.type%in% c("lillie")))+        
   facet_grid(side~test.type)+geom_line()
> print(censored_plot.lil)
> 
#no error

> censored_plot <-  %str1%  data=subset(stats.df,
                                     test.type%in% c("kruskal","levene.hov","anova.homosk","anova.heterosk")))+
                           facet_grid(side~test.type)+geom_line()
> print(censored_plot)
# error

> censored_plot.lil <-  %str1% data=subset(stats.df,
                                     test.type%in% c("lillie")))+        
   facet_grid(side~test.type)+geom_line()
> print(censored_plot.lil)
#no error

> censored_plot.lil <-  %str1% data=subset(stats.df,
                                     test.type%in% c("lillie")))+        
   facet_grid(side~test.type)+geom_line()+scale_y_continuous(limits= c(0,1))
> print(censored_plot.lil)
#no error

我最终得到了我想要的情节。但是,我仍然不知道发生了什么以及为什么我得到了不透明的错误信息。

2 个答案:

答案 0 :(得分:3)

直到现在我才遇到这个问题

我找到了这个链接,提出了Rstudio核心问题 https://support.rstudio.com/hc/communities/public/questions/200649626-Graphics-error-when-executing-a-second-plot-from-a-R-script-using-recent-R-3-0-2-patched-versions

我升级了我的RStudio并解决了问题

(我使用的是Windows,但RStudio核心是跨平台的。 我的新RStudio版本是RStudio-0.98.507.exe)

答案 1 :(得分:0)

可以修复

的一种简单方法

<input type="text" size="75" autofocus="true" name="searchinput" id="textfield"/> <input type="submit" value="find" onclick="myFunction()"/>

错误就是退出RStudio并再次启动它。