Skip to content
Prev 267599 / 398502 Next

identifying weeks (dates) that certain days (dates) fall into

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 2012):
sbwl.dates<-as.Date(c("2005-02-06","2006-02-05","2007-02-04","2008-02-03","2009-02-01","2010-02-07","2011-02-06","2012-02-05"))
I want to find the weeks in y that contain super bowl dates for
applicable years. I am trying:
sbwl.weeks<-findInterval(sbwl.dates, y$week)
sbwl.weeks<-sbwl.weeks[sbwl.weeks>0]
(sbwl.weeks)
y$flag<-0
y$flag[sbwl.weeks]<-1

6 and 58 are correct. But why am I getting 105 (the last row)?
Any way to fix it?
Thanks a lot!
Dimitri



On Tue, Aug 2, 2011 at 12:57 PM, Dimitri Liakhovitski
<dimitri.liakhovitski at gmail.com> wrote: