Check out example codes for "rmarkdown section title as variable ##". It will help you in understanding the concepts better.

Code Example 1

```{r, results="asis", echo = FALSE}
i = 1
cat("## Subject", i, "\n")
plot(i)
i = 2
cat("\n\n## Subject", i, "\n")
plot(i)
```

Learn ReactJs, React Native from akashmittal.com