0

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?

llrs
  • 3,308
  • 35
  • 68
useR
  • 3,062
  • 10
  • 51
  • 66
  • 3
    This is LaTeX code. You'll need an interpreter to translate it into something more readable, like a pdf. On windows, I use MikTeX. Another option is Markdown (see for example http://rpubs.com/Thell/xtable). – Roman Luštrik Mar 07 '14 at 08:24
  • A look at [**`knitr`**](http://yihui.name/knitr/) may also be relevant. – Henrik Mar 07 '14 at 08:44
  • You could also use LyX editor. Insert a Latex block there, paste your text and compile the document. If you've never used LaTeX this would probably be the easiest way. – Maxim.K Mar 07 '14 at 08:50
  • okay. i get it. so it will the same for html that i copy and paste the result to txt file and save as .html. Is there any way that the output directly shown in R windows? – useR Mar 07 '14 at 08:55
  • Nope. R can basically only render plain text. You can use the `browseURL` function or calls to `system` to open compiled knitr output in an appropriate viewer (e.g., web browser or PDF viewer). – Thomas Mar 07 '14 at 09:11
  • Many thanks for all the gentle help! – useR Mar 07 '14 at 09:12

1 Answers1

0

Check the help file for ? 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 asweavedocument andtype="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!

Thell
  • 5,883
  • 31
  • 55