Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using stargazer in R without knowing anything about latex

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?

like image 905
amit Avatar asked Apr 05 '14 07:04

amit


People also ask

How do I run stargazer in R?

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.

How do you make a stargazer table smaller?

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.


1 Answers

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.

like image 198
wake_wake Avatar answered Nov 15 '22 22:11

wake_wake