问题
I have a dataframe like as shown below
d1 <- c('21/01/2052 9:02','12/30/2042 9:25','10134-5-28 0:0:0','10109-12-27 0:0:0','10176-6-7 0:0:0')
d2 <- c('22/03/2052 9:22','31/10/2043 9:25','10134-6-02 0:0:0','10109-12-30 0:0:0','10176-6-9 0:0:0')
df_test <- c(d1,d2)
Input
I tried something like below using lubridate
package but doesn't seem to help
mdy_hm(df_test$d1)
This resulted in a warning message and resulted in NAs
for invalid values
It's fine if invalid dates can't be processed and returns NA
. if I can get output as shown below for valid dates, that is also okay
I expect my output to be like shown below (for invalid dates). If invalid dates can't be processed, then just replacing them with NA
is also fine
Can you help with this?
来源:https://stackoverflow.com/questions/60202631/convert-invalid-date-to-a-valid-date-like-value-using-r