dimanche 28 novembre 2021

ifelse, is.na and replace

I have a big data frame where I am trying to figure out with NA values

q3 times_30
Very easy 18/11/2021
Easy 01/01/2021
NA Not due
NA No answer
NA 01/02/2021

I am using

df$q3<-ifelse (is.na(df$q3), df$times_30,df$q3)

Where gives me

q3 times_30
Very easy 18/11/2021
Easy 01/01/2021
Not due Not due
No answer No answer
01/02/2021 01/02/2021

but I would like instead of replaced with the date at the NA of q3 to give me a "No answer", as the following

q3 times_30
Very easy 18/11/2021
Easy 01/01/2021
Not due Not due
No answer No answer
No answer 01/02/2021

Aucun commentaire:

Enregistrer un commentaire