R(Rstudio)中的“达到经过的时间限制”错误

时间:2018-07-09 13:45:29

标签: r rstudio

我在R中不断收到“达到经过时间限制”错误。我正在使用Studio。

这是我要运行的代码,是ggplot中的一个简单图形:

require(ggplot2)
docgraph <- ggplot(data = plotnvto, aes(calluna, doc)) + 
  geom_point(aes(x = calluna, y = doc, color = "calluna"), size = 3) + 
  geom_point(aes(x = sedge, y = doc, colour = "sedge"), size = 3) +
  geom_smooth(aes(calluna,doc), method=lm, se=FALSE, color = "purple") +
  geom_smooth(aes(sedge,doc), method=lm, se=FALSE, color = "green") +
  scale_colour_manual("", 
                      values = c("calluna"="purple", "sedge"="green")) +
  labs(x= "Percent Cover", y= "DOC (mg/L)") +
  annotate(geom="text", x=10, y=36, label="y = -0.4498x + 26.6843
R² = 0.1836, p = 0.1646",color="purple") +
  annotate(geom="text", x=30, y=36, label="y = -0.5058x + 16.0603
R² = 0.1026, p = 0.3012",color="darkgreen") +
  theme_bw() +
  xlim(0,60) +
  ylim(0,50)
docgraph  

每次运行它时,都会收到一条有关达到已用时间限制的错误消息。每次执行此操作时,图形中都会丢失某些内容,无论是图例,轴,网格线,点,颜色等。错误消息每次都不同,例如:

In depth(x$children[[length(x$children)]], ...) :
  reached elapsed time limit

In paste(names[seq_len(n - 1L)], collapse = .grid.pathSep) :
  reached elapsed time limit

In lapply(X = X, FUN = FUN, ...) : reached elapsed time limit

In x$vp : reached elapsed time limit

这些错误似乎都没有涉及我的任何数据。这是一台刚安装了R和Rstudio的电脑以及我的数据文件,如下所示:

 summary(vegdocverages2016)
 plotslope      month    siteplot      ee6             h254             h400             doc              suva        
 plot :12   march  :12   MC:4     Min.   :1.886   Min.   : 962.9   Min.   : 192.9   Min.   : 7.109   Min.   :0.08819  
 slope:12   october:12   MT:4     1st Qu.:2.773   1st Qu.:2216.8   1st Qu.: 445.4   1st Qu.:15.428   1st Qu.:0.10732  
                         NC:4     Median :3.074   Median :3037.5   Median : 544.3   Median :21.407   Median :0.12451  
                         NT:4     Mean   :3.013   Mean   :2947.6   Mean   : 560.6   Mean   :22.373   Mean   :0.12649  
                         WC:4     3rd Qu.:3.345   3rd Qu.:3712.2   3rd Qu.: 666.4   3rd Qu.:27.371   3rd Qu.:0.13597  
                         WT:4     Max.   :3.639   Max.   :4735.5   Max.   :1070.4   Max.   :45.668   Max.   :0.17626  
    calluna          sedge           sphag             moss            bare       
 Min.   : 3.75   Min.   :15.11   Min.   : 0.000   Min.   : 7.50   Min.   : 1.250  
 1st Qu.:11.25   1st Qu.:16.75   1st Qu.: 0.000   1st Qu.:24.12   1st Qu.: 8.417  
 Median :15.28   Median :30.03   Median : 2.222   Median :28.89   Median :20.728  
 Mean   :16.55   Mean   :29.94   Mean   : 3.097   Mean   :27.98   Mean   :18.136  
 3rd Qu.:21.44   3rd Qu.:38.65   3rd Qu.: 4.514   3rd Qu.:30.25   3rd Qu.:25.875  
 Max.   :33.75   Max.   :52.50   Max.   :13.500   Max.   :54.50   Max.   :32.500  
Warning message:
In dontCheck(fnname) : reached elapsed time limit

是PC上保存的唯一.csv。

对于这个错误的含义以及如何解决它,我有些困惑,当我搜索这个错误时,我并不太了解其他答案。

编辑,这是sessionInfo()

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
[1] ggmap_2.6.1   ggplot2_3.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17      pillar_1.2.3      compiler_3.5.1    plyr_1.8.4        bindr_0.1.1       tools_3.5.1      
 [7] digest_0.6.15     tibble_1.4.2      gtable_0.2.0      lattice_0.20-35   pkgconfig_2.0.1   png_0.1-7        
[13] rlang_0.2.1       Matrix_1.2-14     mapproj_1.2.6     proto_1.0.0       bindrcpp_0.2.2    withr_2.1.2      
[19] dplyr_0.7.6       stringr_1.3.1     RgoogleMaps_1.4.2 maps_3.3.0        grid_3.5.1        tidyselect_0.2.4 
[25] glue_1.2.0        R6_2.2.2          jpeg_0.1-8        sp_1.3-1          purrr_0.2.5       reshape2_1.4.3   
[31] magrittr_1.5      scales_0.5.0      assertthat_0.2.0  colorspace_1.3-2  geosphere_1.5-7   labeling_0.3     
[37] stringi_1.1.7     lazyeval_0.2.1    munsell_0.5.0     rjson_0.2.20     
Warning message:
In unlist(x, recursive = FALSE) : reached elapsed time limit

这是数据集的一些示例,相对较小:

> head(vegdocverages2016)
  plotslope month siteplot      ee6    h254   h400      doc       suva calluna sedge sphag  moss  bare
1      plot march       NC 2.906985 3117.30 613.20 21.48609 0.12880545    3.75 52.50   0.0  7.50 25.00
2      plot march       NT 2.943432 2153.04 516.12 18.29540 0.09992877   25.55 15.75   0.0 30.25 28.50
3      plot march       MC 1.942531 1024.80 192.90 12.62613 0.12917354   22.00 22.00   0.0 54.50  1.25
4      plot march       MT 2.581118 1985.82 356.28 13.07213 0.16446263   11.25 38.75  13.5 29.50  7.00
5      plot march       WC 2.670563 2238.00 388.40 27.37139 0.12932109   10.65 16.75   3.0 45.40 23.40
6      plot march       WT 2.804038 1931.50 526.80 27.37139 0.12932109   10.65 16.75   3.0 45.40 23.40

摘要:

> summary(vegdocverages2016)
  plotslope            month             siteplot              ee6             h254             h400       
 Length:24          Length:24          Length:24          Min.   :1.886   Min.   : 962.9   Min.   : 192.9  
 Class :character   Class :character   Class :character   1st Qu.:2.773   1st Qu.:2216.8   1st Qu.: 445.4  
 Mode  :character   Mode  :character   Mode  :character   Median :3.074   Median :3037.5   Median : 544.3  
                                                          Mean   :3.013   Mean   :2947.6   Mean   : 560.6  
                                                          3rd Qu.:3.345   3rd Qu.:3712.2   3rd Qu.: 666.4  
                                                          Max.   :3.639   Max.   :4735.5   Max.   :1070.4  
      doc              suva            calluna          sedge           sphag             moss            bare       
 Min.   : 7.109   Min.   :0.08819   Min.   : 3.75   Min.   :15.11   Min.   : 0.000   Min.   : 7.50   Min.   : 1.250  
 1st Qu.:15.428   1st Qu.:0.10732   1st Qu.:11.25   1st Qu.:16.75   1st Qu.: 0.000   1st Qu.:24.12   1st Qu.: 8.417  
 Median :21.407   Median :0.12451   Median :15.28   Median :30.03   Median : 2.222   Median :28.89   Median :20.728  
 Mean   :22.373   Mean   :0.12649   Mean   :16.55   Mean   :29.94   Mean   : 3.097   Mean   :27.98   Mean   :18.136  
 3rd Qu.:27.371   3rd Qu.:0.13597   3rd Qu.:21.44   3rd Qu.:38.65   3rd Qu.: 4.514   3rd Qu.:30.25   3rd Qu.:25.875  
 Max.   :45.668   Max.   :0.17626   Max.   :33.75   Max.   :52.50   Max.   :13.500   Max.   :54.50   Max.   :32.500  

6 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,并随机尝试运行dev.off()。它对我有用。

答案 1 :(得分:2)

答案 2 :(得分:1)

我在这里添加我的答案,以防其他人遇到同样的问题。我的 ggplot2 图有一个零星的问题,缺少轴和注释。当我选择一个代码块并只运行该块时,通常会出现问题(如果我从头到尾运行整个脚本,我通常不会遇到问题)。 user12671124 的建议(从上面)有效,但有点痛苦。我终于找到了问题的根本原因。我有一个超出绘图范围的数据点。每当生成绘图时,我都会收到一条警告消息。一旦我删除了那个有问题的数据点,我也解决了缺少绘图元素的问题。

答案 3 :(得分:0)

我遇到了同样的错误。我在一些计算(特别是“ as.double(2730.94 / 3682),as.double(5052.23 / 12308)”)周围添加了as.double(),它解决了我的问题。

答案 4 :(得分:0)

我遇到了同样的问题。重新安装RStudio没有帮助。

就我而言,例如,通过从全局环境中删除所有对象rm(list = ls())暂时解决了该问题-清除全局环境后的第一个绘图已完成。但是,在第二个绘图中,部分绘图再次丢失。 值得注意的是,当我将图导出为pdf时,可以正确导出完整图。

始终清除全球环境是一个可怕的解决方法。我希望听到更好的解决方案。

答案 5 :(得分:0)

我有同样的问题。对我有用的是首先运行组成剧本的脚本部分。停止。并且只有然后运行旨在生产地块的代码。 因此,关于您的脚本,将:首先运行除最后一个代码(文档)以外的所有代码。然后运行docgraph。我没有使用您的脚本尝试此操作,但是可以尝试一下。无论出于什么原因,它确实可以工作。