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.
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")
::install_github("christopherkenny/censable") devtools
library(censable)
The primary data functions are build_dec
and
build_acs
<- build_dec(geography = 'county', state = 'DE') 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:
<- mem_build_dec(geography = 'county', state = 'DE') 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.