【问题标题】:Output for stargazer in RR中观星者的输出
【发布时间】:2014-03-07 08:20:26
【问题描述】:

我听从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} 
> 

我在 R 窗口中看不到输出表。 我可以在哪里访问表格?

【问题讨论】:

  • 这是 LaTeX 代码。你需要一个解释器将它翻译成更易读的东西,比如 pdf。在 Windows 上,我使用 MikTeX。另一种选择是 Markdown(例如参见 rpubs.com/Thell/xtable)。
  • 看看knitr 也可能是相关的。
  • 你也可以使用 LyX 编辑器。在此处插入一个 Latex 块,粘贴您的文本并编译文档。如果您从未使用过 LaTeX,这可能是最简单的方法。
  • 好的。我得到它。因此对于 html,我将结果复制并粘贴到 txt 文件并另存为 .html 将是相同的。有什么办法可以直接在 R windows 中显示输出?
  • 不。 R 基本上只能渲染纯文本。您可以使用browseURL 函数或调用system 在适当的查看器(例如,Web 浏览器或 PDF 查看器)中打开编译的 knitr 输出。

标签: r matlab stargazer


【解决方案1】:

查看? Stargazer 的帮助文件。如果您想在 R 环境中查看 表并使其易于阅读,请使用 type="text" 参数。

我猜这不是你想要的,你想在文档中使用漂亮的表格。 type="latex" is what you want if your creating asweavedocument andtype="html"` 非常适合 Markdown 文档。

最简单的做法是安装RStudio 应用程序和knitr 包,然后创建一个新的sweavemarkdown 文档。如果您选择sweave,您还需要安装Latex distribution 来呈现文档。

最简单的方法是 RStudio -> 新建 Markdown 文件 -> 将其粘贴到文件中:

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

单击“编织 HTML”按钮并查看您的表格。

享受吧!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-22
    • 2021-12-11
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-19
    相关资源
    最近更新 更多