ggvis
ggvis copied to clipboard
layer_smooths not working with size property
When trying to add layer_smooths/layer_model_predictions to a plot where size is set an error occurs.
library(ggvis)
library(dplyr)
df <- as_data_frame(list(x = c(1:3),
y = c(1:3),
z = c(1:3)))
# works
df %>%
ggvis(~x, ~y) %>%
layer_points()
# works
df %>%
ggvis(~x, ~y) %>%
layer_points() %>%
layer_model_predictions(model = "lm")
# works
df %>%
ggvis(~x, ~y, size = ~z) %>%
layer_points()
# doesn't work
df %>%
ggvis(~x, ~y, size = ~z) %>%
layer_points() %>%
layer_model_predictions(model = "lm")
Error in eval(expr, envir, enclos) : Object 'z' not found
I can't speak for why it doesn't work, but layer_model_predictions() doesn't support the size property. What you can do is this:
df %>%
ggvis(~x, ~y) %>%
layer_model_predictions(model = "lm") %>%
layer_points(size = ~z)