简体   繁体   中英

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.

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 . Then include it in your main document conditionally, eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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