我将此代码包含在 .Rnw 文件中:
\documentclass[a4paper,11pt]{article}
\usepackage{lipsum} % Required to insert dummy text
\begin{document}
\title{}
\date{\today}
\maketitle
\section{Header}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<<model_terms, results = "asis", echo = F>>=
library(stargazer); library(knitr)
df <- data.frame(terms = "predictor1 | predictor2")
stargazer(df, summary = F)
@
\end{document}
如果我library(knitr); knit()
在这个文件上运行,我会以 PDF 格式输出:
注意管道之前的空间,而不是之后的空间。如何在管道后插入空格。所以输出应该是这样的:
predictor1 | predictor2