powered by
superseded
recode() has been superseded by case_match().
recode()
case_match()
Replace old values of a vector with new values.
recode(.x, ..., .default = NULL, .missing = NULL)
A vector
A series of old = new pairs specifying the new values
old = new
The default value if all conditions evaluate to FALSE
FALSE
What missing values should be replaced with
char_vec <- c("a", "b", "c") recode(char_vec, a = "Apple", b = "Banana") num_vec <- 1:3 recode(num_vec, `1` = 10, `2` = 25, .default = 100)
Run the code above in your browser using DataLab