purrr headings with rmarkdown

Hi, is there a way to generate headings using purrr in rmarkdown documents?

For example with this code in a chunk:


cats <- unique(iris$Species) %>% 

plots <- function(cat){
  ggplot(iris %>% filter(Species == cat),
              aes(Sepal.Length, Sepal.Width)) +

purrr::map(cats, ~plots(.x))

But with markdown headings in between e.g. (# setosa) - something like this:

I thought I remembered seeing a function in either purrr or rmarkdown that would do something like this, but I can't find it. Any ideas?

This is what I was after: 14.7 Use knitr::knit_expand() to generate Rmd source | R Markdown Cookbook


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.