mardi 25 mai 2021

is there an r code that can select based on 3 columns and returns a value based on the options

I want to create a new variable name based on roof, wall and floor. if any of the options has 1 then the new variable is assigned 1 and zero otherwise.

roof<-c(1,1,1,0,1,0)
    wall<-c(0,1,1,0,0,0)
    floor<-c(1,1,1,0,1,0)
    data<-data.frame(roof,wall,floor)
    data
    data$code<-c(1,1,1,0,1,0)

Aucun commentaire:

Enregistrer un commentaire