I have a data frame and a set of rules defined in a table.
df <- rbind(c("blue","M","<10"),c("blue","F",">10"))
colnames(df)<-c("eyes","gender","age")
rule <- rbind(c("blue","M","<10",1),c("blue","M",">10",2),c("blue","F","<10",3),c("blue","F",">10",4))
colnames(rule)<-c("eyes","gender","age","result" )
Is there a way in R to apply the rules without rewriting the if else script?
Aucun commentaire:
Enregistrer un commentaire