set_vall | R Documentation |
A pipe-workflow optimised method to set value labels.
This is a wrapper around haven::labelled()
, but preserves
the original variable label of the vector.
set_vall(x, value_labels)
x |
Variable to assign value labels to |
value_labels |
Named character vector to be assigned as value labels |
Other Labels:
set_varl()
library(magrittr)
library(dplyr)
library(tibble)
tibble(RESPID=1:1000,
Q1=sample(c(0,1,2),1000,replace=TRUE),
Q2=sample(c(0,1),1000,replace=TRUE))-> df
df %>%
mutate_at("Q2",funs(set_varl(.,"What is your answer to this yes/no question?"))) %>%
mutate_at("Q2",funs(set_vall(.,c("No"=0,"Yes"=1)))) %>%
.$Q2 %>% attributes()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.