I have this dataframe:
df <- read.table(text="
date1 date2
1 NA 2016-12-01
2 2017-01-01 2018-10-01
3 2016-12-01 NA
4 NA NA
", header=TRUE)
What I need is to create new "max_date" column which will be containing maximum of date1/date2 columns. Note that at some rows are NA values, in some cases are NA in both columns.
I tried to achieve that with some if_else but code is too complicated.
Aucun commentaire:
Enregistrer un commentaire