If I understand correctly, what do you mean. You can add a shortcut to your source code snippet and then access it using the ref.label property and prevent it from further execution using eval=FALSE .
For instance:
# Header Bla bla ... ````{r plot1,echo=FALSE} x = rnorm(100,10,5) y = rnorm(100,10,5) plot(x,y) ````
The first piece is executed (without echo) and shows the figure, the second fragment simply echoes the first source of the fragments.
source share