mercredi 19 mai 2021

Is there a R function for using ifelse with 2 conditions

This is the sample of my data

a<-c(NA,NA,NA,65,75,85)
b<-c(12,15,22,65,20,30)
c<-(12,15,22,65,75,85)
data<-data.frame(a,b,c)

I am trying to create a new variable d, such that if a=NA then b, if a=b then a and finally, if a>b then a.

My final data d<-c(12,15,22,65,75,85)

Thankyou

Aucun commentaire:

Enregistrer un commentaire