hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
263 stars 37 forks source link

Example not working... #28

Open happyshows opened 7 years ago

happyshows commented 7 years ago
> mpg %>%
+     group_by(manufacturer, class) %>%
+     summarise(
+         panel = panel(
+             qplot(cty, hwy) + xlab("cty") + ylab("hwy") +
+                 xlim(7, 37) + ylim(9, 47) + theme_bw())) %>%
+     trelliscope(name = "dplyr_gg")
Error in eval(expr, envir, enclos) : object 'cty' not found

sessionInfo()

R version 3.3.1 (2016-06-21) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.12.3 (Sierra)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] trelliscopejs_0.1.8

hafen commented 7 years ago

Interesting. This works for me. Have you loaded ggplot2 and dplyr? Here's my session:

> library(trelliscopejs)
library(ggplot2)
library(dplyr)

> library(ggplot2)
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> 
> mpg %>%
+     group_by(manufacturer, class) %>%
+     summarise(
+         panel = panel(
+             qplot(cty, hwy) + xlab("cty") + ylab("hwy") +
+                 xlim(7, 37) + ylim(9, 47) + theme_bw())) %>%
+     trelliscope(name = "dplyr_gg")

sessionInfo()

>                                                                       
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.3

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] dplyr_0.5.0         ggplot2_2.2.1       trelliscopejs_0.1.8

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9             knitr_1.15.1            magrittr_1.5           
 [4] progress_1.1.2          munsell_0.4.3           colorspace_1.3-0       
 [7] R6_2.2.0                plyr_1.8.4              tools_3.3.2            
[10] webshot_0.4.0           grid_3.3.2              gtable_0.2.0           
[13] DBI_0.5-1               htmltools_0.3.5         yaml_2.1.14            
[16] lazyeval_0.2.0          assertthat_0.1          digest_0.6.12          
[19] tibble_1.2              purrr_0.2.2             tidyr_0.6.1            
[22] DistributionUtils_0.5-1 base64enc_0.1-3         htmlwidgets_0.8        
[25] labeling_0.3            scales_0.4.1.9000       prettyunits_1.0.2      
[28] jsonlite_1.2 
happyshows commented 7 years ago

Sure

R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.3 (Sierra)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] bindrcpp_0.1         dplyr_0.5.0.9000     purrr_0.2.2         
[4] readr_1.0.0          tidyr_0.6.1          tibble_1.2          
[7] ggplot2_2.2.1.9000   tidyverse_1.0.0.9000 trelliscopejs_0.1.8 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9.3           bindr_0.1               knitr_1.15.1           
 [4] magrittr_1.5            progress_1.1.2          munsell_0.4.3          
 [7] colorspace_1.2-7        R6_2.2.0                plyr_1.8.4             
[10] tools_3.3.1             webshot_0.4.0           grid_3.3.1             
[13] gtable_0.2.0            DBI_0.5-15              htmltools_0.3.5        
[16] lazyeval_0.2.0.9000     assertthat_0.1          digest_0.6.12          
[19] DistributionUtils_0.5-1 base64enc_0.1-3         scales_0.4.1           
[22] prettyunits_1.0.2       jsonlite_1.2      
ckopsa commented 6 years ago

I too cannot get any of the examples to work. Here is my output with sessionInfo():

library(trelliscopejs)
Warning message:
replacing previous import ‘dplyr::vars’ by ‘ggplot2::vars’ when loading ‘trelliscopejs’ 
> library(ggplot2)
Use suppressPackageStartupMessages() to eliminate package startup
messages.
> library(gapminder)
> library(dplyr)

Attaching package: ‘dplyr’

The following object is masked from ‘package:ggplot2’:

    vars

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

# Example Here
> mpg %>%
+   group_by(manufacturer, class) %>%
+   summarise(
+     panel = panel(
+       qplot(cty, hwy) + xlab("cty") + ylab("hwy") +
+       xlim(7, 37) + ylim(9, 47) + theme_bw())) %>%
+   trelliscope(name = "dplyr_gg")
Error in FUN(X[[i]], ...) : object 'cty' not found

