I'm about to teach an R course for social scientists. They are likely to know nothing about LaTeX, and reluctant to hear about it (R is complex enough for them). Yet, they are likely to love the sort of tables that the stargazer package creates to represent their models.
Is there any wrapper or other simple procedure that will enable them to use stargazer to directly create a pdf of the table (or other format) that they can then insert into their word documents as an image?
This can be done by typing “install. packages(“stargazer”)”, and then “library(stargazer)” in the next line. Installing Stargazer will only need to be done once, but the second command, which loads the package will need to be typed each session you wish to use it.
To adjust table size with stargazer, you can change the font size font. size= , make the Stargazer single row single. row = TRUE and change the space between columns column.
The stargazer
package has an out
argument in which you can specify the path to which the output can be saved.
If you specify type="html"
and a valid path as the out
argument, you don't have to use the KNIT option that is mentioned by Mikko.
Thus, you can simply do:
X = data.frame(a = 1:10, b = 21:30)
mod <- lm(a ~ b, X)
library(stargazer)
stargazer(mod, type = "html", out="C://Your//Path//Name.html")
Open this html
file within MS Word
and you are good to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With