Is there a way to use a structure like
grid.arrange(
ifelse(somecondition,graph1,graph2),
ifelse(somecondition2,graph3,graph4),
ncol=2
)
where graphX
is either a plot (created with ggplot2
) or a grob defined previously. It looks like ifelse
evaluates the grob
object to something else (a dataframe ?) before printing so grid.arrange
doesn't get the right input to work properly.
I also tried to store all the graph objects in a collection and use that within grid.arrange
but coudn't get a proper data structure to work nicely.