Given:
library(ggplot2)
l <- list(1:6)
for(i in 1:6){
l[[i]] <- ggplot(data=data.frame(x=1:10, y=1:10)) +
geom_point(aes(x=x, y=y)) +
ggtitle(i)
}
ml <- marrangeGrob(l, nrow=3, ncol=2)
ml
I get the plots ordered by column, that is:
1 4
2 5
3 6
but I want them arranged by row:
1 2
3 4
5 6
I've tried with byrow=TRUE, but it has no effect. How could I arrange the plots by row?
As already suggested in the comments you can specify the order via the
layout_matrix=argument, i.e. use thebyrow = TRUEargument ofmatrix().Note: I switched to
lapplyto create thelistof charts.