state_stats: State-level data

Description Usage Format Source Examples

Description

Information about each state collected from both the official US Census website and from various other sources.

Usage

1

Format

A data frame with 51 observations on the following 23 variables.

state

State name.

abbr

State abbreviation (e.g. "MN").

fips

FIPS code.

pop2010

Population in 2010.

pop2000

Population in 2000.

homeownership

Homeownership rate.

multiunit

Percent of living units that are in multi-unit structures.

income

Average income per capita.

med_income

Median household income.

poverty

Poverty rate.

fed_spend

Federal spending per capita.

land_area

Land area.

smoke

Percent of population that smokes.

murder

Murders per 100,000 people.

robbery

Robberies per 100,000.

agg_assault

Aggravated assaults per 100,000.

larceny

Larcenies per 100,000.

motor_theft

Vehicle theft per 100,000.

soc_sec

Percent of individuals collecting social security.

nuclear

Percent of power coming from nuclear sources.

coal

Percent of power coming from coal sources.

tr_deaths

Traffic deaths per 100,000.

tr_deaths_no_alc

Traffic deaths per 100,000 where alcohol was not a factor.

unempl

Unemployment rate (February 2012, preliminary).

Source

Please note that we have not validated the Infochimps data. The other data were collected directly from the corresponding websites.

US Census website (pop2010, pop2000, homeownership, multiunits, income, med_income, poverty, fed_spend, land_area), http://quickfacts.census.gov/qfd/index.html

Infochimps (murder, robbery, agg_assault, larcent, motor_theft, soc_sec, coal, nuclear), http://www.infochimps.com (see linked pages and corresponding downloadable data sets for original source information)

National Highway Traffic Safety Administration (tr_deaths, tr_deaths_no_alc), http://www-fars.nhtsa.dot.gov

Bureau of Labor Statistics (unempl), http://www.bls.gov/web/laus/laumstrk.htm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
library(ggplot2)
library(dplyr)

states_selected <- state_stats %>%
  mutate(region = tolower(state)) %>%
  select(region, unempl, murder, nuclear)

states_map <- map_data("state") %>%
  inner_join(states_selected)

# Unemployment map
ggplot(states_map, aes(map_id = region)) +
  geom_map(aes(fill = unempl), map = states_map) +
  expand_limits(x = states_map$long, y = states_map$lat) +
  scale_fill_viridis_c() +
  labs(x = "", y = "", fill = "Unemployment\n(%)")

# Murder rate map
states_map %>%
  filter(region != "district of columbia") %>%
  ggplot(aes(map_id = region)) +
  geom_map(aes(fill = murder), map = states_map) +
  expand_limits(x = states_map$long, y = states_map$lat) +
  scale_fill_viridis_c() +
  labs(x = "", y = "", fill = "Murders\nper 100k")

# Nuclear energy map
ggplot(states_map, aes(map_id = region)) +
  geom_map(aes(fill = nuclear), map = states_map) +
  expand_limits(x = states_map$long, y = states_map$lat) +
  scale_fill_viridis_c() +
  labs(x = "", y = "", fill = "Nuclear energy\n(%)")

OpenIntroStat/openintro-r-package documentation built on Jan. 22, 2020, 3:23 p.m.