Hi everyone,
I am writing a shiny app and a part of it allows users to draw plots with with a variety of customized elements. The logic I am designing this plotting function is writing a bunch of if statements go like this,
p = ggplot(data)
if(condition1){
p = p + geom_x
}
if(condition2){
p = p + lable(x)
}
however, there is a problem int his design. Say we are in one if statement where we are asked to adjust the point size of a geom_point plot and the ggplot object generated from the previous if statements is this
p = ggplot(data) + geom_point(...) + geom_text(...)
My tentative solution is
to do
p + aes(size = selected size)
but how do I make sure this aes(size) goes to geom_point instead of geom_text?
This form problem could be further generalized to how can I add an element to geom_x after the geom_x was already added to the plot?
Thank you!