10

I'm using R 3.3.3 and RStudio 1.0.136, and the latest versions of all the packages.

I get this error with the plotly package

> ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)
> ggplotly(ggiris)
Error in grid.Call(L_convert, x, as.integer(whatfrom), as.integer(whatto),  : 
  VECTOR_ELT() can only be applied to a 'list', not a 'NULL'

This error does not occur anymore after I "print" the ggplot:

> ggiris
> ggplotly(ggiris)

It occurs not only in RStudio, but also in a Shiny app.

Any hint ?

Note: This more likely occurs with a "fresh" session (just after opening RStudio).

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

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

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

other attached packages:
[1] plotly_4.5.6  ggplot2_2.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9       tidyr_0.6.1       viridisLite_0.1.3 digest_0.6.12    
 [5] dplyr_0.5.0       assertthat_0.1    grid_3.3.3        plyr_1.8.4       
 [9] R6_2.2.0          jsonlite_1.3      gtable_0.2.0      DBI_0.6          
[13] magrittr_1.5      scales_0.4.1      httr_1.2.1        lazyeval_0.2.0   
[17] labeling_0.3      tools_3.3.3       htmlwidgets_0.8   purrr_0.2.2      
[21] munsell_0.4.3     yaml_2.1.14       base64enc_0.1-3   colorspace_1.3-2 
[25] htmltools_0.3.5   tibble_1.2       
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
  • 1
    Cannot reproduce with: `R version 3.3.2 Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) ... other ... : [1] plotly_4.5.6 ggplot2_2.2.1 loaded ... : [1] Rcpp_0.12.9 tidyr_0.6.1 viridisLite_0.1.3 digest_0.6.12 dplyr_0.5.0 assertthat_0.1 grid_3.3.2 plyr_1.8.4 R6_2.2.0 jsonlite_1.2 gtable_0.2.0 DBI_0.5-1 magrittr_1.5 scales_0.4.1 httr_1.2.1 lazyeval_0.2.0 labeling_0.3 tools_3.3.2 htmlwidgets_0.8 purrr_0.2.2 munsell_0.4.3 yaml_2.1.14 base64enc_0.1-3 colorspace_1.3-2 htmltools_0.3.5 tibble_1.2` – Aurèle Mar 19 '17 at 11:29
  • Thank you for testing @apom. Me too, I've never encountered this issue on 3.3.2. – Stéphane Laurent Mar 19 '17 at 15:57
  • Cannot reproduce it either, R 3.3.2 and R 3.3.3 using RStudio 1.0.136 on Windows 10 – Maximilian Peters Mar 20 '17 at 11:57
  • 1
    This occurs for me too. `RStudio 1.0.136, R 3.3.3, Windows 7 x64, ggplot2_2.2.1` Seems quite random. I restart my session to get rid of it. I am only using ggplot2. So, this probably not a ggplotly issue. – mindlessgreen May 12 '17 at 15:22
  • 1
    Thanks @rmf, I'm feeling less alone now. As you say, quite random. – Stéphane Laurent May 12 '17 at 17:40
  • I got the same error in R version 3.2.3 (Ubuntu command-line). I am using pheatmap. Started a new session and no error. – Abhishek Aug 23 '17 at 08:35
  • This https://github.com/rstudio/rstudio/issues/2919 suggests that the problem may come from having a NULL Viewport, but I don't know how to fix that. – Mark D Oct 29 '20 at 13:06
  • Attempting to set a viewport from https://stat.ethz.ch/R-manual/R-devel/library/grid/doc/viewports.pdf fails. ~~~ > fullheight <- convertHeight(sum(tg$heights),"in",valueOnly = TRUE) Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), : VECTOR_ELT() can only be applied to a 'list', not a 'NULL' > .Call(grid:::C_gridDirty) NULL > .Call(grid:::C_currentViewport) NULL > vptst <- viewport() > pushViewport(vptst) Error in grid.Call(C_setDLelt, x) : INTEGER() can only be applied to a 'integer', not a 'NULL' ~~~ – Mark D Oct 29 '20 at 13:08

2 Answers2

3

I am getting the same error when I change characteristics associated with a ggplotly object within a package I am building. Short term fix is to quit and restart the session, as mentioned in a comment above.

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
K Bro
  • 359
  • 3
  • 6
1

I just encountered the same error on my computer, for the same context. I simply update packages from RStudio interface, then I get the error. You probably need to update your R version, it worked for me.

Hope it will help you!

Norore
  • 79
  • 8
  • 4
    This error "randomly" occurs for me. I have all the latest versions, of the packages and R. – Stéphane Laurent Mar 22 '17 at 11:49
  • Have you found a solution @StéphaneLaurent? I have the same error on a script that runs every weekday and the error occurs about once a month. On scheduled scripts its not possible for me to restart R/Rstudio or other quick fixes. Would be very thankful for any hints,... – Tonio Liebrand Jul 26 '19 at 11:34