diff --git a/DESCRIPTION b/DESCRIPTION index bb67f0b..d78ff2c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: nhanesA Version: 0.7.4 -Date: 2023-06-29 +Date: 2023-07-16 Title: NHANES Data Retrieval Authors@R: person(given = "Christopher", diff --git a/NEWS.md b/NEWS.md index 1f5a7da..87bfd01 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +Version 0.7.4 +================================================================================ + +- Add option includelabels to nhanes, which keeps the SAS label attribute (thanks @bashiruda https://github.com/cjendres1/nhanes/issues/17). + Version 0.7.3 ================================================================================ diff --git a/R/nhanes_translate.R b/R/nhanes_translate.R index a0a6041..17d6f79 100644 --- a/R/nhanes_translate.R +++ b/R/nhanes_translate.R @@ -139,7 +139,7 @@ nhanesTranslate <- function(nh_table, colnames=NULL, data = NULL, nchar = 32, if(length(idx)>0) { ## The column is present. Next we need to decide if it should be translated. if(length(levels(as.factor(data[[idx]]))) >= mincategories) { # If we reached this point then yes we are translating - # Check for label attribute + # Check for SAS label attribute idx_label <- attr(data[[idx]],"label") data[[idx]] <- as.factor(data[[idx]]) data[[idx]] <- suppressMessages(plyr::mapvalues(data[[idx]], from = translations[[cname]][['Code.or.Value']], diff --git a/vignettes/Introducing_nhanesA.R b/vignettes/Introducing_nhanesA.R index 1138b85..9b37910 100644 --- a/vignettes/Introducing_nhanesA.R +++ b/vignettes/Introducing_nhanesA.R @@ -134,7 +134,7 @@ df ## ----nhanestranslate2, eval=FALSE--------------------------------------------- # bpx_d_vars <- nhanesTableVars('EXAM', 'BPX_D', namesonly=TRUE) # #Alternatively may use bpx_d_vars = names(bpx_d) -# bpx_d <- suppressMessages(nhanesTranslate('BPX_D', bpx_d_vars, data=bpx_d)) +# bpx_d <- nhanesTranslate('BPX_D', bpx_d_vars, data=bpx_d) ## ----simpletranslate2, echo=FALSE--------------------------------------------- translated <- c('BPAARM', 'BPACSZ', 'BPAEN2', 'BPAEN3', 'BPAEN4', 'BPQ150A', 'BPQ150B', 'BPQ150C', 'BPQ150D', 'BPXPTY', 'BPXPULS', 'PEASCCT1', 'PEASCST1') diff --git a/vignettes/Introducing_nhanesA.html b/vignettes/Introducing_nhanesA.html index d8bfa97..43f7532 100644 --- a/vignettes/Introducing_nhanesA.html +++ b/vignettes/Introducing_nhanesA.html @@ -12,7 +12,7 @@ - +
<- nhanesTableVars('EXAM', 'BPX_D', namesonly=TRUE)
bpx_d_vars #Alternatively may use bpx_d_vars = names(bpx_d)
-<- suppressMessages(nhanesTranslate('BPX_D', bpx_d_vars, data=bpx_d)) bpx_d
## Translated columns: BPAARM BPACSZ BPAEN2 BPAEN3 BPAEN4 BPQ150A BPQ150B BPQ150C BPQ150D BPXPTY BPXPULS PEASCCT1 PEASCST1
head(bpx_d[,6:11])
## BPQ150A BPQ150B BPQ150C BPQ150D BPAARM BPACSZ