knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

Rcbpp

R-CMD-check Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Overview

R utilities to streamline CBPP research, including functions for generating commonly used variables, creating paths to files in the SharePoint datasets library, and computing basic weighted statistics. Rcbpp also includes data that frequently come in handy, including state FIPS codes (along with corresponding state names and postal abbreviations) and calendar year averages of the CPI-U-RS.

Installation

To install Rcbpp, run the following code:

# install.packages("devtools")
devtools::install_github("CenterOnBudget/Rcbpp")

Example

library(Rcbpp)
library(tidyverse)

mar21 <- read_csv(
  file = sp_cps_asec(2021, f = "csv"),
  col_select = c(marsupwt, a_age, spm_resources, spm_povthreshold)
)

mar21 |>
  make_age_group_var("cps_asec") |>
  mutate(
    pop = TRUE, 
    b100 = spm_resources < spm_povthreshold
  ) |>
  group_by(age_group) |>
  summarize(
    across(c(pop, b100), \(x) wt_sum(x, wt = marsupwt)), 
    .groups = "drop"
  ) |>
  mutate(
    across(c(pop, b100), round), 
    pov_rate = b100 / pop
  )

with(mar21, wt_quantile(a_age, wt = marsupwt, n = 10))


CenterOnBudget/Rcbpp documentation built on Jan. 6, 2025, 9:32 p.m.