Reputation: 10578
I want to combine ggplot and manipulate like this:
library(ggplot2);library(manipulate)
manipulate(
ggplot(diamonds, aes(x = type, y = price)) +
geom_point(alpha = 1/10) +
geom_smooth(method = lm)
type = picker("carat","depth","table")
)
(where the manipulate function will change the x inputs with picker
)
But I am getting an Error: unexpected ')' in ")"
EDIT 1: fixed the syntax error (see: ({
... )},
)
manipulate({
ggplot(diamonds, aes(x = type, y = price)) +
geom_point(alpha = 1/10) +
geom_smooth(method = lm)},
type = picker("carat","depth","table")
)
Now I'm getting Don't know how to automatically pick scale for object of type manipulator.picker. Defaulting to continuous Error: Aesthetics must either be length one, or the same length as the dataProblems:type
Upvotes: 1
Views: 317
Reputation: 1392
Since the picker returns "carat"
instead of carat
, you should be using aes_string
, rather than aes
.
manipulate(
ggplot(diamonds, aes_string(x = type, y = "price")) +
geom_point(alpha = 1/10) +
geom_smooth(method = lm),
type = picker("carat","depth","table")
)
Upvotes: 2