Thoughts on Using Flexdashboard

[This article was first published on r on Tony ElHabr, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I’ve experimented with the {flexdashboard} package for a couple of things after first trying out not so long ago. In particular, I found the storyboard format to be my favorite. I used it to create the storyboard that I wrote about in a previous post about tracking the activity of NBA team Twitter accounts.

I also used {flexdashboard} for a presentation that I gave at my company’s data science group.

Recently, I’ve been experimenting with the storyboard {flexdashboard} format for visualizing the weekly NFL picks that my brother and I do.

The Alternatives

In all, I have found {flexdashboard}s to be an extremely effective format. It functions as a good compromise among a number of different alternatives.

  • A “standard” document knitted from a .Rmd file (e.g. HTML, Markdown, Word, or PDF). In my opinion, the main advantage of {flexdashboard} compared to the traditional .Rmd-knitr-Rmarkdown workflow is the ease with which shiny apps and other interactive formats (e.g. htmlwidgets can be integrated. 1

  • A presentation knitted from a .Rmd file (i.e. a beamer_presentation, ioslides_presentation, slidy_presentation, or a revealjs::revealjs_presentation). Compared to these formats, I have found that modifying the default styling of the base CSS is much simpler with the themes in the {flexdashboard} package.

  • A “standard” R presentation (with the .Rpres extension). I must admit that I don’t have much experience with the .Rpres format–I prefer Rmarkdown and the capability that it offers to create different kinds of output from a single “base” file.

  • A shinydashboard (created with the shinydashboard package). In comparison to shinydashboards, I like the “light-weight” framework offered by {flexdashboard}. While shinydashboard is certainly a better option for developing a complex dashboard (perhaps for a business purpose), this is not typically my use case.

Some Other Opinions

Here’s a couple of my other thoughts and tips for using {flexdashboard}:

  • Adding JavaScript functionality is straightforward.

For example, I have used the following snippet of code to add functionality for a “toggle” button to show/hide code.

  $(".toggle").click(function() {
  • Customizing the colors and styles (with .css) is also simple.

When modifying a theme’s CSS, the typical/recommended approach is to use the browser’s “Inspect” tool (or some browser extension such as Selector Gadget to identify which specific styles to adjust.

For example, if the theme that is chosen for the {flexdashboard} (in particular, the storyboard format) uses the same styling for code and its output, the following CSS code can be used to distinguish the two.

pre.sourceCode.r {
  background-color: #ffffff;

To add to this technique, because the CSS files in the {flexdashboard} package, it’s not too difficult to simply pick out the file for the theme that is being used (see the resources/ folder in the package’s GitHub repo) and quickly identify what to modify.


As if I need to re-iterate it again, I would highly recommend trying out the {flexdashboard} package. If anything, you’ll learn that you don’t like it.

  1. These can also be be embedded into .html files knitted from a .Rmdfile, but I think that it’s more natural in the {flexdashboard} context. Also, I believe that the HTML format is the only standard .Rmd output format that has interactive capability, so other output formats cannot be used if opting for the knitr-Rmarkdown combo. ^

To leave a comment for the author, please follow the link and comment on their blog: r on Tony ElHabr. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)