flexdashboard icon indicating copy to clipboard operation
flexdashboard copied to clipboard

Scroll multiple graphs in one R chunk

Open anastasiamiliopoulou opened this issue 7 years ago • 3 comments

I am trying to create a flexdashboard with one tab including multiple graphs (~50). What i get as an output is showing only some graphs and not all. The functionality of scroll is deactivated. I have tried to change the vertical layout = scroll but this does not work either. This seem to be related to the fact that all graphs are written in one chunk as produced by an in-chunk loop. Any ideas? Thanks

anastasiamiliopoulou avatar Jan 16 '18 20:01 anastasiamiliopoulou

Can you separate each graph into its own chunk? You can achieve that with the knit_child() function to knit child documents inside the parent Rmd. See here: https://yihui.name/knitr/demo/child/

bborgesr avatar Jan 16 '18 21:01 bborgesr

Thanks @bborgesr But the problem here is that number of graphs is unknown as it varies each time and that's why they're produced in a loop.

anastasiamiliopoulou avatar Jan 17 '18 09:01 anastasiamiliopoulou

I see, you need to be able to create the chunks programmatically. I think these other resources will help you achieve that:

  1. https://stackoverflow.com/a/14368148/6174455
  2. http://rstudio-pubs-static.s3.amazonaws.com/1283_a009514e3eb24680b1ba0d4d291c2546.html
  3. https://github.com/yihui/knitr/blob/master/vignettes/knit_expand.Rmd

Good luck!

bborgesr avatar Jan 17 '18 17:01 bborgesr