# Sesssion Information
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin17.3.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] bindrcpp_0.2         dplyr_0.7.4          gapminder_0.3.0     
[4] ggplot2_2.2.1.9000   trelliscopejs_0.1.11

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16            bindr_0.1.1             knitr_1.20             
 [4] magrittr_1.5            progress_1.1.2          munsell_0.4.3          
 [7] colorspace_1.3-2        R6_2.2.2                rlang_0.2.0.9001       
[10] plyr_1.8.4              tools_3.4.4             webshot_0.5.0          
[13] grid_3.4.4              gtable_0.2.0            withr_2.1.2            
[16] htmltools_0.3.6         lazyeval_0.2.1          assertthat_0.2.0       
[19] digest_0.6.15           tibble_1.4.2            tidyr_0.8.0            
[22] purrr_0.2.4             DistributionUtils_0.5-1 base64enc_0.1-3        
[25] glue_1.2.0              compiler_3.4.4          pillar_1.2.1           
[28] scales_0.5.0.9000       prettyunits_1.0.2       jsonlite_1.5           
[31] pkgconfig_2.0.1        
hafen commented 6 years ago

Interesting. It looks like you have v0.1.11 installed, and in this version, I do not see any examples that look like the code you provided. Instead of qplot(cty, hwy), it should read qplot(cty, hwy, data = mpg).

GarrettMooney commented 6 years ago

The mpg and gapminder examples don't work for me either.

> library(trelliscopejs)
> library(ggplot2)
RStudio Community is a great place to get help:
https://community.rstudio.com/c/tidyverse.
> library(dplyr)

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

> library(gapminder)
> mpg %>%
+   group_by(manufacturer, class) %>%
+   summarise(panel = panel(
+     qplot(cty, hwy) + xlab("cty") + ylab("hwy") +
+       xlim(7, 37) + ylim(9, 47) + theme_bw()
+   )) %>%
+   trelliscope(name = "dplyr_gg")
Error: All columns in a tibble must be a 1d vector or a list:
* Column `x` is NULL
* Column `y` is NULL
In addition: Warning messages:
1: In fun(name, ...) : Hybrid callback proxy out of scope
2: In fun(name, ...) : Hybrid callback proxy out of scope
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS/LAPACK: /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64_lin/libmkl_rt.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] Cairo_1.5-9          bindrcpp_0.2.2.9000  gapminder_0.3.0.9000 dplyr_0.7.5.9000    
[5] ggplot2_2.2.1.9000   trelliscopejs_0.1.11

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17            knitr_1.20.3            bindr_0.1.1            
 [4] magrittr_1.5.0          progress_1.1.2          tidyselect_0.2.4       
 [7] munsell_0.4.3           colorspace_1.3-2        R6_2.2.2.9000          
[10] rlang_0.2.1             plyr_1.8.4              tools_3.4.4            
[13] webshot_0.5.0           grid_3.4.4              gtable_0.2.0           
[16] withr_2.1.2             htmltools_0.3.6         lazyeval_0.2.1         
[19] assertthat_0.2.0.9000   digest_0.6.15           tibble_1.4.2.9002      
[22] tidyr_0.8.1.9000        purrr_0.2.5             base64enc_0.1-3        
[25] DistributionUtils_0.5-1 glue_1.2.0.9000         compiler_3.4.4         
[28] pillar_1.2.3.9000       prettyunits_1.0.2       scales_0.5.0.9000      
[31] jsonlite_1.5.9000       pkgconfig_2.0.1        
hafen commented 6 years ago

The culprit is ggplot2_2.2.1.9000. There are breaking changes with the dev version (soon to be released on CRAN) that will need to be sorted out. For now, you can use the current CRAN version of ggplot2.

GarrettMooney commented 6 years ago

Thanks! There was still an error with the gapminder examples until I switched to the CRAN version of dplyr as well.