Is it possible to reference a previously defined object in a knitr
Rnw chunk figure caption?
<<chunk1>>=
myObj <- "caption"
@
<<chunk2, fig.cap="This is my \\Sexpr{myObj}">>=
plot(1,2)
@
This SO answer shows how to use LaTeX in a figure caption, but I can't get the same idea to work with \Sexpr{}
and an R object.
@MrFlick offered a simple solution:
fig.cap=paste("This is my", myObj)
Documenting here to close the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With