as_table_brfss: Convert BRFSS imputationList to a single data.table

View source: R/utilities.R

as_table_brfssR Documentation

Convert BRFSS imputationList to a single data.table

Description

Converts a BRFSS imputationList to a single dtsurvey/data.table by extracting the first imputed dataset. This is useful when you need to modify variables in BRFSS data that contains HRA or region variables.

Usage

as_table_brfss(ph.data)

Arguments

ph.data

A imputationList containing BRFSS survey data

Details

When working with BRFSS data that includes Health Reporting Area (HRA) or region variables, the data is stored as an imputationList to account for ZIP codes that cross HRA boundaries. However, if you need to modify variables in your dataset, you must first convert to a single data.table, make your modifications, then convert back to an imputationList using as_imputed_brfss.

Value

Returns a survey-weighted dtsurvey/data.table object containing the first imputed dataset from the input imputationList.

See Also

as_imputed_brfss for converting back to an imputationList

Examples

## Not run: 
# Get BRFSS data with HRA variables (returns an imputationList)
brfss <- get_data_brfss(
  cols = c("age", "hra20_id"),
  year = 2019:2023
)

# Convert to single table for modification
brfss_table <- as_table_brfss(brfss)

# Now you can modify variables
brfss_table[, age_category := fcase(
  age %in% 18:66, "working age",
  age >= 67, "retirement age",
  default = NA_character_
)]

## End(Not run)


PHSKC-APDE/rads documentation built on April 14, 2025, 10:47 a.m.