https://github.com/corymccartan/easycensus
Quickly Extract and Marginalize U.S. Census Tables
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.8%) to scientific vocabulary
Keywords
acs-data
census
census-api
r
Last synced: 5 months ago
·
JSON representation
Repository
Quickly Extract and Marginalize U.S. Census Tables
Basic Info
- Host: GitHub
- Owner: CoryMcCartan
- License: other
- Language: R
- Default Branch: main
- Homepage: http://corymccartan.com/easycensus/
- Size: 8.81 MB
Statistics
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 3
- Releases: 0
Topics
acs-data
census
census-api
r
Created about 4 years ago
· Last pushed 12 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
set.seed(5118)
```
# **easycensus**
[](https://CRAN.R-project.org/package=easycensus)
[](https://opensource.org/license/mit)
[](https://github.com/CoryMcCartan/easycensus/actions/workflows/R-CMD-check.yaml)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
Extracting desired data using the proper Census variable names can be time-consuming.
This package takes the pain out of that process.
The use case is best illustrated by an example.
Suppose you want age-by-race information at the tract level.
Unfortunately, the Census Bureau doesn't publish a specific age-by-race table.
You could build one yourself from public-use microdata, but that lacks tract-level geographic information, for privacy reasons.
So you are left trying to find an existing Census product that you can extract age-by-race information from.
Unless you're a Census pro, you won't know what exactly what is off the top of your head.
But suppose you know you'd like to get the data from the decennial census, since it covers the whole nation and asks about age and race.
`easycensus` provides the `cens_find_dec()` function to help you locate exactly which decennial census table to use to get the data you want.
```{r}
library(easycensus)
cens_find_dec(age, race)
```
We can see right away that our best bet is either table `P12` or table `PCT12`, depending on whether we want age in 5-year groups or down to individual years.
Let's say you're OK with the five-year bins.
Then all you need to do to get your data is to call `cens_get_dec()`.
```{r cache=TRUE}
d_cens = cens_get_dec("P12", "tract", state="AK", county="Nome")
print(d_cens)
```
Once you've gotten your labeled data, it's easy to marginalize out the unneeded `sex` variable.
You can either use `group_by()` and `summarize()` as usual, or you can use the `cens_margin_to()` function in `easycensus`.
This has the added advantage of automatically handling margins of error for ACS data.
```{r message=F}
library(dplyr)
d_cens = d_cens %>%
# Drop table margins. Can also use `drop_total=TRUE` in `get_dec_table()`
filter(age != "total", race_ethnicity != "total") %>%
cens_margin_to(age, race=race_ethnicity)
print(d_cens)
```
Finally, you might want to simplify the age and race labels, since they are kind of verbose.
`easycensus` provides a set of `tidy_*()` functions to assist with this.
```{r}
d_cens %>%
mutate(race = tidy_race(race),
tidy_age_bins(age))
```
Dive into the [reference](https://corymccartan.com/easycensus/reference/) to learn more!
## Installation
You can install the released version of easycensus from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("easycensus")
```
Or install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("CoryMcCartan/easycensus")
```
Owner
- Name: Cory McCartan
- Login: CoryMcCartan
- Kind: user
- Company: New York University
- Website: corymccartan.com
- Twitter: CoryMcCartan
- Repositories: 55
- Profile: https://github.com/CoryMcCartan
Faculty Fellow at NYU's Center for Data Science, working on computational social science problems and open-source R software.
GitHub Events
Total
- Watch event: 1
- Push event: 4
Last Year
- Watch event: 1
- Push event: 4
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 4
- Total pull requests: 0
- Average time to close issues: 9 minutes
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 0.75
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 3
- Pull requests: 0
- Average time to close issues: 9 minutes
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 0.67
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- kuriwaki (3)
- CoryMcCartan (1)
Pull Request Authors
Top Labels
Issue Labels
enhancement (1)
bug (1)
Pull Request Labels
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- censusapi * imports
- cli * imports
- dplyr >= 1.0.0 imports
- pillar * imports
- rlang * imports
- stringr * imports
- tidycensus * imports
- tidyr >= 1.0.0 imports
- vctrs * imports
- posterior * suggests
- sf * suggests
- testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite