Ing*_*ert 2 pdf latex r-markdown stargazer
我正在运行逻辑回归模型,并尝试在 RMarkdown 中使用 stargazer 打印输出。我已经在我的设置中应用了 dcolumn,但当我尝试将文档编织成 pdf 时,我仍然收到“ !LaTeX 错误:数组参数中的非法字符。 ”。我试图复制 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)
```
Run Code Online (Sandbox Code Playgroud)
这产生的 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
Run Code Online (Sandbox Code Playgroud)
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
---
Run Code Online (Sandbox Code Playgroud)