#' Clean smoking data
#'
#' Classify individuals as smokers, ex-smokers, and non-smokers.
#'
#' @return Returns a new set of variables
#' @export
aps_clean_smoking <- function(
data
) {
data[smoker == 1, smoker_status := "smoker"]
data[smoker == 2, smoker_status := "ex-smoker"]
data[smoker == 3, smoker_status := "never smoked"]
# drop surplus variables
data <- subset(data,select = -c(smoker))
return(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.