当我编译 latex 而不是我的 stargazer 生成的 table 时出现空白 space

A blank space is appearing when I compile latex instead of my stargazer generated table

我想将 r 生成的 table 观星者打印到我的乳胶文档中。我创建了名为 table_1.tex 的 table 并将其放在与我的乳胶文件相同的目录中。 首先,我创建了一个简单的数据集来重现我的数据:

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")

然后我尝试在乳胶中导入它:

\documentclass[11pt]{article}

\usepackage{fullpage}
\usepackage{graphicx}

\begin{document}

blabla

\include{table_1_1.tex}

\end{document}


然而,当我编译这段代码时,它只输出 "blabla" 而不是我的 table。相反,它应该在的地方有一个很大的空白 space。我想这可能是因为我在 stargazer 中加入了用葡萄牙语写的笔记。实际上,当我尝试单独打开 stargazer table 文件时,它说我应该将编码从 UTF-8 更改为 ISO-8859-9。我已经在配置中更改了它,但是代码仍然没有输出 table。 我也是乳胶的新手,如果我的错误很愚蠢,请原谅。 提前致谢!

如果您查看 stargazer 导出的 table,您会发现它以

开头
\documentclass{article}
\usepackage{dcolumn}

\begin{document}

当您将 table 导入文档时,您不需要它。您可以在 stargazer 中设置 out.header = F(或者不选择该选项,因为 F 是默认设置),然后在主文档中加载 dcolumn 包。

此外,我认为导入 tables 的更好方法是

\input{table_1_1.tex}

查看此处了解更多信息:

https://www.rdocumentation.org/packages/stargazer/versions/5.2.2/topics/stargazer https://tex.stackexchange.com/questions/246/when-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}