[R] formatting date strings
Jason Turner
jasont at indigoindustrial.co.nz
Wed Feb 13 10:09:11 CET 2002
On Wed, Feb 13, 2002 at 03:47:01PM +1100, Jeremy.Whish at csiro.au wrote:
...
> I have a simulation model that out puts dates in a standard dd/mm/yy format
> R reads this as a factor
Step 1 - you need to read it as plain dumb text first.
In help(read.table), check out the "as.is" option. You probably want
as.is=TRUE
> and I cant find anything that will allow me to
> convert them to a date.
Step 2 - you need to convert the plain dumb text to a date.
R has very sophisticated date/time handling - help(DateTimeClasses)
and help(strptime) will give you a starting background. See if this
makes sense to you once you've read that.
my.data.frame$text.dates<-strptime(my.data.frame$text.dates,"%d/%m/%y")
Cheers
Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list