Questions like this one explain how to evaluate a parsed string, but this doesn’t seem to work when a +
is inside the string as an operator for combining layers of a ggplot
.
E.g.
ggplot(data = mtcars) + eval(parse(text = "geom_point(aes(x = cyl, y = disp))"))
works, but this doesn’t:
ggplot(data = mtcars) + eval(parse(text = "geom_point(aes(x = cyl, y = disp)) + theme_bw()"))
Is there another way to evaluate the +
operator in the ggplot
context?