Make this query simple: Given data = data.frame(mode=c("car","car","car","car"),choice = c(1,0, 0,0),mainmode = c("BS","car","active","TX")); where BS = Bus, car =car, active = walk, TX = taxi.
Target output = data.frame(mode = c("car","car","car","car"),choice = c(0,1, 0,0), mainmode=c("BS","car","active","TX")). In addition, if any value from "mode" does not match with any value in "mainmode", in this case choice values (i.e., c(1,0,0,0))should remain same as it is in data.
Can anyone help me? Many thanks in advance.
Aucun commentaire:
Enregistrer un commentaire