dimanche 29 avril 2018

R Comparing the values of two factors in a data frame and getting the result in a third

i am trying to compare the values of two factors in a dataframe and getting the result in a third. I am trying to use a if statement.

Risk is the new column i'm trying to add.

 X = within(X, {
  Risk = if(X$Member == "Member" & X$Predict == "Non Member"){
    "Risk"
  } else{
    "No Risk"
  }  
})

Aucun commentaire:

Enregistrer un commentaire