Learn R Programming

censable

censable wraps censusapi for common requests, with memoized data functions. With a growing redistricting universe in R, it seems right to partition out some use cases, to allow imports to be more targeted and to stop packages from repeating each other.

Installation

You can install the released version of censable from CRAN with:

install.packages("censable")

You can download the development version from GitHub with:

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

Example

library(censable)

The primary data functions are build_dec and build_acs

de <- build_dec(geography = 'county', state = 'DE')

The build_* functions take arguments on geography and state, at a minimum. If you’re looking at a smaller piece of a state, you can use county to subset it. Year defaults to 2010, but will be updated to 2020 around October 2021, following the API release of the 2020 Census data.

The build_* functions are a convenient wrapper around censusapi, with an eye towards collecting data on total population and voting age population by race. Total population variables begin with the prefix pop, while voting age population variables begin with the prefix vap.

Additionally, there are memoised versions of the build_* functions:

de <- mem_build_dec(geography = 'county', state = 'DE')

These speed up repeated calls, allowing you to have code that is self contained and reproducible, without taking the time hit of having to re-download the data each time.

Copy Link

Version

Install

install.packages('censable')

Monthly Downloads

321

Version

0.0.5

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Christopher T. Kenny

Last Published

November 19th, 2022

Functions in censable (0.0.5)

build_dec

Build Data from the Decennial Census
breakdown_geoid

Breakdown Census GEOID into Components
add_r_environ

Add Entry to Renviron
collapse4

Collapse Full Race Categories into 4 Categories
collapse5_pop

Collapse Population Race Categories into 5 Categories
collapse5

Collapse Full Race Categories into 5 Categories
build_acs

Build Data from the Decennial Census
collapse4_pop

Collapse Population Race Categories into 4 Categories
collapse4_vap

Collapse Voting Age Population Race Categories into 4 Categories
collapse5_vap

Collapse Voting Age Population Race Categories into 5 Categories
fips_2000

Counties FIPS 2000
join_abb_name

Join Abb by Name
fips_2010

Counties FIPS 2010
join_ansi_abb

Join ANSI by Abb
join_abb_fips

Join Abb by FIPS
join_abb_ansi

Join Abb by ANSI
construct_geoid

Create GEOID from Default Columns
fips_2020

Counties FIPS 2020
join_ansi_fips

Join ANSI by FIPS
custom_geoid

Create a GEOID from Columns
join_name_abb

Join Name by Abb
join_fips_abb

Join FIPS by Abb
join_ansi_name

Join ANSI by Name
match_abb

Try to Match to State Abbreviation
join_name_fips

Join Name by FIPS
join_name_ansi

Join Name by ANSI
key

Check or Get Census API Key
%>%

Pipe operator
mt_county

Montana County Data
match_fips

Try to Match to State FIPS
match_name

Try to Match to State Name
join_fips_name

Join FIPS by Name
recode_abb_ansi

Recode Abb by ANSI
join_fips_ansi

Join FIPS by ANSI
recode_ansi_name

Recode ANSI by Name
recode_ansi_fips

Recode ANSI by FIPS
match_ansi

Try to Match to State ANSI
recode_name_abb

Recode Name by Abb
recode_fips_name

Recode FIPS by Name
recode_abb_fips

Recode Abb by FIPS
recode_name_fips

Recode Name by FIPS
recode_name_ansi

Recode Name by ANSI
tidyeval

Tidy eval helpers
stata

stata (State Data)
recode_fips_abb

Recode FIPS by Abb
recode_ansi_abb

Recode ANSI by Abb
recode_abb_name

Recode Abb by Name
recode_fips_ansi

Recode FIPS by ANSI