DDP: US state 1974 per capita income levels explained by your variable of choice

Andrea Vallebueno
March 12, 2019

Overview

This Shiny App has been developed to enable the user to interact with US state-level data. Specifically, the user may select a variable from a list to explain variations in GDP per capita across states. In response to the user's selection, the Shiny App prints a linear model relating the two variables (GDP per capita and the user's selection as the regressor) and a plot of both variables, including the fitted line from the linear model.

Data

The data used in the Shiny App is the R dataset state.x77, which includes the following variables:

  • Population levels as of 1975
  • GDP per capita (1974)
  • Illiteracy as of 1970 as a percent of the population
  • life expectancy in years (1969-71)
  • Murder and non-negligent manslaughter rate per 100,000 population (1976)
  • Percentage of high-school graduates (1970)
  • Mean number of days with minimum temperature below freezing in capital or large city (1931-60)
  • Land area in square miles

Data overview

Below is a glimpse of the dataset used in the app.

data <- state.x77
  data <- as.data.frame(data)
  names(data)<- c("Population", "Income", "Illiteracy", "Life.Expectancy", "Murder.rate", "High.school.graduates", "Frost", "Area")
  head(data, 3)
        Population Income Illiteracy Life.Expectancy Murder.rate
Alabama       3615   3624        2.1           69.05        15.1
Alaska         365   6315        1.5           69.31        11.3
Arizona       2212   4530        1.8           70.55         7.8
        High.school.graduates Frost   Area
Alabama                  41.3    20  50708
Alaska                   66.7   152 566432
Arizona                  58.1    15 113417

Shiny App Example

Below is an example of the output produced by the Shiny App stemming from the selection of Life Expectancy as the regressor. Note that linear model output has been cut for formatting purposes.

plot of chunk unnamed-chunk-2






lm(formula = Income ~ Life.Expectancy, data = data)
    (Intercept) Life.Expectancy 
     -6603.4829        155.7492