防止打印 LaTeX 注释

Prevent LaTeX comments from printing

我在 RMarkdown 文件中包含 psych 包的因子分析结果。因子加载 table 使用 fa2latex()psychTools 包中打印。 R 代码如下所示:

facm <- fa(corrmat, n.factors = 3, rotate = "varimax", fm = "wls")
fa2latex(facm, font.size = "small", caption = "Mandatory Measure Factor Analysis", heading = "Factor Loadings")

代码块选项是echo = FALSE, results = "asis"

这会生成部分如下所示的 LaTeX 代码:

% Called in the psych package  fa2latex % Called in the psych package  facm % Called in the psych package  small % Called in the psych package  Factor Loadings % Called in the psych package  Mandatory Measure Factor Analysis 
\begin{table}[htpb]\caption{Mandatory Measure Factor Analysis}
...

由此产生的 pdf 文件如下所示:

% Called in the psych package fa2latex % Called in the psych package facm % Called in the psych package small % Called in the psych package Factor Loadings % Called in the psych package Mandatory Measure Factor Analysis Table 1: Mandatory Measure Factor Analysis

我不想弄乱 psychTools 包中的代码,但我不想打印注释。关于如何实现这一点有什么想法吗?

设置silent = TRUE然后传给cat().

```{r echo = FALSE, results = 'asis'}
cat(fa2latex(facm,
             font.size = "small",
             caption = "Mandatory Measure Factor Analysis",
             heading = "Factor Loadings",
             silent = TRUE))
```

例子