Вот пример с вашими первыми тремя типами дел. Обратите внимание, что TRUE ~ "Historical")
эквивалентно вашему ELSE
.
library(dplyr)
Salary_Grade <- c("C01","F03","P02","TS1","C02","F04","P03","TS2","C03","F05","P04","T04")
df <- data.frame(Salary_Grade, stringsAsFactors = FALSE)
df %>%
mutate(value = case_when(Salary_Grade %in% c("C01","F03","P02","TS1") ~ "1",
Salary_Grade %in% c("C02","F04","P03","TS2") ~ "2",
Salary_Grade %in% c("C03","F05","P04","T04") ~ "3",
TRUE ~ "Historical"))
Salary_Grade value
1 C01 1
2 F03 1
3 P02 1
4 TS1 1
5 C02 2
6 F04 2
7 P03 2
8 TS2 2
9 C03 3
10 F05 3
11 P04 3
12 T04 3