我正在运行逻辑回归模型,并尝试在RMarkdown中使用stargazer打印输出。我在设置中应用了dcolumn,但是当我尝试将文档编织为pdf时,仍然出现“ !LaTeX错误:数组arg。中的非法字符”。我试图只复制LateX代码,但是它也说我有一个非法字符。有人可以帮我找到非法字符吗?
RMarkdown文件:
title: "Tables and Figures"
author: "me"
date: "November 2019"
header_includes: - \usepackage{dcolumn}
output: pdf_documentclassoption: landscape
```
{r Regression results Q21 1, results='asis', echo=FALSE}
Q21e_teaching99 <- glm(Q21e_teaching ~ Country + Field + typeposition + Gender + Age, data =
SurveyPHEC, family = binomial(link = "probit"))
stargazer(Q21e_teaching99, type="latex", align = TRUE)
```
由此产生的LatexCode:
length of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be
changedlength of NULL cannot be changedlength of NULL cannot be changed
% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at
fas.harvard.edu
% Date and time: man., des 02, 2019 - 14.33.50
% Requires LaTeX packages: dcolumn
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} }
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multicolumn{1}{c}{\textit{Dependent variable:}} \\
\cline{2-2}
\\[-1.8ex] & \multicolumn{1}{c}{Q21e\_teaching} \\
\hline \\[-1.8ex]
CountryNorway & -0.255 \\
& (0.184) \\
& \\
CountryUnited Kingdom & 0.046 \\
& (0.195) \\
& \\
CountryNetherlands & 0.322^{**} \\
& (0.149) \\
& \\
CountryDenmark & 0.171 \\
& (0.165) \\
& \\
FieldPhysics & -0.109 \\
& (0.124) \\
& \\
typepositionSenior & 0.912^{***} \\
& (0.119) \\
& \\
GenderMale & 0.002 \\
& (0.150) \\
& \\
Age40 to 49 years & 0.283 \\
& (0.179) \\
& \\
Age50 to 59 years & 0.329^{*} \\
& (0.185) \\
& \\
Age60 years and more & 0.610^{***} \\
& (0.192) \\
& \\
Constant & -1.548^{***} \\
& (0.217) \\
& \\
\hline \\[-1.8ex]
Observations & \multicolumn{1}{c}{788} \\
Log Likelihood & \multicolumn{1}{c}{-326.114} \\
Akaike Inf. Crit. & \multicolumn{1}{c}{674.227} \\
\hline
\hline \\[-1.8ex]
\textit{Note:} & \multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{table}
length of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be
changedlength
of NULL cannot be changedlength of NULL cannot be changed
R Markdown输出
! LaTeX错误:数组arg中的字符非法。
错误表明未加载dcolumn
程序包。未加载的原因是yaml标头中存在多个语法错误。
以下标头应加载程序包(注意添加的换行符:
---
title: "Tables and Figures"
author: "me"
date: "November 2019"
output:
pdf_document:
keep_tex: true
header-includes:
- \usepackage{dcolumn}
classoption: landscape
---