Miguel Ángel Daza
April 9, 2019
Note: The content of this presentation has been obtained from the websites R Markdown from RStudio , Flexdashboard for R and R Markdown: The Definitive Guide.
Dashboards are a useful way to communicate large amounts of information visually and quickly. Create one with the flexdashboard::flex_dashboard output format, as in the .Rmd file.
Flexdashboard makes easy to organize your content into a visual layout:
Use R Markdown to publish a group of related data visualizations as a dashboard.
Support for a wide variety of components including html widgets; base, lattice, and grid graphics; tabular data; gauges and value boxes; and text annotations.
Flexible and easy to specify row and column-based layouts. Components are intelligently re-sized to fill the browser and adapted for display on mobile devices.
Storyboard layouts for presenting sequences of visualizations and related comments.
Optionally use Shiny to drive visualizations dynamically.
There are many examples of layouts in Flexdashboard for R.
Many of them must be added to the Rmarkdown yaml-header.
One could set the design:
- in rows orientation: rows,
- or in columns orientation: columns.
Furthermore, you can decide if you want: - to fit the content in a page, - or to use scrolling websites vertical_layout: scroll.
Other possibility is to create a storyboard storyboard: true.
For Shiny features, runtime: shiny must be added. Then, we can include a sidebar by Sidebar {.sidebar}: - global at the level of the page, - or local at the level of the row or column.
Also, it is possible to create tabs: - in rows, when define a new one, Row {.tabset .tabset-fade}, - in columns, when define a new one, Column {.tabset}.
Note: All of this examples has been obtained from the website Flexdasboard for R.
If you add the next R code, a value box is displayed.
### Primary
NumsWifi = 10
valueBox(NumsWifi, icon = "fa-wifi", color="primary")
There are five colors that correspond to the text:
- blue -> primary,
- violet -> info,
- gray -> success,
- orange -> warning,
- Red -> danger.
The next code produces a gauge (Shiny is needed, runtime: shiny).
### Contact Rate
gauge(91, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
There are three colors that correspond to the text:
- green -> success,
- orange -> warning,
- Red -> danger.
Note: All of this examples has been obtained using data file LogFile_corrected.csv
Using Shiny with flexdashboard turns a static R Markdown report into an Interactive Document.
It is important to note that interactive documents need to be deployed to a Shiny Server to be shared broadly (whereas static R Markdown documents are standalone web pages that can be attached to emails or served from any standard web server).
Note that the shinydashboard package provides another way to create dashboards with Shiny.
The steps required to add Shiny components to a flexdashboard are as follows:
Add runtime: shiny to the options declared at the top of the document (YAML front matter).
Add the {.sidebar} attribute to the first column of the dashboard to make it a host for Shiny input controls (note this step is not strictly required, but many Shiny based dashboards will demand).
Add Shiny inputs and outputs as appropriate.
When including plots, be sure to wrap them in a call to renderPlot. This is important not only for dynamically responding to changes but also to ensure that they are automatically re-sized when their container changes.
You can use some of these render functions:
renderDataTable({ })
renderGauge({ })
renderImage({ })
renderPlot({ })
renderPlotly({ })
renderPrint({ })
renderSankeyNetwork({ })
renderTable({ })
renderText({ })
renderUI({ })
renderValueBox({ })
Note: All of this examples has been obtained using the data file LogFile_corrected.csv