Performance of large Rmd document

Hello. I have a RMarkdown flex-dashboard document that is nearly 20MB in size. It has 7 tabs (business category) that is made up of several grid and subplots. Unfortunately, clicking between the tabs (the first time) takes upwards of 10-15 seconds to render.

A two part question:

  1. Is it possible to cache the plots (plotly objects) so they render faster? I believe this is most the bottleneck.
  2. Is it possible to break the documents up and link the separate documents together to lessen the overall size.

I have heard that I might be able to accomplish #2 with child documents, but have not found much information on this,

Thank you,

I think you would need to go to a shiny app approach (with or without using flexdashboard) and yes you'll be able to cache plot

Yes you can still use static website (no server processing, so no shiny app), but separate you big dashboard in several file in order for them to load not all at once (like now I suppose) but only when the page is click on. You could generate several html file (using parametrized dashboard or other mechanism), then have an index.html page, (which could be a flexdashboard) that linked to all these page. The load in the browser would be less.

Also, have you thought about deactivating the self_contained = TRUE option in flexdashboard ? with this activated, everything is encoded to be put inside one html. Using FALSE, you will have a html file AND a folder with ressource. This would lead to smaller html, loading from files what is required. It could improve the response by the browser.

Hope it helps.

Thank you for the reply. I truly appreciate it. These are actually options that I have thought of. To this:

  1. If I do cache, how can I expire the cache at the end of the day? I have been unable to determine how to do so, possibly based on max(date) column on a dataframe being changed....?

  2. If I break the document up, would this be considered "child documents" or just documents linked on the index.Rmd page? I have heard a little about child documents, but have found little info on what they are and how to do it.

Regarding the self_contained setting. Is it correct that this setting is specific to HTML documents; output of HTML in YAML? Our Rmd is a FlexDashboard.

Thanks again for your inputs.

If you develop your website as a shiny application, you will have a server with R running code, and you can invalidate with any mechanism you want I think. There is already a function to cache plot

I am not sure if you mean that, but child document is sometime used with R markdown about the code source to be in several document. One main Rmd and some child, to be merged together at rendering time. For html static website, this is not the same. I would break the site in several html and link that using html code and js in a main page. There is also the rmarkdown website option

Flexdashboard also have a self_contained option. They are based on the same kind of document as html_document. It is the template and them that changes. There is a self_contained argument. You can also insert shiny app element

Look also at this documentation to get details

1 Like

This topic was automatically closed 21 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.