Perhaps flogging a dead horse here, but notice that your desired output has lines C and D in conflicting formats, since you can't have 19 in both 1st and 2nd position. Also, it is not clear that A-C are not yy-mm-dd, with B being November 20 2022.
If you can ensure that formats are at least consistent within xx-yy-zz and xx/yy/zzzz, then you can do as Rui suggests (possibly safeguarded by comparing results for several formats), otherwise you are a bit "up the roof without a paddle". -pd > On 20 Jan 2020, at 23:58 , Val <valkr...@gmail.com> wrote: > > Hi All, > > I have a data frame where one column is a mixed date format, > a date in the form "%m-%d-%y" and "%m/%d/%Y", also some are not in date > format. > > Is there a way to delete the rows that contain non-dates and > standardize the dates in one date format like %m-%d-%Y? > Please see my sample data and desired output > > DFX<-read.table(text="name ddate > A 19-10-02 > B 22-11-20 > C 19-01-15 > D 11/19/2006 > F 9/9/2011 > G 12/29/2010 > H DEX",header=TRUE) > > Desired output > name ddate > A 19-10-2002 > B 22-11-2020 > C 19-01-2015 > D 11-19-2006 > F 09-09-2011 > G 12-29-2010 > > Thank you > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.