assign_labels <- function(df, vars, values) {
stopifnot(requireNamespace("purrr", quietly = TRUE))
purrr::modify_at(
df, vars,
factor, levels = as.integer(values), labels = names(values)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.