I want to have summary coloum with this conditions:
- If part 1 greater than part 2 & 3 than give value 1
- If part 2 greater than part 1&3 than give value -1
- If part 3 greater than part 1&2 than give value 0
- If two part has same greater value give 0
-
If NA give value NA
df <- structure(list(id.Var1 = c("A", "A", "B", "A", "B", "C", "A", "B", "C", "D"), id.Var2 = c("B", "C", "C", "D", "D", "D", "E", "E", "E", "E"), Part1 = c(NA, 0, 0, 60, 100, 0, 20, 50, 20, 80), Part2 = c(NA, 60, 100, 0, 0, 100, 20, 50, 20, 0), Part3 = c(NA, 40, 0, 40, 0, 0, 60, 0, 60, 20)), row.names = c(37L, 73L, 74L, 109L, 110L, 111L, 145L, 146L, 147L, 148L), class = "data.frame")
Aucun commentaire:
Enregistrer un commentaire