cwi

check-release pkgdown Codecov test coverage

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.

Installation

You can install this package from GitHub with:

# install.packages("devtools")
devtools::install_github("CT-Data-Haven/cwi")

Dependencies

This package relies heavily on:

Data

cwi ships with several datasets and shapefiles. These include:

Sources

This package contains functions to make it easier and more reproducible to fetch and analyze data from:

Example

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").



CT-Data-Haven/cwi documentation built on July 1, 2024, 7:45 a.m.