This is a way to use R code outside the chunks in the markdown text
```{r setup, include=FALSE}
library(ggplot2)
```
# This is a title in markdown
```{r echo=FALSE}
figureNr = 1
ggplot(iris, aes(x = Petal.Length, y = Sepal.Length)) +
geom_point() +
labs(title = "This is the title in ggplot",
caption = paste("Figure", figureNr, " - caption created within ggplot")) +
theme(plot.title = element_text(hjust = 0.5, face = "bold"),
plot.caption = element_text(hjust = 0, colour = "blue"))
```
Figure `r figureNr` - caption created in markdown with variables from R
By using the back ticks and starting with r, you can then call the value of a variable to markdown like this: `r ...` or as in the example: `r figureNr` to display the value of the variable figureNr
Does this help?
PJ
