[R] Dates in R

Don MacQueen macq at llnl.gov
Thu Dec 28 07:07:41 CET 2006


See the documentation for

   as.Date

Something like (untested):

as.Date(Date1, '"%m%d%y") - as.Date(Date2,"%m%d%y")

That's assuming Date1 and Date2 have already been loaded into R, and 
are character vectors. They would have to be character vectors in 
order to display the leading zero, as in 032398.

-Don

At 10:18 PM -0600 12/27/06, Brian Edward wrote:
>Hello all,
>
>Can somebody point me to references or provide some code on dealing with
>this date issue.  Basically, I have two vectors of values that represent
>dates.  I want to convert these values into a date format and subtract the
>differences to show elapsed time in days.  More specifically, here is the
>example:
>
>Date1      Date2
>032398    061585
>032398    061585
>111694    101994
>111694    101994
>062695    021595
>051898    111597
>072495    040195
>072495    040195
>
>The dates are in the mmddyy format, but when I attempt to format these in R
>with the function, date.mmddyy(Date1), I get very odd results.  Any help on
>this matter would be greatly appreciated!
>
>Thanks in advance,
>Brian
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.


-- 
---------------------------------
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA



More information about the R-help mailing list