Re: [R] Mixed format

2020-01-24 Thread Val
s with R, and that of most of the > > regular commentators here, that I submit > > this a little nervously! > > Thanks! > > Rui Barradas > > > > Many thanks to all who teach me so much here, lovely, if I am correct, to > > contribute for a change! > >

[R] Mixed format

2020-01-21 Thread David Luckett
Bearing Peter's warning in mind, the {anytime} package can be useful in this example: library(anytime) DFX$dnew <- anydate(DFX$ddate) DFX # First three strings are ambiguous # Also, string 5 is only OK if its assumed to be the same format as strings 4 & 6. # Can add a specific format to those any

Re: [R] Mixed format

2020-01-21 Thread Rui Barradas
nge! Chris - Original Message - From: "Rui Barradas" To: "Val" , "r-help@R-project.org (r-help@r-project.org)" Sent: Tuesday, 21 January, 2020 00:40:29 Subject: Re: [R] Mixed format Hello, The following strategy works with your data. It uses the fact

Re: [R] Mixed format

2020-01-21 Thread peter dalgaard
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 co

Re: [R] Mixed format

2020-01-21 Thread Chris Evans
that I submit this a little nervously! Many thanks to all who teach me so much here, lovely, if I am correct, to contribute for a change! Chris - Original Message - > From: "Rui Barradas" > To: "Val" , "r-help@R-project.org (r-help@r-project.org)" &

Re: [R] Mixed format

2020-01-20 Thread Rui Barradas
Hello, The following strategy works with your data. It uses the fact that most dates are in one of 3 formats, dmy, mdy, ymd. It tries those formats one by one, after each try looks for NA's in the new column. # first round, format is dmy DFX$dnew <- lubridate::dmy(DFX$ddate) na <- is.na(DFX$d

[R] Mixed format

2020-01-20 Thread Val
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