[R] date.mdy in date package

Brian Scholl brianscholl at yahoo.com
Fri Jun 9 21:13:17 CEST 2006


I'm having a problem with output from date.mdy in the date package. 
   
  Goal: to take a long vector of dates of the form "01/22/99" and extract values month="01", day="22", year="1999".  
   
  I am providing the vector of class dates in the attached file to date.mdy: 
   
  > mdy_dates<-date.mdy(trimmed_dates)
   
  The first few obs of the attached vector of dates are: 
              1  1/2/2003    2  1/3/2003    3  1/6/2003    4  1/7/2003    5  1/8/2003    6  1/9/2003    7  1/10/2003    8  1/13/2003    9  1/14/2003
   
  I am expecting to get a list with vectors for the day, month, and year.  The function appears to spit out the format I expect (though I would like months/days with leading zeros) but incorrect values, But what I get in the first few lines is something like: 
   
  > mdy_dates
$month
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  2  2
 [26]  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  3  3  3  3  3  3  3  3
 [51]  3  3  3  3  3  3  3  3  3  3  3  3  3  3  4  4  4  4  4  4  4  4  4  4  4
$day
  [1]  1  2  5  6  7  8  9 12 13 14 15 16 19 20 21 22 23 26 27 28 29 30  2  3  4
 [26]  5  6  9 10 11 12 13 16 17 18 19 20 23 24 25 26 27  2  3  4  5  6  9 10 11
 [51] 12 13 16 17 18 19 20 23 24 25 26 27 30 31  1  2  3  6  7  8  9 10 13 14 15
$year
  [1] 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993
 [16] 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993
 [31] 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993

  So: The first day of my list of dates is Jan 2, 2003, but in the list output the first date is Jan 1, 1993.  Have I incorrectly formatted my input, or is there some other problem? 
   
  Thanks in advance. 

 __________________________________________________




More information about the R-help mailing list