Skip to content
Prev 169787 / 398506 Next

Counting session days

On Mon, Feb 9, 2009 at 4:57 PM, <stefan.petersson at inizio.se> wrote:
Hej Stefan,

The following should do. It's a bit convoluted though, so someone else
might be able to come up with a better solution.
start       stop
1 2009-01-03 2009-01-04
2 2009-01-01 2009-01-05
3 2009-01-02 2009-01-09

activeDaysPerSession<-apply(test,MARGIN=1,FUN=function(x)
seq(from=as.Date(x["start"]),
to=as.Date(x["stop"]),by=1
)
)
ActiveDays<-as.Date(unlist(activeDaysPerSession))
as.data.frame(table(ActiveDays))



Regards,

Gustaf