[R] Assigning week numbers

Michael Hosack mhosack9 at hotmail.com
Wed Apr 21 21:00:01 CEST 2010



Gustaf,
 
That is correct. Schedule3 does contain all of the Saturdays between April 30 
and Nov. 01 for a given year. 
 
Mike

R experts,
>
> How could I extract the week number from a date vector (in Date class) 
> such that week numbering (week 1...2...) begins (May 01) and ends 
> (October 31) on the same specific dates each year? Week numbering must 
> conform to the following day numbering format (Sat=1,Sun=2,Mon=3.....Fri=7).
> This means that new weeks must begin on Saturdays, and end on Fridays 
> (except for the first date of May 01, which always begins week 1; week 
> 2 begins on the proceeding Saturday). This needs to be applicable 
> across years to work effectively. I have tried using both vectorized 
> and loop approaches with no success.
>
> I am including a bit of old Systat code that does the trick simply and concisely.
> If anyone knows an analogous method in R please let me know. My R 
> dataframe contains all the variables and data in the Systat temp file.
>
> Use sched3.t
> Save sched4.t
> Hold
> By mm dd
> If bof then let week=1
> Else if bog and DOW$="SAT" then let week = week + 1 Run
>
>
> Thank you,
>
> Mike
 

>From your code, it seems as if you're assuming that SCHEDULE3 contains
all consecutive saturdays, without skipping any. Is that correct?
/Gustaf 		 	   		  
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.

ID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4


More information about the R-help mailing list