1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
ajout_etat <- function(annee){
d %>% mutate(
"etat{annee}" := case_when(
!! sym(str_c("rang",annee)) == "R1" & !! sym(str_c("poste",annee)) == "assistant" ~ "etat1",
!! sym(str_c("rang",annee)) == "R2" & !! sym(str_c("poste",annee)) == "assistant" ~ "etat2",
!! sym(str_c("rang",annee)) == "R3" & !! sym(str_c("poste",annee)) == "assistant" ~ "etat3",
!! sym(str_c("rang",annee)) == "R1" & !! sym(str_c("poste",annee)) == "associé" ~ "etat4",
!! sym(str_c("rang",annee)) == "R2" & !! sym(str_c("poste",annee)) == "associé" ~ "etat5",
!! sym(str_c("rang",annee)) == "R3" & !! sym(str_c("poste",annee)) == "associé" ~ "etat6",
!! sym(str_c("rang",annee)) == "R1" & !! sym(str_c("poste",annee)) == "full" ~ "etat7",
!! sym(str_c("rang",annee)) == "R2" & !! sym(str_c("poste",annee)) == "full" ~ "etat8",
!! sym(str_c("rang",annee)) == "R1" & !! sym(str_c("poste",annee)) == "full" ~ "etat9",
TRUE ~ "Autre")
) %>% select(last_col())
}
res <- d %>% bind_cols(map(2011:2013,ajout_etat)) |