I have a master document
\documentclass{article}
\begin{document}
<<main>>=
a <- 20
b <- 30
@
<<child-demo, child='child.Rnw', eval=TRUE>>=
@
\end{document}
and a corresponding child document
<<set-parent, echo=FALSE, cache=FALSE>>=
set_parent('mwe.Rnw')
@
<<child-code>>=
a + b
@
When processing the file, I get the following output
a <- 20
b <- 30
## NULL
a + b
## [1] 50
Using \Sexpr{set_parent('mwe.Rnw')}
does not produce the ugly ##NULL
in the output, but I would prefer declaring the parent via a chunk, as I try to only use \Sexpr{}
outside of chunks