[R] Week of the Year date conversion

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Mon Dec 15 12:43:04 CET 2003


Prof Brian Ripley wrote:

> That is not a complete date!   Which day of the week is it?
> 
> 
>>example1<-"200301"
>>strptime(paste(example1, "1", format="%Y%U %d")
> 
> 
> will work, and you need to do something like that to resolve the 
> ambiguity.
> 

  Doesn't seem to work:

  - 6th day of 5th week:

 > strptime("2003 05 06", format="%Y %U %d")
[1] "2003-01-06"

  Ah ha. Use '%w' for 'day of week':

 > strptime("2003 05 06", format="%Y %U %w")
[1] "2003-02-02"

  I dont have a calendar to hand to check that 2 Feb is the 6th day of 
the 5th week....

Barry




More information about the R-help mailing list