Given a loaded USRDS dataset and the corresponding file key (e.g., "PATIENTS", "RXHIST"), this function uses internal metadata to convert numerically coded variables to factors using value mappings from Appendix C of the USRDS Researcher's Guide.
Arguments
- df
A data frame loaded from a USRDS file.
- file_key
Character. The canonical file key (e.g., "PATIENTS").
- verbose
Logical. If TRUE, print each variable being labeled.
Details
Variable formats are looked up from Appendix B. Only variables with formats beginning with a dollar sign (e.g., $REMCD.) and present in the dataset will be converted.
Examples
if (FALSE) {
df <- load_usrds_file("PATIENTS", factor_labels = TRUE)
}
