I have hundreds of CSV files coming in from another program that have
a text field representing the date time combined together. I need to
strip the time and keep the date. How could I do that?
In the example below, on the first line I need to keep the 6/15/2009,
turning it into a date that R
Mark -
Here's a few possibilites:
dts = c('6/10/2009 10:04:00 AM','6/15/2009 9:47:00 AM','6/15/2009 9:47:00 AM')
as.Date(sapply(strsplit(dts,' '),'[',1),'%m/%d/%Y')
[1] 2009-06-10 2009-06-15 2009-06-15
as.Date(sub('(\\d+/\\d+/\\d+) .*','\\1',dts),'%m/%d/%Y')
[1] 2009-06-10 2009-06-15
Try as.Date() with a suitable format (it only knows about
internationally standard formats), e.g. maybe you mean
as.Date(6/10/2009 10:04:00 AM, format=%m/%d/%Y)
[1] 2009-06-10
On Tue, 8 Feb 2011, Mark Knecht wrote:
I have hundreds of CSV files coming in from another program that have
a
On Tue, Feb 8, 2011 at 11:30 AM, Prof Brian Ripley
rip...@stats.ox.ac.uk wrote:
Try as.Date() with a suitable format (it only knows about internationally
standard formats), e.g. maybe you mean
as.Date(6/10/2009 10:04:00 AM, format=%m/%d/%Y)
[1] 2009-06-10
Thank you!
- Mark
On Tue, Feb 8, 2011 at 11:29 AM, Phil Spector spec...@stat.berkeley.edu wrote:
Mark -
Here's a few possibilites:
dts = c('6/10/2009 10:04:00 AM','6/15/2009 9:47:00 AM','6/15/2009 9:47:00
AM')
as.Date(sapply(strsplit(dts,' '),'[',1),'%m/%d/%Y')
[1] 2009-06-10 2009-06-15 2009-06-15
5 matches
Mail list logo