[R] couting events by subject with black out windows

2011-11-18 Thread Chris Conner
I large datset that includes subjects(ID), Dates and events that need to be counted.  Not every date includes an event, and I need to only count one event per 30days, per subject.  So in essence, I need to create a 30-day black out period during which time an event cannot be counted for each

Re: [R] couting events by subject with black out windows

2011-11-18 Thread Dennis Murphy
Hi: Here's a Q D solution that could be improved. It uses the plyr package. Starting from your data1 data frame, library('plyr') dseq - seq(as.Date('2010-01-01'), as.Date('2011-06-05'), by = '30 days') # Use the cut() function to create a factor whose levels are demarcated # by the dates in