Re: [R] Assigning week numbers

2010-04-22 Thread Gustaf Rydevik
On Wed, Apr 21, 2010 at 6:50 PM, Michael Hosack wrote: > > > I provided a minimized version of my dataframe at the bottom of this message > containing the results of David's code in variable ('wkoffset') and Jeff > Hallman's code in ('WEEK'). Jeff's code produced the correct results (thank > yo

Re: [R] Assigning week numbers

2010-04-21 Thread David Winsemius
roach you provided does not end Week 1 on a Friday and does not end subsequent week #'s on Fridays. My solution should be adjustable for any day-of-week ending number. Why don't you provide a minimal example for testing and show how apply my solution fails? Your original version was defin

[R] Assigning week numbers

2010-04-21 Thread Michael Hosack
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

[R] Assigning Week Numbers

2010-04-21 Thread Michael Hosack
#x27;s on Fridays. > > My solution should be adjustable for any day-of-week ending number. > Why don't you provide a minimal example for testing and show how apply > my solution fails? Your original version was definitely not "minimal." > -- > David. >> >> Thanks again, >> >> Mike >>

Re: [R] Assigning week numbers

2010-04-21 Thread David Winsemius
how how apply my solution fails? Your original version was definitely not "minimal." -- David. Thanks again, Mike CC: mhosack9 at hotmail.com; r-help at r-project.org From: dwinsemius at comcast.net To: dwinsemius at comcast.net Subject: Re: [R] Assigni

[R] Assigning week numbers

2010-04-21 Thread Michael Hosack
r. Why don't you provide a minimal example for testing and show how apply my solution fails? Your original version was definitely not "minimal." -- David. > > Thanks again, > > Mike > > >> CC: mhosack9 at hotmail.com; r-

Re: [R] Assigning Week Numbers

2010-04-21 Thread Gustaf Rydevik
On Tue, Apr 20, 2010 at 7:59 PM, Michael Hosack wrote: > > 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

Re: [R] Assigning Week Numbers

2010-04-21 Thread David Winsemius
insem...@comcast.net Subject: Re: [R] Assigning Week Numbers Date: Tue, 20 Apr 2010 16:03:09 -0400 On Apr 20, 2010, at 2:55 PM, David Winsemius wrote: On Apr 20, 2010, at 1:59 PM, Michael Hosack wrote: R experts, How could I extract the week number from a date vector (in Date class) such that

Re: [R] Assigning Week Numbers

2010-04-21 Thread Jeffrey J. Hallman
Take a look at the 'ti' stuff in the tis package on CRAN. If I understand you correctly, you want something like this: weekNumber <- function(aDate){ aTi <- ti(aDate, tif = "wfriday") may1ymd <- 1*year(aTi) + 501 baseWeek <- ti(may1ymd, tif = "wfriday") return(aTi - baseWeek +