I'd like to convert in vector mydates the NA in actual date (Sys.Date()) and if the values is a date then do not change anything, but I don't have success using ifelse or if_else of dplyr package. In my example:
# Package
library(dplyr)
# My vector
mydates<-c(NA,NA,NA,"2019-03-14","2020-05-01",NA,NA)
# Using ifelse
mydatescorr1<-ifelse(is.na(mydates)==TRUE,Sys.Date(),mydates)
mydatescorr1
[1] "18771" "18771" "18771" "2019-03-14" "2020-05-01" "18771" "18771"
#Using if_else
mydatescorr2<-if_else(is.na(mydates)==TRUE,Sys.Date(),mydates)
mydatescorr2
Erro: `false` must be a `Date` object, not a character vector.
Please, any help to fix it?