Home > Software design >  Creating tabs automatically in rmarkdown and plotting with purrr
Creating tabs automatically in rmarkdown and plotting with purrr

Time:03-04

I am trying to do something similar to what is posted enter image description here

Could anyone help me with this?

Thanks

CodePudding user response:

Change the imap to iwalk

cat('## Tabs panel {.tabset}   \n')
  iris %>% 
      dplyr::group_split(Species) %>% 
      purrr::iwalk(.,~{
        # create tabset for each group 
        cat('### Tab',.y,'   \n')
        p <- ggplot(.x, aes(x = Sepal.Length, y = Sepal.Width))   geom_point()
        print(p)
        cat('\n')
      })

According to ?walk

walk() returns the input .x (invisibly). This makes it easy to use in pipe.

  • Related