Learn R Programming

ppmf

The goal of ppmf is to convert Census Privacy Protected Microdata Files into somewhat wider data aggregated to a geographic level.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("christopherkenny/ppmf")

Basics

Load the package:

library(ppmf)

Download and read data with:

path <- download_ppmf(dsn = 'filename.csv', dir = 'some/directory', version = '19')
al <- read_ppmf(state = 'AL', path = path)

Version ‘19’ reflects the 19.61 finalized parameters used again for the 2020 Census.

For future use, I recommend storing the path to the data for future sessions using:

add_pmmf19_path(path)

Then the path can be recovered with:

path19 <- Sys.getenv('ppmf19')

Once you’ve read in what you want, you can aggregate it to the right level:

al <- al %>% add_geoid()
blocks <- agg(al)

And aggregated data can use the GEOID to merge with shapefiles:

library(dplyr) # to clean up the data

shp <- tigris::blocks('AL', year = 2010) %>% 
  select(GEOID10, geometry) %>% rename(GEOID = GEOID10)
shp <- shp %>% left_join(blocks, by = 'GEOID')

# always clean shp!
shp[is.na(shp)] <- 0

For users with the newest package version, there is an added dependency on censable, which allows for an easier workflow. If you’ve used the add_pmmf*_path() workflow suggested, you don’t even need to supply the paths!

This will not just read the ppmf data, it will merge it with 2010 Census populations (by major race/ethnicity grouping) and add the corresponding geometries.

al <- read_merge_ppmf('AL', level = 'block', versions = '19')

Copy Link

Version

Install

install.packages('ppmf')

Monthly Downloads

581

Version

0.1.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Christopher T. Kenny

Last Published

December 15th, 2021

Functions in ppmf (0.1.3)

add_geoid

Add Standard GEOID to PPMF Data
agg

Aggregate PPMF Data
overwrite_hisp_race

Overwrite Races with Hispanic
breakdown_geoid

Breakdown GEOID into Components
states

State Rows
replace_race

Replace Race Categories
races

Race Classifications
ppmf_ex

Example PPMF Data
read_ppmf

Read in PPMF Data
read_merge_ppmf

Read PPMF data and Merge with Census 2010 Data
%>%

Pipe operator
get_ppmf_links

Get PPMF File Links
add_ppmf4_path

Add ppmf4 path to Renviron
download_ppmf

Download PPMF Files
add_ppmf19_path

Add ppmf19 path to Renviron
add_ppmf12_path

Add ppmf12 path to Renviron