Evaluating a plus symbol from parsed text as a ggplot2 operator

  Kiến thức lập trình

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?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT