Once painstakingly collected, data is most value when actionable steps are taken from it. Methods of safely distributing and communicating results from data are not all created equally. Dashboards are a safe and effective way to communicate results from data.
We’ll walk through an example of how to create a dashboard in R using flexdashboard, an R framework for creating dashboards with R and Markdown.
For this example we’ll grab data from Google Analytics and use it to make 3 charts on a dashboard.
- A histogram
- A time series chart
- Sortable table
To get this all to work, we’ll need to wrap our code in a flexdashboard template. You can find out how to do that here. We’ll use the row template to get our charts displaying well on the page and allow for vertical scrolling.
For chart 1 we’ll use DT, a data table library to create a searchable and sortable table for our dashboard. I used data from the in-market segment in Google Analytics. Plotting the chart with default stylings is easy:
Chart 2 will be our histogram. The code for creating a histogram in Highcharter is very simple as well:
This should plot a histogram of traffic to my website from May 2015 through May 2016. This chart is also zoomable, which is a nice feature to get for free.
Chart 3 is a time series chart. I will also use Highcharter for this as well:
This gives us visits by time over the same range.
From here you can click “Knit” in Rstudio and it will compile this markdown document into HTML. You will have a working, interactive and responsive dashboard. I’ve published a working version to rPubs for reference here.