Refers to a previously defined object in the header of the picture "knitr` Rnw"

Is it possible to refer to a previously defined object in the picture header of knitr Rnw?

 <<chunk1>>= myObj <- "caption" @ <<chunk2, fig.cap="This is my \\Sexpr{myObj}">>= plot(1,2) @ 

This "SO" answer shows how to use LaTeX in the title of the picture, but I can't get the same idea to work with \Sexpr{} and the R object.

+5
source share
1 answer

@MrFlick offers a simple solution:

 fig.cap=paste("This is my", myObj) 

Documentation is here to close the question.

+1
source

Source: https://habr.com/ru/post/1238545/


All Articles