Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-04 Thread Dimitri Liakhovitski
Michael, thanks a lot! Really appreciate it - what wasn't hard for you would be for me! Dimitri On Thu, Aug 4, 2011 at 2:20 PM, R. Michael Weylandt wrote: > You are getting 105 because the default behavior of findInterval  is such > that v[N+1] := + Inf (as noted in ? findInterval); that is, the

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-04 Thread R. Michael Weylandt
You are getting 105 because the default behavior of findInterval is such that v[N+1] := + Inf (as noted in ? findInterval); that is, the last interval is actually taken to stretch from the final element of sbwl.dates unto eternity. It shouldn't be hard to write a catch line to set that to whatever

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-04 Thread Dimitri Liakhovitski
Sorry for renewing the topoic. I thought it worked but now I've run into a little problem: # My data frame with dates for week starts (Mondays) y<-data.frame(week=seq(as.Date("2009-12-28"), as.Date("2011-12-26"),by="week") ) # I have a vector of super bowl dates (including the future one for 201

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Dimitri Liakhovitski
Thanks a lot, everyone! Dimitri On Tue, Aug 2, 2011 at 12:34 PM, Dennis Murphy wrote: > Hi: > > You could try the lubridate package: > > library(lubridate) > week(weekly$week) > week(july4) > [1] 27 27 > >> week > function (x) > yday(x)%/%7 + 1 > > > which is essentially Gabor's code :) > > HTH,

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Dennis Murphy
Hi: You could try the lubridate package: library(lubridate) week(weekly$week) week(july4) [1] 27 27 > week function (x) yday(x)%/%7 + 1 which is essentially Gabor's code :) HTH, Dennis On Tue, Aug 2, 2011 at 7:36 AM, Dimitri Liakhovitski wrote: > Hello! > > I have dates for the beginning of

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Gabor Grothendieck
On Tue, Aug 2, 2011 at 10:36 AM, Dimitri Liakhovitski wrote: > Hello! > > I have dates for the beginning of each week, e.g.: > weekly<-data.frame(week=seq(as.Date("2010-04-01"), > as.Date("2011-12-26"),by="week")) > week  # each week starts on a Monday > > I also have a vector of dates I am intere

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread David Winsemius
The findInterval function should surely be tried in some form or another. On Aug 2, 2011, at 10:36 AM, Dimitri Liakhovitski wrote: Hello! I have dates for the beginning of each week, e.g.: weekly<-data.frame(week=seq(as.Date("2010-04-01"), as.Date("2011-12-26"),by="week")) week # each week