as_table_brfss | R Documentation |
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.
as_table_brfss(ph.data)
ph.data |
A |
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
.
Returns a survey-weighted dtsurvey
/data.table object
containing the first imputed dataset from the input imputationList.
as_imputed_brfss
for converting back to an imputationList
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.