ggvis layer_boxplots() doesn't work with fill which is not x

23 Views Asked by At

I'm trying to generate boxplots of Group and have the fill by another factor Species but it doesn't work. I'm getting a object not found error.

I'm working with iris, added a random group factor to it:

iris$Group <- as.factor(sample(c("A", "B", "C"), nrow(iris), replace = T))

Then plot it with ggviz:

iris %>% ggvis(~Group , ~Sepal.Width, fill= ~Species) %>% layer_points()

Which works as expected and produces this plot: enter image description here

But when I try to generate boxplots I get an error:

iris %>% ggvis(~Group , ~Sepal.Width, fill= ~Species) %>% layer_boxplots()

Error in eval(value(x$value), envir = data, enclos = x$env) : 
  object 'Species' not found

When I change x to Species it works as expected:

iris %>% ggvis(~Species , ~Sepal.Width, fill= ~Species) %>% layer_boxplots()

Produces enter image description here Any idea why? I guess ggvis philosophy is different than ggplot2 but I couldn't figure out how.

Thank you.

0

There are 0 best solutions below