简体   繁体   中英

Output for stargazer in R

I follow the instruction of this article

> library(stargazer)
> stargazer(attitude)

% Table created by stargazer v.5.0 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Fri, Mar 07, 2014 - 4:12:55 PM
\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
Statistic & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Max} \\ 
rating & 30 & 64.633 & 12.173 & 40 & 85 \\ 
complaints & 30 & 66.600 & 13.315 & 37 & 90 \\ 
privileges & 30 & 53.133 & 12.235 & 30 & 83 \\ 
learning & 30 & 56.367 & 11.737 & 34 & 75 \\ 
raises & 30 & 64.633 & 10.397 & 43 & 88 \\ 
critical & 30 & 74.767 & 9.895 & 49 & 92 \\ 
advance & 30 & 42.933 & 10.289 & 25 & 72 \\ 
\hline \\[-1.8ex] 
\end{tabular} 
\end{table} 
> 

I cannot see the output table in R windows. Where I can access the table?

Check the help file for ? Stargazer ? Stargazer . If you want to view the table in the R environment and have it be plainly readable use the type="text" argument.

My guess is that isn't the desire and you'd like to make use of the pretty table in a document. The type="latex" is what you want if your creating a sweave document and type="html"` works nicely for markdown documents.

The simplest thing to do is install the RStudio application and the knitr package, then create a new sweave or markdown document. If you choose sweave you'll also need a Latex distribution installed to render the document.

The easiest route is RStudio -> New Markdown File -> paste this into the file:

```{r, results='asis'}
require(stargazer)
stargazer(attitude, type="html")
```

The click the 'Knit HTML' button and look at your table.

Enjoy!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM