Overview (First Page)

Column 1

Welcome back to PHW251B! Today we’re covering dashboards with RMarkdown and flexdashboard. The layout of this module is a bit different than what we’re normally used to, because this is a ready-to-knit dashboard! I recommend working through each step of the code to see what it does and then under Knit select “Knit to flex_dashboard”.

This example is based on the assigned chapter from the Epidemiologist R Handbook, which can be found here: https://epirhandbook.com/en/dashboards-with-r-markdown.html

Note the different arguments in lines 1-8 at the top of this RMD, which specify that the output when you knit this document will be a flex_dashboard organized in columns. In a flexdashboard RMD, the hashes (#) we have previously used to create HTML headers now dictate different parts of the dashboard:

# Creates a new page

## Creates a column or a row (columns/rows are determined by line 6!) These can take an additional argument for width, as seen in this document.

### Creates a subsection within that column or row

Hospital Location

The line above will create a subsection within the first column. Now we just need to decide what to put in it. In keeping with our recent weeks on GIS, let’s put a map!

Column 2

Epidemic curve by age

This line above creates the first subsection within the second column. Let’s put a chart here:

Cases by Hospital

Here is another subsection for the second column! We can add whatever content we desire for our dashboard: in this case, a table summarizing the number of cases by hospital.

Hospital Cases
Port Hospital 1762
Missing 1469
Military Hospital 896
Other 885
Central Hospital 454
St. Mark’s Maternity Hospital (SMMH) 422

Data Explorer (Second Page)

The line above adds a second page under a new tab! Let’s visualize the dataset as an interactive table for viewers to explore:

 

And that’s the end of this module – in essence, it’s just a new way to organize and use an RMD to output a different product. And there are many more customizations and additional arguments that can further enhance your dashboard product, so be sure to take a look at the assigned chapter to learn about the possibilities! The final step is to click “Knit to flex_dashboard”. This will give you an HTML document that you can share with others.