简体   繁体   English

KnitR,Latex条件显示文本和代码块

[英]KnitR , Latex conditional display of Text and Code block

How do i turn on/off display of perticular subsection based on some condition ? 如何根据某些条件打开/关闭特定部分的显示? for example, i want to display following sub-section only when xyplotFacSpecTotVarTest.pdf exist. 例如,我想仅在xyplotFacSpecTotVarTest.pdf存在时显示以下子部分。

How can i do it ? 我该怎么做 ?

\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}

Put your sub-section in a different file, say, sub.Rnw . 将您的子部分放在另一个文件中,例如sub.Rnw Then include it in your main document conditionally, eg 然后有条件地将它包含在主文档中,例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM