I want to use tikz to implement basic graphics in an automated report created by Sweave. Therefore, I created an R function, returning the tikz command, based on the data. My code looks similar to this:
<<echo=FALSE>>=
y <- 20
code <- cat(paste("\\draw (0pt, ",y,"pt) circle (5pt)", sep=""))
@
\begin{tikzpicture}
\Sexpr{code}
\end{tikzpicture}
Which does not work ... I get the string instead of the drawing.
Don't use
\Sexpr
, just put the chunk in thetikzpicture
environment, and add the chunk optionresults=tex
. For example,This isn't tested, so you may need to tweak it a little.