I have created this plot for a report in Rmarkdown
pot<-ggarrange(
tablas_pais(1)[[4]],
tablas_pais(2)[[4]],
tablas_pais(3)[[4]],
tablas_pais(4)[[4]],
tablas_pais(5)[[4]],
tablas_pais(6)[[4]],
tablas_pais(7)[[4]],
tablas_pais(8)[[4]],
tablas_pais(9)[[4]],ncol=3,nrow=3,legend="bottom",common.legend = TRUE
)
annotate_figure(pot, top = text_grob("Difference in Differences results by country and gender ",
color = "black",face= "bold", size = 20))
Notice that tablas_pais is a list with plots.... basically each tablas_pais(9)[[i]] has a plot created with ggplot.
I got the next output plot:
However, I dont like how this plot looks. I would like to create to plots. First a plot with only 4 plots and then other with space for 6 plots. But in the first row 3 plots and in the second only the 2 remaining plots.
I was trying doing the next:
gridExtra::grid.arrange(
tablas_pais(5)[[4]],
tablas_pais(6)[[4]],
tablas_pais(7)[[4]],
grid::nullGrob()
tablas_pais(8)[[4]],
grid::nullGrob()
tablas_pais(9)[[4]], grid::nullGrob(),
layout_matrix = matrix(c(1,2,3,4,5,6,7,8), byrow = TRUE, ncol = 4))
But it does not work.