lundi 25 novembre 2019

Using an IF statement in R

I'm new to R. I want to do something along the lines of:

if Survive="Y" then Survive1=1 in my dataframe named "od" But, I'm having trouble with the code. This is what I currently have

od$Survive <- c(0)
if(od$Survive=="Y"){
  od$Survive1=1
}

I keep getting this warning: Warning message: In if (od$Survive == "Y") { : the condition has length > 1 and only the first element will be used

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire