I am trying to combine different graphs created by the fixest package.
library("fixest")
library("ggpubr")
data(base_did)
base_inter = base_did
est_did = feols(y ~ x1 + i(period, treat, 5) | id+period, base_inter)
pl1 <- iplot(est_did)
pl2 <- coefplot(est_did)
plot_list <- list(pl1, pl2)
combined_plot <- ggarrange(plotlist = plot_list, ncol = 2)
But I'm getting :
"Warning messages:
1: In as_grob.default(plot) :
Cannot convert object of class list into a grob.
2: In as_grob.default(plot) :
Cannot convert object of class list into a grob.
I tried converting the output from iplot() and coefplot() before passing them to ggarrange. I used as.grob() but it returned an empty object.
Anyone know how to combine those graphs please ?
Edit: The best way I've found for now is to use par, but I cannot save the graphs for later use.
par(mfrow = c(2, 2))
iplot(est_did)
coefplot(est_did)
iplot(est_did)
coefplot(est_did)
par(mfrow = c(1, 1))
I tried saving the graphs with :
iplot(est_did)
pl1 <- recordPlot()
coefplot(est_did)
pl2 <- recordPlot()
par(mfrow = c(2, 2))
replayPlot(pl1)
replayPlot(pl2)
replayPlot(pl1)
replayPlot(pl2)
par(mfrow = c(1, 1))
But when I display them, they just are just 1 graph at a time, ignoring the par command (probably because the graph was created before the par command actually came in).