[R] start and end times to yes/no in certain intervall
Stefan Uhmann
stefan.uhmann at googlemail.com
Fri Jul 23 12:02:29 CEST 2010
Hi List,
I have start and end times of events
structure(list(start = c("15:00", "15:00", "15:00", "11:00",
"14:00", "14:00", "15:00", "12:00", "12:00", "12:00", "12:00",
"12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00",
"12:00", "12:00"), end = c("16:00", "16:00", "16:00", "12:00",
"16:00", "15:00", "16:00", "13:00", "13:00", "13:00", "13:00",
"13:00", "13:00", "13:00", "13:00", "13:00", "13:00", "13:00",
"13:00", "13:00")), .Names = c("start", "end"), row.names = c(NA,
20L), class = "data.frame")
and I would like the data to look like this:
> t9 t10 t11 t12 t13 t14 t15 t16 t17
> 1 FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
> 2 FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
> 3 FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
> 4 FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> 5 FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE
> 6 FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE
> 7 FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
> 8 FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
> 9 FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
> 10 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
Which means, that I just get a TRUE for every hour the event was taking
place. A finishing time of 16:00 means that t16 is FALSE, because the
event was finished until 16:00; 16:15 as end time would result in t16
being TRUE.
It would be nice if the function would add the variables needed (t9 ..)
as well and depending on the times put in (no t9 if there is no event
starting before 10:00).
Thanks for any suggestion,
Stefan
More information about the R-help
mailing list