The vectorized form of if is ifelse and you could chain those together. However, the dplyr package has the function case_when which uses a convenient syntax for effectively chaining together ifelse calls.
library(dplyr)
DF <- data.frame(Cost = c("X", "R", "Y", "T"),
Schedule = c("A", "T", "X", "U"),
Scope = c("X", "T", "G", "Q"),
stringsAsFactors = FALSE)
DF
#> Cost Schedule Scope
#> 1 X A X
#> 2 R T T
#> 3 Y X G
#> 4 T U Q
DF <- mutate(DF, P =
case_when(
Cost == "R" | Schedule == "R" | Scope == "R" ~ "R",
Cost == "A" | Schedule == "A" | Scope == "A" ~ "A",
Cost == "G" | Schedule == "G" | Scope == "G" ~ "G",
TRUE ~ "Z"
)
)
DF
#> Cost Schedule Scope P
#> 1 X A X A
#> 2 R T T R
#> 3 Y X G G
#> 4 T U Q Z
Created on 2020-02-04 by the reprex package (v0.3.0)