Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

animit2dir does not work #173

Closed
ndaniel opened this issue Dec 5, 2016 · 6 comments
Closed

animit2dir does not work #173

ndaniel opened this issue Dec 5, 2016 · 6 comments

Comments

@ndaniel
Copy link

ndaniel commented Dec 5, 2016

Running this:

library(animint)
example(animint)

gives this error:

animnt> ## Make a Gapminder plot (aka Google motion chart), which is actually
animnt> ## just a scatterplot with size and color that moves over time.
animnt> library(animint)

animnt> data(WorldBank)

animnt> gapminder <-
animnt+   list(title="Linked scatterplot and time series",
animnt+        ts=ggplot()+
animnt+        make_tallrect(WorldBank, "year")+
animnt+        geom_line(aes(year, life.expectancy, group=country, color=region,
animnt+                      clickSelects=country),
animnt+                  data=WorldBank, size=4, alpha=3/5),
animnt+        time=list(variable="year",ms=3000),
animnt+        duration=list(year=1000),
animnt+        scatter=ggplot()+
animnt+        geom_point(aes(fertility.rate, life.expectancy, clickSelects=country,
animnt+                       key=country,
animnt+                       showSelected=year, colour=region, size=population),
animnt+                   data=WorldBank)+
animnt+        geom_text(aes(fertility.rate, life.expectancy, label=country,
animnt+                      showSelected=country, showSelected2=year),
animnt+                  data=WorldBank)+
animnt+        make_text(WorldBank, 5, 80, "year")+
animnt+        scale_size_animint(pixel.range=c(2,20), breaks=10^(4:9)))
Warning: Ignoring unknown aesthetics: clickSelects.variable, clickSelects.value, showSelected.variable, showSelected.value, key
Warning: Ignoring unknown aesthetics: clickSelects
Warning: Ignoring unknown aesthetics: clickSelects, key, showSelected
Warning: Ignoring unknown aesthetics: showSelected, showSelected2
Warning: Ignoring unknown aesthetics: showSelected

animnt> animint2dir(gapminder, "WorldBank-viz")
Error in if (attributes(margin.value)$unit == "pt") { : 
  argument is of length zero

More info is here:

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

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

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

other attached packages:
[1] animint_2016.11.02 ggplot2_2.2.0     

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.3-1 scales_0.4.1     assertthat_0.1  
 [5] lazyeval_0.2.0   plyr_1.8.4       tools_3.3.2      gtable_0.2.0    
 [9] tibble_1.2       Rcpp_0.12.8      grid_3.3.2       munsell_0.4.3

> devtools::session_info()

Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, linux-gnu           
 ui       X11                         
 language en_US:en                    
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2016-12-05                  

Packages -----------------------------------------------------------------------
 package    * version    date       source                         
 animint    * 2016.11.02 2016-11-28 Github (tdhock/animint@c0db9f3)
 assertthat   0.1        2013-12-06 CRAN (R 3.2.0)                 
 colorspace   1.3-1      2016-11-18 CRAN (R 3.3.2)                 
 devtools     1.12.0     2016-06-24 CRAN (R 3.3.2)                 
 digest       0.6.10     2016-08-02 CRAN (R 3.3.1)                 
 ggplot2    * 2.2.0      2016-11-11 CRAN (R 3.3.2)                 
 gtable       0.2.0      2016-02-26 CRAN (R 3.2.3)                 
 labeling     0.3        2014-08-23 CRAN (R 3.1.1)                 
 lazyeval     0.2.0      2016-06-12 CRAN (R 3.3.1)                 
 memoise      1.0.0      2016-01-29 CRAN (R 3.2.3)                 
 munsell      0.4.3      2016-02-13 CRAN (R 3.2.3)                 
 plyr         1.8.4      2016-06-08 CRAN (R 3.3.2)                 
 Rcpp         0.12.8     2016-11-17 CRAN (R 3.3.2)                 
 scales       0.4.1      2016-11-09 CRAN (R 3.3.2)                 
 tibble       1.2        2016-08-26 CRAN (R 3.3.1)                 
 withr        1.0.2      2016-06-20 CRAN (R 3.3.1)       

It looks like it might be related to: #88

@faizan-khan-iit
Copy link
Collaborator

@ndaniel Thanks for the report!

It looks like the problem is because of the ggplot2 version. You are using v2.2.0, while we currently support v2.1.0.

Could you please try out the simple example below and provide the output?

library(animint)
mtcars$cyl <- as.factor(mtcars$cyl)
plot_car <- ggplot()+geom_point(aes(mpg, disp, 
                                      colour=cyl), 
                                  data = mtcars)
animint2dir(list(plot=plot_car), "test_plot")

@faizan-khan-iit
Copy link
Collaborator

@tdhock It looks like the chunk_vars issue is resolved with the ggplot2 v2.2.0. Should we update animint to support this?

@ndaniel
Copy link
Author

ndaniel commented Dec 9, 2016

I tried that it shows this error:

> library(animint)
Loading required package: ggplot2
> mtcars$cyl <- as.factor(mtcars$cyl)
> plot_car <- ggplot()+geom_point(aes(mpg, disp, colour=cyl), data = mtcars)
> animint2dir(list(plot=plot_car), "test_plot")
Error in if (attributes(margin.value)$unit == "pt") { : 
  argument is of length zero

@faizan-khan-iit
Copy link
Collaborator

@ndaniel I upgraded to ggplot2 v2.2.0 on my system and got the same error.

To solve this you could simply install the version 2.1.0. I would recommend installing it from the branch we depend on. You could just run the code below, preferably in a fresh R session:

devtools::install_github("faizan-khan-iit/ggplot2@5fb99d0cece13239bbbc09c6b8a7da7f86ac58e2")
library(animint)
example(animint)

This should solve your issue. Please do report if you have any other problems.

@ndaniel
Copy link
Author

ndaniel commented Dec 9, 2016

Ok. I will do that! Thx!

@dhruvarora93
Copy link

Hi, I am facing the same error when running the example. I changed my ggplot2 version as suggested by you in the comments but now I get this error : Error in as.vector(y) : attempt to apply non-function. Appreciate your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants