当我编译latex而不是我的stargazer生成的表格时,出现了一个空白的地方。

问题描述 投票:0回答:1

我想从r中打印一个stargazer生成的表格到我的latex文档中。我创建了名为table_1.tex的表格,并把它和我的latex文件放在同一个目录下。首先我创建了一个简单的数据集来重现我的数据。

vector <- rep(0,72)
for (i in 1:72) {
  vector[i] <- rnorm(1)
}
matrix <- matrix(vector, nrow= 9)
data <- as.data.frame(matrix)

table_1 <- stargazer(data,
                     align=TRUE,
                     title = "Table 1: Main Results",
                     type = "text", 
                     out.header = TRUE,
                     column.labels = c("Modelo", "Modelo", "Modelo","Modelo", "Modelo", "Modelo",
                                       "Modelo", "Modelo", "Modelo"),
                     dep.var.labels=c("log(PIB)","log(PIB)"), 
                     covariate.labels = c("log(DT t)", "Gini t", "log(DT t) * Gini t", "log(DT t-1)",
                                          "Gini t-1", "log(DT t) * Gini t-1", "log(DT t-1) * Gini t-1",
                                          "Mortinf t", "log(Prod t)", "Abertura t", "log(Pop t)"),
                     notes = c("All models were estimated by the fixed effects estimator. The errors are robust to heteroscedasticity and", 
                               "autocovariance. Numbers between parenthesis are the standard-deviations of the coefficients. * represents",
                               "significante at 10\\%, ** at 5\\% and *** at 1\\%."),
                     no.space= TRUE,
                     style = "AER",
                     notes.append = FALSE,
                     notes.align = "l",
                     out = "table_1_1.tex")

然后我试着把它导入到latex中。

\documentclass[11pt]{article}

\usepackage{fullpage}
\usepackage{graphicx}

\begin{document}

blabla

\include{table_1_1.tex}

\end{document}


然而,当我编译这段代码时,它只输出 "blabla "而不是我的表格。取而代之的是,在它应该存在的地方有一个很大的空白。我想这可能是因为我在stargazer中加入了用葡萄牙语写的注释。事实上,当我试图单独打开Stargazer表格文件时,它说我应该把编码从UTF-8改为ISO-8859-9。我已经在配置中修改了,但代码仍然不能输出表格。我也是乳胶的新手,如果我的错误是愚蠢的,请原谅。

r latex stargazer
1个回答
1
投票

如果你看一下stargazer导出的表格,你会发现它的开头为

\documentclass{article}
\usepackage{dcolumn}

\begin{document}

因为你是将表导入到一个文档中,所以你不需要这样做。你可以设置 out.header = F (也可以不填,因为F是默认值),然后加载Stargazer中的 dcolumn 包的主文档中。

另外,我认为导入表格的更好的方法是

\input{table_1_1.tex}

更多信息请看这里。

https:/www.rdocumentation.orgpackagesstargazerversions5.2.2topicsstargazerhttps:/tex.stackexchange.comquestions246when-should I-use-input-vs-include

完整的答案。

观星者

table_1 <- stargazer(data,
                     align=TRUE,
                     title = "Table 1: Main Results",
                     type = "text", 
                     column.labels = c("Modelo", "Modelo", "Modelo","Modelo", "Modelo", "Modelo",
                                       "Modelo", "Modelo", "Modelo"),
                     dep.var.labels=c("log(PIB)","log(PIB)"), 
                     covariate.labels = c("log(DT t)", "Gini t", "log(DT t) * Gini t", "log(DT t-1)",
                                          "Gini t-1", "log(DT t) * Gini t-1", "log(DT t-1) * Gini t-1",
                                          "Mortinf t", "log(Prod t)", "Abertura t", "log(Pop t)"),
                     notes = c("All models were estimated by the fixed effects estimator. The errors are robust to heteroscedasticity and", 
                               "autocovariance. Numbers between parenthesis are the standard-deviations of the coefficients. * represents",
                               "significante at 10\\%, ** at 5\\% and *** at 1\\%."),
                     no.space= TRUE,
                     style = "AER",
                     notes.append = FALSE,
                     notes.align = "l",
                     out = "table_1_1.tex")

乳胶。

\documentclass[11pt]{article}

\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{dcolumn}

\begin{document}

blabla

\input{table_1_1.tex}

\end{document}
© www.soinside.com 2019 - 2024. All rights reserved.