November 18, 2016

Project Overview

The Swiss dataset, one of the base R datasets, contains standardized fertility measure and socio-economic indicators for each of 47 French-speaking provinces of Switzerland at about 1888. This project required the development of a Shiny application that includes the use of reactive programming. Reactive programming is the concept of performing server calculations based on user inputs. In this application, two different linear models are executed. The predictions made from those models can be dynamically changed using input sliders to adjust the values of various exploratory variables. Regression lines overlaid on the plot show the data trends. Finally, the results of those calculations are displayed graphically and textually to the user. The subsequent slides explore the application in greater detail.

Tour of the Shiny App

The Shiny application has three major components:

  • Side panel with sliders: Here the user can adjust the values of the various exploratory values available in the dataset. Also, the display of the regression lines can be suppressed using checkboxes. Clicking the Generate Models button produces predicted values from the models.
  • Plot area: Here the raw Fertility rates are plotted. Trend lines showing the direction of the two models are displayed and can be suppressed as described above. The changing values of the Fertility prediction, based on the values selected on the slider, are show relative to the raw Fertility data.
  • Results of Linear Model calculations: Here the predictions, made based on the Linear Models, are displayed, and they adjust dynamically when values selected from the input sliders are altered.

Linear Models used

Predict Fertility using Agriculture Exploratory Variable

model.1$call
## lm(formula = Fertility ~ Agriculture, data = swiss)

Predict Fertility excluding Agriculture Exploratory Variable

model.2$call
## lm(formula = Fertility ~ . - Agriculture, data = swiss)

Full code available at github.

Sample Plot