knitr::opts_chunk$set(
    cache = TRUE,
    collapse = TRUE,
    comment = "#>",
    fig.path = "man/figures/README-",
    out.width = "100%"
)

Travis-CI Build Status AppVeyor Build Status

About county.pop

The package stores U.S. annual county-level population estimates (1969-2016) from SEER. The dataset is unbalanced: certain counties do not have population estimates for all the years.

Installation

# install.packages("devtools")
devtools::install_github("jjchern/county.pop@v0.0.4")

# To uninstall the package, use:
# remove.packages("county.pop")

Usage

The package contains four datasets

library(tibble)
county.pop::pop_since_1969

county.pop::pop_since_1969_adjusted

county.pop::pop_since_1990

county.pop::pop_since_1990_adjusted

The population counts are usually based on July 1 populations. The two adjusted versions take into account the changes in population due to hurricanes Katrina and Rita.

All four data sets provide total population counts at the county-year level, as well as population counts by

New and Deleted Counties are Documented Properly

For example, Broomfield County, Colorado (08014) are created on November 15, 2001 (https://www.census.gov/geo/reference/county-changes.html).

library(tidyverse)
county.pop::pop_since_1990 %>% 
    filter(county_fips == "08014") %>% 
    distinct(year)

State-Level Population Can be Aggregated Easily

county.pop::pop_since_1990 %>% 
    group_by(usps, year) %>% 
    summarise(state_pop = sum(pop))

Demographic Shifts

county.pop::pop_since_1969 %>% 
    select(state, year, pop, age_65_85p) %>% 
    group_by(state, year) %>% 
    summarise_all(sum) %>% 
    mutate(sh_age_65p = age_65_85p / pop) %>% 
    left_join(fips::bea_region) %>% 
    ungroup() -> df

df %>% 
    ggplot(aes(x = year, y = state, fill = sh_age_65p)) +
    geom_tile() +
    scale_x_continuous(breaks = seq(1969, 2016, 5)) +
    facet_grid(short_region_name~., 
               scales = "free_y", 
               space = "free_y") +
    viridis::scale_fill_viridis(labels=scales::percent) +
    labs(x = NULL, y = NULL,
         title = "Aging in the United States",
         fill = "Ages 65+") +
    theme_bw() +
    theme(strip.text = element_text(size = 9)) +
    theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = .5))


jjchern/county.pop documentation built on May 24, 2019, 5:06 a.m.