#' Get full label list
#'
#' Returns full list of code labels for variable
#' @param .table Data table
#' @param .var Colum name for variable of interest
#' @param .labels Path to .csv file containing code labels
#' @return List giving all possible code labels
#' @export
#' @examples
#' getLabelNames(data[['household']], 'income', path.to.labels)
getLabelNames <- function(.table, .var, .labels) {
codes <- unique(.table[[.var]])
if (.var=='dm_grade' | .var=='income') {codes <- c(codes, 'm')}
var_labs <- .labels %>% filter(variable == .var & code_val %in% codes)
return(as.character(var_labs[['val_label']]))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.