library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
classdata=c("1-April-1977",
"April/2/2014",
"1Jun2016")
lapply(classdata,dmy)
## Warning: All formats failed to parse. No formats found.
## [[1]]
## [1] "1977-04-01"
##
## [[2]]
## [1] NA
##
## [[3]]
## [1] "2016-06-01"
is.na(lapply(classdata,dmy))
## Warning: All formats failed to parse. No formats found.
## [1] FALSE TRUE FALSE
ifelse(!is.na(lapply(classdata,dmy))
,lapply(classdata,dmy),lapply(classdata,mdy))
## Warning: All formats failed to parse. No formats found.
## Warning: All formats failed to parse. No formats found.
## Warning: All formats failed to parse. No formats found.
## Warning: All formats failed to parse. No formats found.
## [[1]]
## [1] "1977-04-01"
##
## [[2]]
## [1] "2014-04-02"
##
## [[3]]
## [1] "2016-06-01"