[R-SIG-Finance] About timeDate Problem
Guy Green
guygreen at netvigator.com
Sun Jun 6 15:24:12 CEST 2010
I may be missing something on this, but it seems timeDate is quite difficult
to work with. For example, the following code shows some dates working, and
others not, but it is hard to see what the difference is except that
timeDate has difficulty dealing with single digit dates:
timeDate("6/7/2010", format = "%m/%d/%Y") #works fine
timeDate("5/28/2010", format = "%m/%d/%Y") #works fine
timeDate(c("6/7/2010", "5/28/2010"), format = "%m/%d/%Y") #doesn't work. I
have no idea why the dates work on their own (above), but not together.
timeDate(c("06/07/2010", "05/28/2010"), format = "%m/%d/%Y") #works - so
the single/double issue seems to be the cause of the problem
timeDate(c("06-07-2010", "05-28-2010"), format = "%m-%d-%Y") #works fine
Could you just use as.Date? Does this get you what you wanted?
date <- read.csv("D:/date.csv",header=T,sep=",")
date2 = as.Date(date$Date, format = "%m/%d/%Y")
date2
Guy
--
View this message in context: http://r.789695.n4.nabble.com/About-timeDate-Problem-tp2243951p2244985.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list