knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", dpi = 150 )
The original goal of cwi
was to get data, primarily the Census ACS, fetched, aggregated, and analyzed for DataHaven's 2019 Community Index reports. It's now evolved to support more of our day-to-day work—and now we're on the 2022 reports! This includes functions to speed up and standardize analysis for multiple staff people, preview trends and patterns we'll need to write about, and get data in more layperson-friendly formats.
It pairs well with many functions from Camille's brilliantly-named camiller
package.
You can install this package from GitHub with:
# install.packages("devtools") devtools::install_github("CT-Data-Haven/cwi")
This package relies heavily on:
tidyverse
packages, namely dplyr
, tidyr
, purrr
, stringr
, forcats
, and ggplot2
(version >= 3.0.0) (so a lot the tidyverse)rlang
and tidyselect
for non-standard evaluation in many functionstidycensus
for actually getting all the Census datasf
isn't required but it's encouragedcwi
ships with several datasets and shapefiles. These include:
sf
objects) of towns, tracts, and city neighborhoods for New Haven, Hartford, Bridgeport, and StamfordThis package contains functions to make it easier and more reproducible to fetch and analyze data from:
Here's an example of getting a big table to calculate homeownership rates across many geographies at once:
library(dplyr) library(cwi)
tenure <- multi_geo_acs( table = basic_table_nums$tenure, year = 2020, regions = regions[c("Greater New Haven", "New Haven Inner Ring", "New Haven Outer Ring")], counties = "New Haven", towns = regions[["Greater New Haven"]], us = TRUE ) tenure
homeownership <- tenure |> label_acs(year = 2020) |> dplyr::group_by(level, name) |> camiller::calc_shares(group = label, denom = "Total") |> dplyr::filter(stringr::str_detect(label, "Owner")) |> dplyr::select(level, name, share) homeownership
geo_level_plot(homeownership, value = share, hilite = "#EA7FA2", title = "Homeownership in Greater New Haven, 2020")
See more detail in the vignette: vignette("basic-workflow")
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.