rstudio / ggvis

Interactive grammar of graphics for R
Other
713 stars 171 forks source link

layer_histograms not working w/o a stack = FALSE argument #470

Closed edgararuiz-zz closed 6 years ago

edgararuiz-zz commented 7 years ago

Hi, I've tried the following in two different computers with today's devel version:

mtcars %>% ggvis(~mpg) %>% layer_histograms()

This is the response:

Error in eval(expr, envir, enclos) : object 'xmin_' not found

But works if I pass stack = FALSE :

mtcars %>% ggvis(~mpg) %>% layer_histograms(stack = FALSE)

From looking at the code in layer_bins.R, it seems that by equating x to compute_stack, the original compute_bin data is lost, causing the columns called by props to be dropped:

    if (stack) {
      x <- compute_stack(x, stack_var = ~count_, group_var = ~x_)

      rect_props <- merge_props(
        new_props,
        props(x = ~xmin_, x2 = ~xmax_, y = ~stack_upr_, y2 = ~stack_lwr_)
      )
      x <- emit_rects(x, rect_props)

    } else ...
duttashi commented 7 years ago

@edgararuiz this code, mtcars %>% ggvis(~mpg) %>% layer_histograms() works for me. My sessioninfo() is given below. Try updating the R version and let us know if the error persists. cheers.

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

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

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

other attached packages:
[1] bindrcpp_0.2 ggvis_0.4.3