say I want to plot two layers in ggplot, one containing points and another one containing lines if a certain criteria is fulfilled.
The code without the criteria cou
What you are seeing is a syntax error. The most robust way I can think of is:
tmp.data<-c(1,2,3) if(tmp.data[1]!="no value") { p = p + geom_point() } p + geom_line()
So you compose the object p in a sequence, only adding geom_point() when the if statements yields TRUE.
p
geom_point()
TRUE