Last chance! 50% off unlimited learning
Sale ends in
Returns code translations for categorical variables, which appear in most NHANES tables.
nhanesTranslate(
nh_table,
colnames = NULL,
data = NULL,
nchar = 32,
mincategories = 2,
details = FALSE,
dxa = FALSE
)
The name of the NHANES table to retrieve.
The names of the columns to translate.
If a data frame is passed, then code translation will be applied directly to the data frame. In that case the return argument is the code-translated data frame.
Applies only when data is defined. Code translations can be very long. Truncate the length by setting nchar (default = 32).
The minimum number of categories needed for code translations to be applied to the data (default=2).
If TRUE then all available table translation information is displayed (default=FALSE).
If TRUE then the 2005-2006 DXA translation table will be used (default=FALSE).
The code translation table (or translated data frame when data is defined).
Code translation tables are retrieved via webscraping using rvest. Many of the NHANES data tables have encoded values. E.g. 1 = 'Male', 2 = 'Female'. Thus it is often helpful to view the code translations and perhaps insert the translated values in a data frame. Note that Hmisc supports "labelled" fields. When a translation is applied directly to a column in a data frame, the column class is first converted to 'factor' and then the coded values are replaced with the code translations.
# NOT RUN {
nhanesTranslate('DEMO_B', c('DMDBORN','DMDCITZN'))
nhanesTranslate('BPX_F', 'BPACSZ', details=TRUE)
# }
# NOT RUN {
nhanesTranslate('BPX_F', 'BPACSZ', data=nhanes('BPX_F'))
# }
Run the code above in your browser using DataLab