I try to create a multi-panel table using stargazer
and starpolishr
. The first panel table is a summary statistics table, and the second panel table is a regression table. Here is an example of the code I used –
# Summary Table for Panel 1
star.out = mtcars %>%
stargazer(type = 'latex',
summary.stat = c(
'n',
'mean',
'sd',
'p25',
'median',
'p75'
),
digits = 3,
label = "tab:overallsummary",
title = "Summary Statistics of Variables",
single.row = TRUE,
no.space = TRUE,
font.size = "scriptsize",
column.sep.width = "5pt",
header = FALSE,
notes.align = "l",
covariate.labels = c (
'MPG',
'CYL',
'DISP',
'HP',
'DRAT',
'WT',
'QSEC',
'VS',
'AM',
'GEAR',
'CARB'
)
)
# Regressions for panel 2
reg1 <- lm(mpg ~ cyl + disp, data = mtcars)
reg2 <- lm(cyl ~ cyl + disp, data = mtcars)
reg3 <- lm(mpg ~ hp + drat, data = mtcars)
reg4 <- lm(cyl ~ hp + drat, data = mtcars)
reg5 <- lm(disp ~ hp + qsec, data = mtcars)
# Panels 1 amd 2 Output
panel1 <- stargazer::stargazer(
star.out,
float = TRUE,
header = FALSE,
model.numbers = FALSE,
omit.table.layout = "n",
multicolumn = FALSE,
#dep.var.caption = "",
type = "latex",
align = TRUE,
digits = 3,
df = FALSE,
digits.extra = 3
#,nobs = TRUE
#,omit.stat = c("rsq", "adj.rsq", "ser")
)
# Panel 2 output
panel2 <-
stargazer::stargazer(
reg1, reg2, reg3, reg4, reg5,
float = TRUE,
header = FALSE,
model.numbers = FALSE,
omit.table.layout = "n",
multicolumn = FALSE,
dep.var.caption = "",
type = "latex",
align = TRUE,
digits = 3,
df = FALSE,
digits.extra = 3,
nobs = TRUE,
omit.stat = c("rsq", "adj.rsq", "ser")
)
But When I run the following in an Rmarkdown PDF, the table is not generated; it just shows some latex words. Do you have any idea how I can solve this issue? I created multi-panel table, with each panel containing regression table, but I am not able to create a table in which both panels do not contain the regression tables. I tried to follow this link – Multi-panel regression tables in R, but have not been able to solve the issue.
#### Final Output in Rmarkdown PDF
starpolishr::star_panel(
panel1,
panel2,
panel.names = c(
"Summary Statistics",
"Regression Results"
),
panel.label.fontface = "bold",
same.summary.stats = FALSE,
same.lhs.vars = FALSE ) %>%
star_notes_tex(
note.type = "threeparttable",
note = c("blah blah")
) %>%
cat