I included resize.height=0.5,resize.width=0.5
in the code chunk, but still can't resize the table generated by stargazer. Can anyone tell me why?
My code chunk options look like this:
echo=FALSE,warning=FALSE,results='asis',resize.height=0.5,resize.width=0.5}
The stargazer codes are like this:
stargazer(did.student,student.control.kmt,student.control.neu,student.control.dpp,header = FALSE,
title="DD Model",
covariate.labels = c("Treatment","group","Treatment*group"),
dep.var.labels = "attitude",
column.labels = c("","party1","Independent","party2"),
label = "DiD-students")
Would appreciate any help!
-- Forgot to mention - I'm using beamer with the table.
This comment on GitHub inspired me to implement
\resizebox{}
intostargazer()
. You can useresizebox.stargazer()
to specify the size of the table outputted fromstargazer()
withtab.width
and/ortab.height
arguments. To activate the function, you need to run the following code first:You can specify the table size by e.g.
resizebox.stargazer(..., tab.width = "0.7\\textwidth")
. Note that you have to write the TeX commands from\\
instead of\
.Here is an alternative to Carlos' solution that writes the output to a LaTeX file:
This post also provided some help: https://stackoverflow.com/a/36018251/2289444
I kind of solve the problem myself:
To adjust table size with stargazer, you can change the font size
font.size=
, make the Stargazer single rowsingle.row = TRUE
and change the space between columnscolumn.sep.width = "1pt"
instargazer()
.Though the link here suggests using
print(stargazer(),scalebox='0.7')
, it doesn't work for me perhaps because I'm using Markdown with Beamer, but I'm not sure. Would still love to have more contribution on this.I was hoping for a more straightforward answer, but this works!