using stargazer in R without knowing anything about latex

amit picture amit · Apr 5, 2014 · Viewed 12.4k times · Source

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?

Answer

wake_wake picture wake_wake · Nov 13, 2016

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.