r - KnitR,Text 和 Code block 的 Latex 条件显示

标签 r latex knitr pdflatex

如何根据某些条件打开/关闭特定小节的显示?
例如,我只想在 xyplotFacSpecTotVarTest.pdf 时显示以下子部分存在。

我该怎么做 ?

\subsection{Checksum: Factor, Specific, and Total Variance}
Perhaps the most basic test of a regression model is if the factor and specific variances sum to equal the total variance.  Here, we 
present this diagnostic as an xy-plot, with the sum of factor and specific variance on the x-axis and the total variance on the y-axis.  We 
expect the plotted points to line up tightly along the identity line.

\clearpage
\begin{figure}[!h]

\centering

\includegraphics{\Sexpr{image_dir}xyplotFacSpecTotVarTest.pdf}

\caption{Total Variance vs. Sum of Factor and Specific Variance, All Instruments Passing Exposure Model.}

\end{figure}

最佳答案

将您的子部分放在不同的文件中,例如 sub.Rnw .然后有条件地将其包含在您的主文档中,例如

<<child = if (file.exists('foo.pdf')) 'sub.Rnw'>>=
@

关于r - KnitR,Text 和 Code block 的 Latex 条件显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23437854/

相关文章:

r - R是编译语言吗?

r - 使用data.table按组抽样而不重复

r - 使用 Shiny 模拟实时数据可视化

latex - eqnarray中的多行大括号

r - 无法使用 knitr2html 使用 kable/kableExtra 获得漂亮的 table

r - 使用 knititations 在 RMarkdown 文档中包含引用书目

latex - 在 Latex 中对齐数学方程

emacs - 使用包 authblk 在 Orgmode 中自定义多个作者隶属关系以进行 latex 导出

r - 针织品的剩余物

r - katexR 未在 rmarkdown 中渲染