{"id":16471954,"url":"https://github.com/corymccartan/easycensus","last_synced_at":"2025-03-23T11:32:44.397Z","repository":{"id":56934022,"uuid":"450242055","full_name":"CoryMcCartan/easycensus","owner":"CoryMcCartan","description":"Quickly Extract and Marginalize U.S. Census Tables","archived":false,"fork":false,"pushed_at":"2025-02-21T19:23:06.000Z","size":9242,"stargazers_count":15,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-18T20:06:25.615Z","etag":null,"topics":["acs-data","census","census-api","r"],"latest_commit_sha":null,"homepage":"http://corymccartan.com/easycensus/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoryMcCartan.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-20T20:06:47.000Z","updated_at":"2025-02-21T19:21:00.000Z","dependencies_parsed_at":"2024-10-28T16:08:05.052Z","dependency_job_id":"951a4ad2-9b33-4f96-9db7-be9a6bbfca9b","html_url":"https://github.com/CoryMcCartan/easycensus","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Feasycensus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Feasycensus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Feasycensus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Feasycensus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoryMcCartan","download_url":"https://codeload.github.com/CoryMcCartan/easycensus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097158,"owners_count":20560311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acs-data","census","census-api","r"],"created_at":"2024-10-11T12:15:39.874Z","updated_at":"2025-03-23T11:32:44.388Z","avatar_url":"https://github.com/CoryMcCartan.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\nset.seed(5118)\n```\n\n# **easycensus** \u003ca href=\"https://corymccartan.com/easycensus/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/easycensus)](https://CRAN.R-project.org/package=easycensus)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)\n[![R-CMD-check](https://github.com/CoryMcCartan/easycensus/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/CoryMcCartan/easycensus/actions/workflows/R-CMD-check.yaml)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n\u003c!-- badges: end --\u003e\n\nExtracting desired data using the proper Census variable names can be time-consuming.\nThis package takes the pain out of that process.\n\nThe use case is best illustrated by an example.\nSuppose you want age-by-race information at the tract level.\nUnfortunately, the Census Bureau doesn't publish a specific age-by-race table.\nYou could build one yourself from public-use microdata, but that lacks tract-level geographic information, for privacy reasons.\nSo you are left trying to find an existing Census product that you can extract age-by-race information from.\n\nUnless you're a Census pro, you won't know what exactly what is off the top of your head.\nBut 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.\n`easycensus` provides the `cens_find_dec()` function to help you locate exactly which decennial census table to use to get the data you want.\n\n```{r}\nlibrary(easycensus)\n\ncens_find_dec(age, race)\n```\n\nWe 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.\nLet's say you're OK with the five-year bins.\nThen all you need to do to get your data is to call `cens_get_dec()`.\n\n```{r cache=TRUE}\nd_cens = cens_get_dec(\"P12\", \"tract\", state=\"AK\", county=\"Nome\")\nprint(d_cens)\n```\n\nOnce you've gotten your labeled data, it's easy to marginalize out the unneeded `sex` variable.\nYou can either use `group_by()` and `summarize()` as usual, or you can use the `cens_margin_to()` function in `easycensus`.\nThis has the added advantage of automatically handling margins of error for ACS data.\n\n```{r message=F}\nlibrary(dplyr)\n\nd_cens = d_cens %\u003e%\n    # Drop table margins. Can also use `drop_total=TRUE` in `get_dec_table()`\n    filter(age != \"total\", race_ethnicity != \"total\") %\u003e%\n    cens_margin_to(age, race=race_ethnicity)\nprint(d_cens)\n```\n\nFinally, you might want to simplify the age and race labels, since they are kind of verbose.\n`easycensus` provides a set of `tidy_*()` functions to assist with this.\n\n```{r}\nd_cens %\u003e%\n    mutate(race = tidy_race(race),\n           tidy_age_bins(age))\n```\n\nDive into the [reference](https://corymccartan.com/easycensus/reference/) to learn more!\n\n## Installation\n\nYou can install the released version of easycensus from [CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"easycensus\")\n```\n\nOr install the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"CoryMcCartan/easycensus\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorymccartan%2Feasycensus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorymccartan%2Feasycensus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorymccartan%2Feasycensus/lists"}