31 July 2018

Presenting Exploratory Analyses

Sharing an exploratory analysis as a series of R commands and their outputs, like below, can give lengthy and untidy results.

str(iris)
'data.frame':   150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...

… and so on.

Interactive Exploratory Analysis with Shiny

Alternatively, an exploratory analysis can be packaged in an interactive Shiny app. This brings some key advantages:

  • Greater flexibility due to interactive options and dynamic outputs
  • Intuitive and easy to understand, even without knowledge of R
  • App format allows for convenient organisation with tabs and menus

App Features

An example exploratory analysis, packaged as a Shiny app, can be accessed here.

  • Tab 1: Data Overview
    • Shows a table of up to 100 observations from the dataset. The user can select how many observations to display and which variable to order the dataset by.
  • Tab 2: Exploratory Graphs
    • Allows the user to create a variety of exploratory graphs, including scatter plots, box plots and histograms
    • Users can select which variables to show on the axes and whether to show further variables using color or faceting, and tune graphical options

App Features (cont.)

  • Tab 3: Linear Regression
    • Allows the user to fit linear regression models to the data, selecting which variable to model as the outcome and which variables to use as predictors
    • Model coefficients, goodness of fit (adjusted R-Squared) and diagnostic plots are dynamically displayed