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!
> >
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
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
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
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)"
&
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
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
7 matches
Mail list logo