Recoding in R

https://dplyr.tidyverse.org/reference/recode.html

# For character values, recode values with named arguments only. Unmatched # values are unchanged. char_vec <- sample(c("a", "b", "c"), 10, replace = TRUE) recode(char_vec, a = "Apple")
#> [1] "Apple" "b" "Apple" "b" "c" "Apple" "c" "c" "b" #> [10] "Apple"
recode(char_vec, a = "Apple", b = "Banana")
#> [1] "Apple" "Banana" "Apple" "Banana" "c" "Apple" "c" "c" #> [9] "Banana" "Apple"

 

My example:

court2qe$abc2<-recode(
court2qe$abc,"this is" = "X",
"That is" = "Y")