17/07/2020

A Shiny Application

What does the app do?

  • Allows you to visualise the population and life expectancy of US states in using the US State Facts and Figures dataset.

  • You can use sliders to select a population and life expectancy range to display and checkboxes to show different regions

  • The output is an interactive map of the US showing the states that satisfy the selected criteria.

Under the hood

  • A data frame called states was created using the vectors from the US Facts and Figures Dataset.

  • A fourth column (hover) was added for the interactivity of the map.

head(states)
           state.name   pop  lexp state.region                          hover
Alabama       Alabama  3615 69.05        South     Alabama : 3615 69.05 years
Alaska         Alaska   365 69.31         West       Alaska : 365 69.31 years
Arizona       Arizona  2212 70.55         West     Arizona : 2212 70.55 years
Arkansas     Arkansas  2110 70.66        South    Arkansas : 2110 70.66 years
California California 21198 71.71         West California : 21198 71.71 years
Colorado     Colorado  2541 72.06         West    Colorado : 2541 72.06 years

Output

  • The slider values and checkbox values are used to filter the dataset using the state.name and state.region columns before creating the map.

  • The output is a googlevis interactive map.

  • The states turn green when they satisfy the selected criteria (slider and checkboxes)

  • When each green state is hovered over, the name and area of the state is displayed.