How to draw a geom_tile plot - r
I want to create a plot that shows work schedules for each day. The data I have to work with looks something like this:
dput(head (TiNiSWeek, 3))
structure(list(`04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(0, 0, 0), `07:15` = c(0, 0, 0), `07:30` = c(0,
0, 0), `07:45` = c(0, 0, 0), `08:00` = c(0, 0, 2), `08:15` = c(0,
0, 2), `08:30` = c(0, 0, 2), `08:45` = c(0, 0, 2), `09:00` = c(0,
2, 2), `09:15` = c(0, 2, 2), `09:30` = c(0, 2, 2), `09:45` = c(0,
2, 2), `10:00` = c(0, 2, 2), `10:15` = c(0, 2, 2), `10:30` = c(0,
2, 2), `10:45` = c(0, 2, 2), `11:00` = c(0, 2, 2), `11:15` = c(0,
2, 2), `11:30` = c(0, 2, 2), `11:45` = c(0, 2, 2), `12:00` = c(0,
2, 0), `12:15` = c(0, 2, 2), `12:30` = c(0, 2, 2), `12:45` = c(0,
2, 2), `13:00` = c(0, 2, 2), `13:15` = c(0, 2, 2), `13:30` = c(0,
2, 2), `13:45` = c(0, 2, 2), `14:00` = c(0, 2, 2), `14:15` = c(0,
2, 2), `14:30` = c(0, 2, 2), `14:45` = c(0, 2, 2), `15:00` = c(0,
2, 2), `15:15` = c(0, 2, 2), `15:30` = c(0, 2, 2), `15:45` = c(0,
2, 2), `16:00` = c(0, 2, 2), `16:15` = c(0, 2, 2), `16:30` = c(0,
2, 2), `16:45` = c(0, 2, 2), `17:00` = c(0, 2, 0), `17:15` = c(0,
2, 0), `17:30` = c(0, 2, 0), `17:45` = c(0, 0, 0), `18:00` = c(0,
0, 0), `18:15` = c(0, 0, 0), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0), `04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(2, 0, 0), `07:15` = c(2, 0, 0), `07:30` = c(2,
0, 0), `07:45` = c(2, 0, 0), `08:00` = c(2, 0, 2), `08:15` = c(2,
0, 2), `08:30` = c(2, 0, 2), `08:45` = c(2, 0, 2), `09:00` = c(2,
2, 2), `09:15` = c(2, 2, 2), `09:30` = c(2, 2, 2), `09:45` = c(2,
2, 2), `10:00` = c(2, 2, 2), `10:15` = c(2, 2, 2), `10:30` = c(2,
2, 2), `10:45` = c(2, 2, 2), `11:00` = c(2, 2, 2), `11:15` = c(2,
2, 2), `11:30` = c(2, 2, 2), `11:45` = c(2, 2, 2), `12:00` = c(2,
2, 0), `12:15` = c(2, 2, 0), `12:30` = c(2, 2, 2), `12:45` = c(2,
2, 2), `13:00` = c(2, 2, 2), `13:15` = c(2, 2, 2), `13:30` = c(2,
2, 2), `13:45` = c(2, 2, 2), `14:00` = c(2, 2, 2), `14:15` = c(2,
2, 2), `14:30` = c(2, 2, 2), `14:45` = c(2, 2, 2), `15:00` = c(2,
2, 2), `15:15` = c(2, 2, 2), `15:30` = c(2, 2, 2), `15:45` = c(2,
2, 2), `16:00` = c(2, 2, 2), `16:15` = c(2, 2, 2), `16:30` = c(2,
2, 2), `16:45` = c(2, 2, 2), `17:00` = c(2, 2, 2), `17:15` = c(0,
2, 2), `17:30` = c(0, 2, 0), `17:45` = c(0, 2, 0), `18:00` = c(0,
0, 0), `18:15` = c(0, 0, 0), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0), `04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(0, 0, 0), `07:15` = c(0, 0, 0), `07:30` = c(0,
0, 0), `07:45` = c(0, 0, 0), `08:00` = c(0, 0, 2), `08:15` = c(0,
0, 2), `08:30` = c(0, 0, 2), `08:45` = c(0, 0, 2), `09:00` = c(0,
0, 2), `09:15` = c(0, 0, 2), `09:30` = c(0, 2, 2), `09:45` = c(0,
2, 2), `10:00` = c(0, 2, 2), `10:15` = c(0, 2, 2), `10:30` = c(0,
2, 2), `10:45` = c(0, 2, 2), `11:00` = c(0, 2, 2), `11:15` = c(0,
2, 2), `11:30` = c(0, 2, 2), `11:45` = c(0, 2, 2), `12:00` = c(0,
2, 2), `12:15` = c(0, 2, 2), `12:30` = c(0, 2, 2), `12:45` = c(0,
2, 2), `13:00` = c(0, 2, 2), `13:15` = c(0, 2, 0), `13:30` = c(0,
2, 0), `13:45` = c(0, 2, 2), `14:00` = c(0, 2, 2), `14:15` = c(0,
2, 2), `14:30` = c(0, 2, 2), `14:45` = c(0, 2, 2), `15:00` = c(0,
2, 2), `15:15` = c(0, 2, 2), `15:30` = c(0, 2, 2), `15:45` = c(0,
2, 2), `16:00` = c(0, 2, 2), `16:15` = c(0, 2, 2), `16:30` = c(0,
2, 2), `16:45` = c(0, 2, 2), `17:00` = c(0, 2, 2), `17:15` = c(0,
2, 0), `17:30` = c(0, 2, 0), `17:45` = c(0, 2, 0), `18:00` = c(0,
0, 0), `18:15` = c(0, 0, 0), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0), `04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(0, 0, 0), `07:15` = c(0, 0, 0), `07:30` = c(0,
0, 0), `07:45` = c(0, 0, 0), `08:00` = c(0, 0, 2), `08:15` = c(0,
0, 2), `08:30` = c(0, 0, 2), `08:45` = c(0, 0, 2), `09:00` = c(0,
2, 2), `09:15` = c(0, 2, 2), `09:30` = c(0, 2, 2), `09:45` = c(0,
2, 2), `10:00` = c(0, 2, 2), `10:15` = c(0, 2, 2), `10:30` = c(0,
2, 2), `10:45` = c(0, 2, 2), `11:00` = c(0, 2, 2), `11:15` = c(0,
2, 2), `11:30` = c(0, 2, 2), `11:45` = c(0, 2, 2), `12:00` = c(0,
2, 2), `12:15` = c(0, 2, 2), `12:30` = c(0, 2, 2), `12:45` = c(0,
2, 2), `13:00` = c(0, 2, 0), `13:15` = c(0, 2, 2), `13:30` = c(0,
2, 2), `13:45` = c(0, 2, 2), `14:00` = c(0, 2, 2), `14:15` = c(0,
2, 2), `14:30` = c(0, 2, 2), `14:45` = c(0, 2, 2), `15:00` = c(0,
2, 2), `15:15` = c(0, 2, 2), `15:30` = c(0, 2, 2), `15:45` = c(0,
2, 2), `16:00` = c(0, 2, 2), `16:15` = c(0, 2, 2), `16:30` = c(0,
2, 2), `16:45` = c(0, 2, 2), `17:00` = c(0, 2, 2), `17:15` = c(0,
2, 2), `17:30` = c(0, 2, 2), `17:45` = c(0, 2, 2), `18:00` = c(0,
0, 2), `18:15` = c(0, 0, 2), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0), `04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(0, 0, 0), `07:15` = c(0, 0, 0), `07:30` = c(0,
0, 0), `07:45` = c(0, 0, 0), `08:00` = c(0, 0, 2), `08:15` = c(0,
0, 2), `08:30` = c(0, 0, 2), `08:45` = c(0, 0, 2), `09:00` = c(0,
2, 2), `09:15` = c(0, 2, 2), `09:30` = c(0, 2, 2), `09:45` = c(0,
2, 2), `10:00` = c(0, 2, 2), `10:15` = c(0, 2, 2), `10:30` = c(0,
2, 2), `10:45` = c(0, 2, 2), `11:00` = c(0, 2, 2), `11:15` = c(0,
2, 2), `11:30` = c(0, 2, 2), `11:45` = c(0, 2, 2), `12:00` = c(0,
2, 2), `12:15` = c(0, 2, 2), `12:30` = c(0, 2, 2), `12:45` = c(0,
2, 2), `13:00` = c(0, 2, 2), `13:15` = c(0, 2, 2), `13:30` = c(0,
2, 2), `13:45` = c(0, 2, 2), `14:00` = c(0, 2, 2), `14:15` = c(0,
2, 0), `14:30` = c(0, 2, 2), `14:45` = c(0, 2, 2), `15:00` = c(0,
2, 2), `15:15` = c(0, 2, 2), `15:30` = c(0, 2, 2), `15:45` = c(0,
2, 2), `16:00` = c(0, 2, 2), `16:15` = c(0, 2, 2), `16:30` = c(0,
2, 2), `16:45` = c(0, 2, 2), `17:00` = c(0, 2, 2), `17:15` = c(0,
2, 0), `17:30` = c(0, 2, 0), `17:45` = c(0, 2, 0), `18:00` = c(0,
0, 0), `18:15` = c(0, 0, 0), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0), `04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(0, 0, 0), `07:15` = c(0, 0, 0), `07:30` = c(0,
0, 0), `07:45` = c(0, 0, 0), `08:00` = c(0, 0, 0), `08:15` = c(0,
0, 0), `08:30` = c(0, 0, 0), `08:45` = c(0, 0, 0), `09:00` = c(0,
0, 0), `09:15` = c(0, 0, 0), `09:30` = c(0, 0, 0), `09:45` = c(0,
0, 0), `10:00` = c(0, 0, 0), `10:15` = c(0, 0, 0), `10:30` = c(0,
0, 0), `10:45` = c(0, 0, 0), `11:00` = c(0, 0, 0), `11:15` = c(0,
0, 0), `11:30` = c(0, 0, 0), `11:45` = c(0, 0, 0), `12:00` = c(0,
0, 0), `12:15` = c(0, 0, 0), `12:30` = c(0, 0, 0), `12:45` = c(0,
0, 0), `13:00` = c(0, 0, 0), `13:15` = c(0, 0, 0), `13:30` = c(0,
0, 0), `13:45` = c(0, 0, 0), `14:00` = c(0, 0, 0), `14:15` = c(0,
0, 0), `14:30` = c(0, 0, 0), `14:45` = c(0, 0, 0), `15:00` = c(0,
0, 0), `15:15` = c(0, 0, 0), `15:30` = c(0, 0, 0), `15:45` = c(0,
0, 0), `16:00` = c(0, 0, 0), `16:15` = c(0, 0, 0), `16:30` = c(0,
0, 0), `16:45` = c(0, 0, 0), `17:00` = c(0, 0, 0), `17:15` = c(0,
0, 0), `17:30` = c(0, 0, 0), `17:45` = c(0, 0, 0), `18:00` = c(0,
0, 0), `18:15` = c(0, 0, 0), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0), `04:00` = c(0, 0, 0), `04:15` = c(0, 0, 0), `04:30` = c(0,
0, 0), `04:45` = c(0, 0, 0), `05:00` = c(0, 0, 0), `05:15` = c(0,
0, 0), `05:30` = c(0, 0, 0), `05:45` = c(0, 0, 0), `06:00` = c(0,
0, 0), `06:15` = c(0, 0, 0), `06:30` = c(0, 0, 0), `06:45` = c(0,
0, 0), `07:00` = c(0, 0, 0), `07:15` = c(0, 0, 0), `07:30` = c(0,
0, 0), `07:45` = c(0, 0, 0), `08:00` = c(0, 0, 0), `08:15` = c(0,
0, 0), `08:30` = c(0, 0, 0), `08:45` = c(0, 0, 0), `09:00` = c(0,
0, 0), `09:15` = c(0, 0, 0), `09:30` = c(0, 0, 0), `09:45` = c(0,
0, 0), `10:00` = c(0, 0, 0), `10:15` = c(0, 0, 0), `10:30` = c(0,
0, 0), `10:45` = c(0, 0, 0), `11:00` = c(0, 0, 0), `11:15` = c(0,
0, 0), `11:30` = c(0, 0, 0), `11:45` = c(0, 0, 0), `12:00` = c(0,
0, 0), `12:15` = c(0, 0, 0), `12:30` = c(0, 0, 0), `12:45` = c(0,
0, 0), `13:00` = c(0, 0, 0), `13:15` = c(0, 0, 0), `13:30` = c(0,
0, 0), `13:45` = c(0, 0, 0), `14:00` = c(0, 0, 0), `14:15` = c(0,
0, 0), `14:30` = c(0, 0, 0), `14:45` = c(0, 0, 0), `15:00` = c(0,
0, 0), `15:15` = c(0, 0, 0), `15:30` = c(0, 0, 0), `15:45` = c(0,
0, 0), `16:00` = c(0, 0, 0), `16:15` = c(0, 0, 0), `16:30` = c(0,
0, 0), `16:45` = c(0, 0, 0), `17:00` = c(0, 0, 0), `17:15` = c(0,
0, 0), `17:30` = c(0, 0, 0), `17:45` = c(0, 0, 0), `18:00` = c(0,
0, 0), `18:15` = c(0, 0, 0), `18:30` = c(0, 0, 0), `18:45` = c(0,
0, 0), `19:00` = c(0, 0, 0), `19:15` = c(0, 0, 0), `19:30` = c(0,
0, 0), `19:45` = c(0, 0, 0), `20:00` = c(0, 0, 0), `20:15` = c(0,
0, 0), `20:30` = c(0, 0, 0), `20:45` = c(0, 0, 0), `21:00` = c(0,
0, 0), `21:15` = c(0, 0, 0), `21:30` = c(0, 0, 0), `21:45` = c(0,
0, 0), `22:00` = c(0, 0, 0), `22:15` = c(0, 0, 0), `22:30` = c(0,
0, 0), `22:45` = c(0, 0, 0), `23:00` = c(0, 0, 0), `23:15` = c(0,
0, 0), `23:30` = c(0, 0, 0), `23:45` = c(0, 0, 0), `00:00` = c(0,
0, 0), `00:15` = c(0, 0, 0), `00:30` = c(0, 0, 0), `00:45` = c(0,
0, 0), `01:00` = c(0, 0, 0), `01:15` = c(0, 0, 0), `01:30` = c(0,
0, 0), `01:45` = c(0, 0, 0), `02:00` = c(0, 0, 0), `02:15` = c(0,
0, 0), `02:30` = c(0, 0, 0), `02:45` = c(0, 0, 0), `03:00` = c(0,
0, 0), `03:15` = c(0, 0, 0), `03:30` = c(0, 0, 0), `03:45` = c(0,
0, 0)), row.names = c(NA, 3L), class = "data.frame")
Each line in the df represents a time step (start time 04:00, end time 03:45, measured in 14 minutes) and there are seven days staring with Monday.
I would like to create a heatmap-type of plot using geom_tile (or geom_raster or geom_rect).
I would like to modify the x axis (to add breaks) as well the y axis (to replace with identification number).
Unfortunately, the data that I'm using doesn't seem to work, I think. I've tried to create a plot using all three geoms but without much success.
This is the only plot that I managed to create.
How can change this plot to represent the daily profiles profiles?
Thank you
Here's an approach using some wrangling to convert from matrix to data frame, and converting time character strings into "decimal hour since 4am."
TiNiSWeek %>%
rowid_to_column() %>%
as_tibble() %>%
gather(time, val, -rowid) %>%
mutate(day = rep(weekdays, each = 96*3) %>% fct_relevel(weekdays),
time_hm = hm(str_sub(time, end = 5)),
time_dec_from_start = hour(time_hm) + minute(time_hm)/60 - 4) %>%
ggplot(aes(time_dec_from_start, rowid, fill = val)) +
geom_tile() +
facet_wrap(~day)
Related
Adding 2 DF's of Different Sizes Together
I have two DF's: passesComb <- structure(list(P1_Good = c(0, 1, 0, 0, 0, 0, 1), P2_Good = c(2, 0, 0, 0, 0, 0, 2), P3_Good = c(0, 1, 0, 0, 0, 0, 1), P4_Good = c(0, 0, 1, 0, 0, 0, 1), P5_Good = c(0, 0, 0, 1, 0, 0, 1), P1_Bad = c(0, 0, 0, 0, 0, 0, 0), P2_Bad = c(0, 0, 0, 0, 0, 0, 0), P3_Bad = c(0, 0, 0, 0, 0, 0, 0), P4_Bad = c(0, 0, 1, 0, 0, 0, 1), P5_Bad = c(0, 0, 0, 0, 0, 0, 0), `Bad Pass` = c(0, 0, 1, 0, 0, 1, 1), `Good Pass` = c(2, 2, 1, 1, 0, 3, 6), `Intercepted Pass` = c(0, 0, 0, 0, 0, 1, 0 ), Turnover = c(0, 0, 0, 0, 0, 1, 0), totalEvents = c(2, 2, 2, 1, 0, 6, 7)), row.names = c("P1", "P2", "P3", "P4", "P5", "Opponent", "VT"), class = "data.frame") of size 7x15, and copyComb <- structure(list(P1_Good = c(0, 1, 0, 0, 0, 1), P2_Good = c(2, 0, 0, 0, 0, 2), P4_Good = c(0, 0, 0, 0, 0, 0), P5_Good = c(0, 0, 1, 0, 0, 1), P1_Bad = c(0, 0, 0, 0, 0, 0), P2_Bad = c(0, 0, 0, 0, 0, 0), P3_Bad = c(0, 0, 0, 0, 0, 0), P4_Bad = c(0, 0, 0, 0, 0, 0), P5_Bad = c(0, 0, 0, 0, 0, 0), `Bad Pass` = c(0, 0, 0, 0, 1, 0), `Good Pass` = c(2, 1, 1, 0, 3, 4), `Intercepted Pass` = c(0, 0, 0, 0, 1, 0), Turnover = c(0, 0, 0, 0, 1, 0), totalEvents = c(2, 1, 1, 0, 6, 4)), row.names = c("P1", "P2", "P4", "P5", "Opponent", "VT"), class = "data.frame") or simply, copyComb <- passesComb copyComb <- copyComb[-3,-3] #Updating specific cells since [3,3] is removed copyComb[2,11] <- 1 copyComb[2,14] <- 1 copyComb[6,8] <- 0 copyComb[6,3] <- 0 copyComb[6,10] <- 0 copyComb[6,11] <- 4 copyComb[6,14] <- 4 #This now equals the copyComb from dput() above of size 6x14. I am trying to combine/add these two df's together based on matching row/column names. I tried to achieve this using the code from the answer to this post gamesComb <- data.frame(matrix(NA, nrow = ifelse(nrow(passesComb) >= nrow(copyComb), nrow(passesComb),nrow(copyComb)), ncol = ifelse(ncol(passesComb) >= ncol(copyComb), ncol(passesComb),ncol(copyComb)))) gamesComb[row.names(ifelse(nrow(passesComb) >= nrow(copyComb), passesComb, copyComb)), colnames(ifelse(ncol(passesComb) >= ncol(copyComb), passesComb, copyComb))] <- passesComb Here, I create a df, gamesComb and set the dimensions of whichever passesComb or copyComb is bigger. It does create a 7x15 df, but doesn't add the row/col names. I also am trying to then add the 2 df's together based on the cell value if they have the same row/col name (same as in the post link above), i.e. passesComb["P2","P1_Good"] = 1 and copyComb["P2","P1_Good"] = 1, so gamesComb["P2","P1_Good"] should = 2, and same for all similar row/col names. So the final result look like: expectedOutput <- structure(list(P1_Good = c(0, 2, 0, 0, 0, 0, 2), P2_Good = c(4, 0, 0, 0, 0, 0, 4), P3_Good = c(0, 1, 0, 0, 0, 0, 1), P4_Good = c(0, 0, 1, 0, 0, 0, 1), P5_Good = c(0, 0, 0, 2, 0, 0, 2), P1_Bad = c(0, 0, 0, 0, 0, 0, 0), P2_Bad = c(0, 0, 0, 0, 0, 0, 0), P3_Bad = c(0, 0, 0, 0, 0, 0, 0), P4_Bad = c(0, 0, 1, 0, 0, 0, 1), P5_Bad = c(0, 0, 0, 0, 0, 0, 0), `Bad Pass` = c(0, 0, 1, 0, 0, 2, 1), `Good Pass` = c(4, 3, 1, 2, 0, 6, 10), `Intercepted Pass` = c(0, 0, 0, 0, 0, 2, 0), Turnover = c(0, 0, 0, 0, 0, 2, 0), totalEvents = c(4, 3, 2, 2, 0, 12, 11)), row.names = c("P1", "P2", "P3", "P4", "P5", "Opponent", "VT"), class = "data.frame")
Here's a dplyr/tidyr approach where I reshape each table into a long format, then join them, sum, and pivot wider again. library(dplyr); library(tidyr) lengthen <- function(df) { df %>% rownames_to_column(var = "row") %>% pivot_longer(-row)} full_join(lengthen(passesComb), lengthen(copyComb), by = c("row", "name")) %>% mutate(new_val = coalesce(value.x, 0) + coalesce(value.y, 0)) %>% select(-starts_with("value")) %>% pivot_wider(names_from = name,values_from = new_val)
Another option is to stack them and then sum by rowname groups. library(dplyr, warn.conflicts = FALSE) library(tibble) out <- rownames_to_column(passesComb) %>% bind_rows(rownames_to_column(copyComb)) %>% # bind_rows(rownames_to_column(third_table)) %>% if you want to add another select(rowname, names(passesComb)) %>% group_by(rowname) %>% summarise(across(everything(), sum, na.rm = T)) %>% slice(match(rownames(passesComb), rowname)) %>% column_to_rownames('rowname') all.equal(out, expectedOutput) #> [1] TRUE Created on 2021-10-09 by the reprex package (v2.0.1)
Hierarchical clustering of a time-series
I am struggling with hierarchical or clustering. I have the following time-series and I want to cluster to based on time. Would transpose function work for this? structure(list(`04:00` = c(0, 0, 0, 0, 0, 0), `04:10` = c(0, 0, 0, 0, 0, 0), `04:20` = c(0, 0, 0, 0, 0, 0), `04:30` = c(0, 0, 0, 0, 0, 0), `04:40` = c(0, 0, 0, 0, 0, 0), `04:50` = c(0, 0, 0, 0, 0, 0), `05:00` = c(0, 0, 0, 0, 0, 0), `05:10` = c(0, 0, 0, 0, 0, 0), `05:20` = c(0, 0, 0, 0, 0, 0), `05:30` = c(0, 0, 0, 0, 0, 0), `05:40` = c(0, 0, 0, 0, 0, 0), `05:50` = c(1, 0, 0, 0, 0, 0), `06:00` = c(1, 0, 0, 0, 0, 0), `06:10` = c(1, 0, 0, 0, 0, 0), `06:20` = c(2, 0, 0, 0, 0, 0), `06:30` = c(0, 0, 0, 0, 0, 0), `06:40` = c(0, 1, 0, 0, 0, 0), `06:50` = c(0, 2, 0, 0, 0, 1), `07:00` = c(0, 0, 0, 0, 0, 2), `07:10` = c(0, 0, 1, 0, 0, 2), `07:20` = c(0, 0, 0, 0, 0, 2), `07:30` = c(0, 0, 1, 0, 0, 0), `07:40` = c(1, 0, 1, 0, 0, 0), `07:50` = c(1, 0, 0, 0, 2, 0), `08:00` = c(1, 0, 0, 0, 0, 0), `08:10` = c(1, 0, 0, 0, 0, 0), `08:20` = c(2, 0, 0, 0, 0, 0), `08:30` = c(2, 0, 0, 0, 0, 0), `08:40` = c(2, 0, 0, 0, 0, 0), `08:50` = c(2, 0, 0, 0, 0, 0), `09:00` = c(0, 0, 0, 0, 0, 0), `09:10` = c(0, 0, 0, 0, 0, 0), `09:20` = c(0, 1, 0, 0, 0, 0), `09:30` = c(0, 1, 0, 2, 0, 0), `09:40` = c(0, 1, 0, 0, 0, 0), `09:50` = c(0, 1, 0, 0, 0, 0), `10:00` = c(0, 0, 0, 0, 0, 0), `10:10` = c(0, 0, 0, 0, 0, 0), `10:20` = c(0, 1, 0, 0, 0, 0), `10:30` = c(0, 1, 0, 0, 0, 0), `10:40` = c(0, 0, 0, 0, 0, 0), `10:50` = c(0, 0, 0, 0, 0, 0), `11:00` = c(2, 0, 0, 1, 0, 0), `11:10` = c(0, 0, 0, 1, 0, 0), `11:20` = c(0, 0, 0, 1, 0, 1), `11:30` = c(0, 0, 0, 1, 0, 1), `11:40` = c(0, 0, 0, 1, 0, 1), `11:50` = c(0, 0, 0, 1, 0, 0), `12:00` = c(0, 0, 0, 1, 2, 0), `12:10` = c(0, 0, 0, 1, 0, 0), `12:20` = c(0, 0, 0, 1, 0, 0), `12:30` = c(0, 0, 0, 1, 0, 0), `12:40` = c(0, 0, 0, 1, 0, 0), `12:50` = c(0, 0, 0, 1, 1, 0), `13:00` = c(0, 0, 0, 0, 1, 0), `13:10` = c(0, 0, 0, 0, 1, 0), `13:20` = c(0, 0, 0, 0, 1, 0), `13:30` = c(0, 0, 0, 0, 1, 0), `13:40` = c(0, 0, 0, 0, 1, 0), `13:50` = c(0, 0, 0, 0, 1, 0), `14:00` = c(0, 0, 0, 0, 1, 0), `14:10` = c(0, 0, 0, 0, 1, 0), `14:20` = c(0, 0, 0, 0, 1, 0), `14:30` = c(0, 0, 0, 0, 1, 0), `14:40` = c(0, 0, 0, 0, 1, 0), `14:50` = c(0, 0, 0, 0, 0, 0), `15:00` = c(0, 0, 0, 0, 0, 0), `15:10` = c(0, 2, 0, 0, 0, 0), `15:20` = c(0, 2, 0, 0, 1, 0), `15:30` = c(0, 2, 0, 0, 1, 1), `15:40` = c(0, 2, 0, 0, 1, 0), `15:50` = c(0, 2, 0, 0, 1, 0), `16:00` = c(0, 2, 0, 0, 1, 0), `16:10` = c(0, 2, 0, 0, 1, 0), `16:20` = c(2, 2, 0, 0, 1, 0), `16:30` = c(2, 2, 0, 0, 1, 2), `16:40` = c(2, 2, 0, 0, 1, 1), `16:50` = c(2, 2, 0, 0, 0, 1), `17:00` = c(0, 2, 0, 0, 2, 0), `17:10` = c(0, 0, 0, 0, 2, 0), `17:20` = c(0, 0, 0, 0, 2, 0), `17:30` = c(0, 0, 0, 0, 2, 0), `17:40` = c(0, 0, 0, 0, 0, 0), `17:50` = c(0, 0, 0, 0, 0, 0), `18:00` = c(0, 2, 0, 0, 0, 2), `18:10` = c(0, 2, 0, 0, 0, 2), `18:20` = c(0, 0, 0, 0, 2, 2), `18:30` = c(0, 0, 0, 0, 0, 2), `18:40` = c(0, 0, 0, 0, 0, 2), `18:50` = c(1, 0, 0, 0, 0, 2), `19:00` = c(1, 0, 0, 1, 1, 0), `19:10` = c(1, 0, 0, 1, 1, 0), `19:20` = c(1, 0, 0, 1, 1, 0), `19:30` = c(1, 0, 1, 1, 1, 0), `19:40` = c(1, 0, 1, 1, 1, 1), `19:50` = c(1, 0, 1, 1, 1, 1), `20:00` = c(0, 0, 1, 1, 1, 1), `20:10` = c(0, 0, 1, 1, 1, 1), `20:20` = c(0, 0, 1, 1, 1, 1), `20:30` = c(0, 1, 2, 1, 1, 1), `20:40` = c(0, 1, 0, 1, 1, 1), `20:50` = c(0, 1, 0, 1, 1, 1), `21:00` = c(0, 1, 0, 1, 1, 1), `21:10` = c(0, 1, 0, 0, 1, 1), `21:20` = c(0, 1, 0, 0, 1, 1), `21:30` = c(0, 1, 1, 0, 1, 1), `21:40` = c(0, 1, 1, 0, 1, 1), `21:50` = c(0, 1, 1, 0, 0, 1), `22:00` = c(0, 1, 1, 0, 0, 0), `22:10` = c(0, 1, 0, 0, 0, 0), `22:20` = c(0, 1, 0, 0, 0, 0), `22:30` = c(0, 1, 0, 0, 0, 0), `22:40` = c(0, 1, 0, 0, 0, 0), `22:50` = c(0, 1, 0, 0, 0, 0), `23:00` = c(0, 0, 0, 0, 1, 0), `23:10` = c(0, 0, 0, 0, 0, 1), `23:20` = c(0, 0, 0, 0, 0, 1), `23:30` = c(0, 0, 0, 0, 0, 1), `23:40` = c(0, 0, 0, 0, 0, 1), `23:50` = c(0, 0, 0, 0, 0, 0), `00:00` = c(0, 0, 0, 0, 0, 0), `00:10` = c(0, 0, 0, 0, 0, 0), `00:20` = c(0, 0, 0, 0, 0, 0), `00:30` = c(0, 0, 0, 0, 0, 0), `00:40` = c(0, 0, 0, 0, 0, 0), `00:50` = c(0, 0, 0, 0, 0, 0), `01:00` = c(0, 0, 0, 0, 0, 0), `01:10` = c(0, 0, 0, 0, 0, 0), `01:20` = c(0, 0, 0, 0, 0, 0), `01:30` = c(0, 0, 0, 0, 0, 0), `01:40` = c(0, 0, 0, 0, 0, 0), `01:50` = c(0, 0, 0, 0, 0, 0), `02:00` = c(0, 0, 0, 0, 0, 0), `02:10` = c(0, 0, 0, 0, 0, 0), `02:20` = c(0, 0, 0, 0, 0, 0), `02:30` = c(0, 0, 0, 0, 0, 0), `02:40` = c(0, 0, 0, 0, 0, 0), `02:50` = c(0, 0, 0, 0, 0, 0), `03:00` = c(0, 0, 0, 0, 0, 0), `03:10` = c(0, 0, 0, 0, 0, 0), `03:20` = c(0, 0, 0, 0, 0, 0), `03:30` = c(0, 0, 0, 0, 0, 0), `03:40` = c(0, 0, 0, 0, 0, 0), `03:50` = c(0, 0, 0, 0, 0, 0)), row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame") I managed to run hierarchical clustering but only on cases and not on time d_distance <- dist(as.matrix(df)) plot(hclust(d_distance)) The plot that I generated As you can see on the plot the structure end points are indexes - how can I have instead of index time (maybe transpose)? Also I would like to plot time-series cluster separately like below plot. Would dtw be better than hierarchical clustering?
weighted mean R
I was wondering how I can get the weighted average of my data. I have already looked on the internet, but when I try the weighted.mean function, I keep getting the same result, so I was wondering what I am doing wrong. Below is some information of the dataset: dput(head(new)) structure(list(comp.1 = c(0.5, 0.25, 0, 0.25, 0.31, 0.3), comp.2 = c(0.3, 0.15, 0, 0.15, 0, 0), comp.3 = c(0.2, 0.6, 1, 0.6, 0.69, 0.7), genderMale = c(0, 1, 1, 1, 0, 0), SeniorCitizen = c(0, 0, 0, 0, 0, 0), PartnerYes = c(1, 0, 0, 0, 0, 0), DependentsYes = c(0, 0, 0, 0, 0, 0), tenure = c(-1.28015700354285, 0.064298112878097, -1.23941593940889, 0.512449818351747, -1.23941593940889, -0.994969554605076), MultipleLinesYes = c(0, 0, 0, 0, 0, 1), `InternetServiceFiber optic` = c(0, 0, 0, 0, 1, 1), OnlineSecurityYes = c(0, 1, 1, 1, 0, 0), OnlineBackupYes = c(1, 0, 1, 0, 0, 0), DeviceProtectionYes = c(0, 1, 0, 1, 0, 1), TechSupportYes = c(0, 0, 0, 1, 0, 0), StreamingTVYes = c(0, 0, 0, 0, 0, 1), StreamingMoviesYes = c(0, 0, 0, 0, 0, 1), `ContractOne year` = c(0, 1, 0, 1, 0, 0), `ContractTwo year` = c(0, 0, 0, 0, 0, 0), PaperlessBillingYes = c(1, 0, 1, 0, 1, 1), `PaymentMethodCredit card (automatic)` = c(0, 0, 0, 0, 0, 0), `PaymentMethodElectronic check` = c(1, 0, 0, 0, 1, 1), `PaymentMethodMailed check` = c(0, 1, 1, 0, 0, 0), MonthlyCharges = c(-1.16161133177258, -0.260859369930086, -0.363897417225722, -0.747797238601399, 0.196164226945719, 1.15840663636787), TotalCharges = c(1.47494433546539, 3.27634689625303, 2.03402652377511, 3.26499480914874, 2.18084241464668, 2.91407858538911)), row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame") As you can see, I have 3 components (comp.1, comp.2, comp.3). All of these components have their posterior probabilities. And I am wondering how I can get the weighted averages for all of these and the final weighted averages. I have tried: weighted.mean(new$comp.1, new$SeniorCitizen) weighted.mean(new$comp.2, new$SeniorCitizen) weighted.mean(new$comp.3, new$SeniorCitizen) It gave me the output 0.24, 0.14 and 0.61. But irrespectively which variable I put, I get the same output. What am I doing wrong?
Sum columns of dataframe
I have dataframe with the following structure: structure(list(`Monday_04:00` = c(0, 0, 0), `Monday_04:15` = c(0, 0, 0), `Monday_04:30` = c(0, 0, 0), `Monday_04:45` = c(0, 0, 0), `Monday_05:00` = c(0, 0, 0), `Monday_05:15` = c(0, 0, 0), `Monday_05:30` = c(0, 0, 0), `Monday_05:45` = c(0, 0, 0), `Monday_06:00` = c(0, 0, 0), `Monday_06:15` = c(0, 0, 0), `Monday_06:30` = c(0, 0, 0), `Monday_06:45` = c(0, 0, 0), `Monday_07:00` = c(0, 0, 0), `Monday_07:15` = c(0, 0, 0), `Monday_07:30` = c(0, 0, 0), `Monday_07:45` = c(0, 0, 0), `Monday_08:00` = c(2, 0, 0), `Monday_08:15` = c(2, 0, 0), `Monday_08:30` = c(2, 0, 0), `Monday_08:45` = c(2, 0, 0), `Monday_09:00` = c(2, 0, 0), `Monday_09:15` = c(2, 0, 0), `Monday_09:30` = c(2, 0, 0), `Monday_09:45` = c(2, 0, 0), `Monday_10:00` = c(2, 0, 0), `Monday_10:15` = c(2, 0, 0), `Monday_10:30` = c(2, 0, 0), `Monday_10:45` = c(2, 0, 0), `Monday_11:00` = c(2, 0, 0), `Monday_11:15` = c(2, 0, 0), `Monday_11:30` = c(2, 0, 0), `Monday_11:45` = c(2, 0, 0), `Monday_12:00` = c(0, 0, 0), `Monday_12:15` = c(0, 0, 0), `Monday_12:30` = c(0, 0, 0), `Monday_12:45` = c(0, 0, 0), `Monday_13:00` = c(2, 0, 0), `Monday_13:15` = c(2, 0, 0), `Monday_13:30` = c(2, 0, 0), `Monday_13:45` = c(2, 0, 0), `Monday_14:00` = c(2, 0, 0), `Monday_14:15` = c(2, 0, 0), `Monday_14:30` = c(2, 0, 0), `Monday_14:45` = c(2, 0, 0), `Monday_15:00` = c(2, 0, 0), `Monday_15:15` = c(2, 0, 0), `Monday_15:30` = c(2, 0, 0), `Monday_15:45` = c(2, 0, 0), `Monday_16:00` = c(2, 0, 0), `Monday_16:15` = c(2, 0, 0), `Monday_16:30` = c(2, 0, 0), `Monday_16:45` = c(2, 0, 0), `Monday_17:00` = c(2, 0, 0), `Monday_17:15` = c(2, 0, 0), `Monday_17:30` = c(2, 0, 0), `Monday_17:45` = c(2, 0, 0), `Monday_18:00` = c(2, 0, 0), `Monday_18:15` = c(2, 0, 0), `Monday_18:30` = c(0, 0, 0), `Monday_18:45` = c(0, 0, 0), `Monday_19:00` = c(0, 0, 0), `Monday_19:15` = c(0, 0, 0), `Monday_19:30` = c(0, 0, 0), `Monday_19:45` = c(0, 0, 0), `Monday_20:00` = c(0, 0, 0), `Monday_20:15` = c(0, 0, 0), `Monday_20:30` = c(0, 0, 0), `Monday_20:45` = c(0, 0, 0), `Monday_21:00` = c(0, 0, 0), `Monday_21:15` = c(0, 0, 0), `Monday_21:30` = c(0, 0, 0), `Monday_21:45` = c(0, 0, 0), `Monday_22:00` = c(0, 0, 0), `Monday_22:15` = c(0, 0, 0), `Monday_22:30` = c(0, 0, 0), `Monday_22:45` = c(0, 0, 0), `Monday_23:00` = c(0, 0, 0), `Monday_23:15` = c(0, 0, 0), `Monday_23:30` = c(0, 0, 0), `Monday_23:45` = c(0, 0, 0), `Monday_00:00` = c(0, 0, 0), `Monday_00:15` = c(0, 0, 0), `Monday_00:30` = c(0, 0, 0), `Monday_00:45` = c(0, 0, 0), `Monday_01:00` = c(0, 0, 0), `Monday_01:15` = c(0, 0, 0), `Monday_01:30` = c(0, 0, 0), `Monday_01:45` = c(0, 0, 0), `Monday_02:00` = c(0, 0, 0), `Monday_02:15` = c(0, 0, 0), `Monday_02:30` = c(0, 0, 0), `Monday_02:45` = c(0, 0, 0), `Monday_03:00` = c(0, 0, 0), `Monday_03:15` = c(0, 0, 0), `Monday_03:30` = c(0, 0, 0), `Monday_03:45` = c(0, 0, 0), `Tuesday_04:00` = c(0, 0, 0), `Tuesday_04:15` = c(0, 0, 0 ), `Tuesday_04:30` = c(0, 0, 0), `Tuesday_04:45` = c(0, 0, 0), `Tuesday_05:00` = c(0, 0, 0), `Tuesday_05:15` = c(0, 0, 0), `Tuesday_05:30` = c(0, 0, 0), `Tuesday_05:45` = c(0, 0, 0), `Tuesday_06:00` = c(0, 0, 0), `Tuesday_06:15` = c(0, 0, 0), `Tuesday_06:30` = c(0, 0, 0), `Tuesday_06:45` = c(0, 0, 0), `Tuesday_07:00` = c(0, 0, 0), `Tuesday_07:15` = c(0, 0, 0), `Tuesday_07:30` = c(0, 0, 0), `Tuesday_07:45` = c(0, 0, 0), `Tuesday_08:00` = c(2, 0, 0), `Tuesday_08:15` = c(2, 0, 0), `Tuesday_08:30` = c(2, 0, 2), `Tuesday_08:45` = c(2, 0, 2), `Tuesday_09:00` = c(2, 0, 2), `Tuesday_09:15` = c(2, 0, 2), `Tuesday_09:30` = c(2, 0, 2), `Tuesday_09:45` = c(2, 0, 2), `Tuesday_10:00` = c(2, 0, 2), `Tuesday_10:15` = c(2, 0, 2), `Tuesday_10:30` = c(2, 0, 2), `Tuesday_10:45` = c(2, 0, 2), `Tuesday_11:00` = c(2, 0, 2), `Tuesday_11:15` = c(2, 0, 2), `Tuesday_11:30` = c(2, 0, 2), `Tuesday_11:45` = c(2, 0, 2), `Tuesday_12:00` = c(0, 0, 2), `Tuesday_12:15` = c(0, 0, 2), `Tuesday_12:30` = c(0, 0, 2), `Tuesday_12:45` = c(0, 0, 2), `Tuesday_13:00` = c(2, 0, 2), `Tuesday_13:15` = c(2, 0, 2), `Tuesday_13:30` = c(2, 0, 2), `Tuesday_13:45` = c(2, 0, 2), `Tuesday_14:00` = c(2, 0, 2), `Tuesday_14:15` = c(2, 0, 2), `Tuesday_14:30` = c(2, 0, 2), `Tuesday_14:45` = c(2, 0, 2), `Tuesday_15:00` = c(2, 0, 2), `Tuesday_15:15` = c(2, 0, 2), `Tuesday_15:30` = c(2, 0, 2), `Tuesday_15:45` = c(2, 0, 0), `Tuesday_16:00` = c(2, 0, 0), `Tuesday_16:15` = c(2, 0, 0), `Tuesday_16:30` = c(2, 0, 0), `Tuesday_16:45` = c(2, 0, 0), `Tuesday_17:00` = c(2, 0, 0), `Tuesday_17:15` = c(2, 0, 0), `Tuesday_17:30` = c(2, 0, 0), `Tuesday_17:45` = c(2, 0, 0), `Tuesday_18:00` = c(2, 0, 0), `Tuesday_18:15` = c(2, 0, 0), `Tuesday_18:30` = c(0, 0, 0), `Tuesday_18:45` = c(0, 0, 0), `Tuesday_19:00` = c(0, 0, 0), `Tuesday_19:15` = c(0, 0, 0), `Tuesday_19:30` = c(0, 0, 0), `Tuesday_19:45` = c(0, 0, 0), `Tuesday_20:00` = c(0, 0, 0), `Tuesday_20:15` = c(0, 0, 0), `Tuesday_20:30` = c(0, 0, 0), `Tuesday_20:45` = c(0, 0, 0), `Tuesday_21:00` = c(0, 0, 0), `Tuesday_21:15` = c(0, 0, 0), `Tuesday_21:30` = c(0, 0, 0), `Tuesday_21:45` = c(0, 0, 0), `Tuesday_22:00` = c(0, 0, 0), `Tuesday_22:15` = c(0, 0, 0), `Tuesday_22:30` = c(0, 0, 0), `Tuesday_22:45` = c(0, 0, 0), `Tuesday_23:00` = c(0, 0, 0), `Tuesday_23:15` = c(0, 0, 0), `Tuesday_23:30` = c(0, 0, 0), `Tuesday_23:45` = c(0, 0, 0), `Tuesday_00:00` = c(0, 0, 0), `Tuesday_00:15` = c(0, 0, 0), `Tuesday_00:30` = c(0, 0, 0), `Tuesday_00:45` = c(0, 0, 0), `Tuesday_01:00` = c(0, 0, 0), `Tuesday_01:15` = c(0, 0, 0), `Tuesday_01:30` = c(0, 0, 0), `Tuesday_01:45` = c(0, 0, 0), `Tuesday_02:00` = c(0, 0, 0), `Tuesday_02:15` = c(0, 0, 0), `Tuesday_02:30` = c(0, 0, 0), `Tuesday_02:45` = c(0, 0, 0), `Tuesday_03:00` = c(0, 0, 0), `Tuesday_03:15` = c(0, 0, 0), `Tuesday_03:30` = c(0, 0, 0), `Tuesday_03:45` = c(0, 0, 0), `Wednesday_04:00` = c(0, 0, 0), `Wednesday_04:15` = c(0, 0, 0), `Wednesday_04:30` = c(0, 0, 0), `Wednesday_04:45` = c(0, 0, 0), `Wednesday_05:00` = c(0, 0, 0), `Wednesday_05:15` = c(0, 0, 0), `Wednesday_05:30` = c(0, 0, 0), `Wednesday_05:45` = c(0, 0, 0), `Wednesday_06:00` = c(0, 0, 0), `Wednesday_06:15` = c(0, 0, 0), `Wednesday_06:30` = c(0, 0, 0), `Wednesday_06:45` = c(0, 0, 0), `Wednesday_07:00` = c(0, 0, 0), `Wednesday_07:15` = c(0, 0, 0), `Wednesday_07:30` = c(0, 0, 0), `Wednesday_07:45` = c(0, 0, 0), `Wednesday_08:00` = c(0, 0, 2), `Wednesday_08:15` = c(0, 0, 2), `Wednesday_08:30` = c(0, 0, 2), `Wednesday_08:45` = c(0, 0, 2), `Wednesday_09:00` = c(0, 0, 2), `Wednesday_09:15` = c(0, 0, 2), `Wednesday_09:30` = c(0, 0, 2), `Wednesday_09:45` = c(0, 0, 2), `Wednesday_10:00` = c(0, 0, 2), `Wednesday_10:15` = c(0, 0, 2), `Wednesday_10:30` = c(0, 0, 2), `Wednesday_10:45` = c(0, 0, 2), `Wednesday_11:00` = c(0, 0, 2), `Wednesday_11:15` = c(0, 0, 2), `Wednesday_11:30` = c(0, 0, 2), `Wednesday_11:45` = c(0, 0, 2), `Wednesday_12:00` = c(0, 0, 2), `Wednesday_12:15` = c(0, 0, 2), `Wednesday_12:30` = c(0, 0, 2), `Wednesday_12:45` = c(0, 0, 2), `Wednesday_13:00` = c(0, 0, 2), `Wednesday_13:15` = c(0, 0, 2), `Wednesday_13:30` = c(0, 0, 2), `Wednesday_13:45` = c(0, 0, 2), `Wednesday_14:00` = c(0, 0, 2), `Wednesday_14:15` = c(0, 0, 2), `Wednesday_14:30` = c(0, 0, 2), `Wednesday_14:45` = c(0, 0, 2), `Wednesday_15:00` = c(0, 0, 2), `Wednesday_15:15` = c(0, 0, 2), `Wednesday_15:30` = c(0, 0, 2), `Wednesday_15:45` = c(0, 0, 2), `Wednesday_16:00` = c(0, 0, 2), `Wednesday_16:15` = c(0, 0, 2), `Wednesday_16:30` = c(0, 0, 2), `Wednesday_16:45` = c(0, 0, 2), `Wednesday_17:00` = c(0, 0, 2), `Wednesday_17:15` = c(0, 0, 2), `Wednesday_17:30` = c(0, 0, 0), `Wednesday_17:45` = c(0, 0, 0), `Wednesday_18:00` = c(0, 0, 0), `Wednesday_18:15` = c(0, 0, 0), `Wednesday_18:30` = c(0, 0, 0), `Wednesday_18:45` = c(0, 0, 0), `Wednesday_19:00` = c(0, 0, 0), `Wednesday_19:15` = c(0, 0, 0), `Wednesday_19:30` = c(0, 0, 0), `Wednesday_19:45` = c(0, 0, 0), `Wednesday_20:00` = c(0, 0, 0), `Wednesday_20:15` = c(0, 0, 0), `Wednesday_20:30` = c(0, 0, 0), `Wednesday_20:45` = c(0, 0, 0), `Wednesday_21:00` = c(0, 0, 0), `Wednesday_21:15` = c(0, 0, 0), `Wednesday_21:30` = c(0, 0, 0), `Wednesday_21:45` = c(0, 0, 0), `Wednesday_22:00` = c(0, 0, 0), `Wednesday_22:15` = c(0, 0, 0), `Wednesday_22:30` = c(0, 0, 0), `Wednesday_22:45` = c(0, 0, 0), `Wednesday_23:00` = c(0, 0, 0), `Wednesday_23:15` = c(0, 0, 0), `Wednesday_23:30` = c(0, 0, 0), `Wednesday_23:45` = c(0, 0, 0), `Wednesday_00:00` = c(0, 0, 0), `Wednesday_00:15` = c(0, 0, 0), `Wednesday_00:30` = c(0, 0, 0), `Wednesday_00:45` = c(0, 0, 0), `Wednesday_01:00` = c(0, 0, 0), `Wednesday_01:15` = c(0, 0, 0), `Wednesday_01:30` = c(0, 0, 0), `Wednesday_01:45` = c(0, 0, 0), `Wednesday_02:00` = c(0, 0, 0), `Wednesday_02:15` = c(0, 0, 0), `Wednesday_02:30` = c(0, 0, 0), `Wednesday_02:45` = c(0, 0, 0), `Wednesday_03:00` = c(0, 0, 0), `Wednesday_03:15` = c(0, 0, 0), `Wednesday_03:30` = c(0, 0, 0), `Wednesday_03:45` = c(0, 0, 0), `Thursday_04:00` = c(0, 0, 0), `Thursday_04:15` = c(0, 0, 0), `Thursday_04:30` = c(0, 0, 0), `Thursday_04:45` = c(0, 0, 0), `Thursday_05:00` = c(0, 0, 0), `Thursday_05:15` = c(0, 0, 0), `Thursday_05:30` = c(0, 0, 0), `Thursday_05:45` = c(0, 0, 0), `Thursday_06:00` = c(0, 0, 0), `Thursday_06:15` = c(0, 0, 0), `Thursday_06:30` = c(0, 0, 0), `Thursday_06:45` = c(0, 0, 0), `Thursday_07:00` = c(0, 0, 0), `Thursday_07:15` = c(0, 0, 0), `Thursday_07:30` = c(0, 0, 0), `Thursday_07:45` = c(0, 0, 0), `Thursday_08:00` = c(0, 0, 0), `Thursday_08:15` = c(0, 0, 0), `Thursday_08:30` = c(0, 0, 2), `Thursday_08:45` = c(0, 0, 2), `Thursday_09:00` = c(0, 0, 2), `Thursday_09:15` = c(0, 0, 2), `Thursday_09:30` = c(0, 0, 2), `Thursday_09:45` = c(0, 0, 2), `Thursday_10:00` = c(0, 0, 2), `Thursday_10:15` = c(0, 0, 2), `Thursday_10:30` = c(0, 0, 2), `Thursday_10:45` = c(0, 0, 2), `Thursday_11:00` = c(0, 0, 2), `Thursday_11:15` = c(0, 0, 2), `Thursday_11:30` = c(0, 0, 2), `Thursday_11:45` = c(0, 0, 2), `Thursday_12:00` = c(0, 0, 2), `Thursday_12:15` = c(0, 0, 2), `Thursday_12:30` = c(0, 0, 2), `Thursday_12:45` = c(0, 0, 2), `Thursday_13:00` = c(0, 0, 2), `Thursday_13:15` = c(0, 0, 2), `Thursday_13:30` = c(0, 0, 2), `Thursday_13:45` = c(0, 0, 2), `Thursday_14:00` = c(0, 0, 2), `Thursday_14:15` = c(0, 0, 2), `Thursday_14:30` = c(0, 0, 2), `Thursday_14:45` = c(0, 0, 2), `Thursday_15:00` = c(0, 0, 2), `Thursday_15:15` = c(0, 0, 2), `Thursday_15:30` = c(0, 0, 2), `Thursday_15:45` = c(0, 0, 2), `Thursday_16:00` = c(0, 0, 2), `Thursday_16:15` = c(0, 0, 2), `Thursday_16:30` = c(0, 0, 2), `Thursday_16:45` = c(0, 0, 2), `Thursday_17:00` = c(0, 0, 0), `Thursday_17:15` = c(0, 0, 0), `Thursday_17:30` = c(0, 0, 0), `Thursday_17:45` = c(0, 0, 0), `Thursday_18:00` = c(0, 0, 0), `Thursday_18:15` = c(0, 0, 0), `Thursday_18:30` = c(0, 0, 0), `Thursday_18:45` = c(0, 0, 0), `Thursday_19:00` = c(0, 0, 0), `Thursday_19:15` = c(0, 0, 0), `Thursday_19:30` = c(0, 0, 0), `Thursday_19:45` = c(0, 0, 0), `Thursday_20:00` = c(0, 0, 0), `Thursday_20:15` = c(0, 0, 0), `Thursday_20:30` = c(0, 0, 0), `Thursday_20:45` = c(0, 0, 0), `Thursday_21:00` = c(0, 0, 0), `Thursday_21:15` = c(0, 0, 0), `Thursday_21:30` = c(0, 0, 0), `Thursday_21:45` = c(0, 0, 0), `Thursday_22:00` = c(0, 0, 0), `Thursday_22:15` = c(0, 0, 0), `Thursday_22:30` = c(0, 0, 0), `Thursday_22:45` = c(0, 0, 0), `Thursday_23:00` = c(0, 0, 0), `Thursday_23:15` = c(0, 0, 0), `Thursday_23:30` = c(0, 0, 0), `Thursday_23:45` = c(0, 0, 0), `Thursday_00:00` = c(0, 0, 0), `Thursday_00:15` = c(0, 0, 0), `Thursday_00:30` = c(0, 0, 0), `Thursday_00:45` = c(0, 0, 0), `Thursday_01:00` = c(0, 0, 0), `Thursday_01:15` = c(0, 0, 0), `Thursday_01:30` = c(0, 0, 0), `Thursday_01:45` = c(0, 0, 0), `Thursday_02:00` = c(0, 0, 0), `Thursday_02:15` = c(0, 0, 0), `Thursday_02:30` = c(0, 0, 0), `Thursday_02:45` = c(0, 0, 0), `Thursday_03:00` = c(0, 0, 0), `Thursday_03:15` = c(0, 0, 0), `Thursday_03:30` = c(0, 0, 0), `Thursday_03:45` = c(0, 0, 0), `Friday_04:00` = c(0, 0, 0), `Friday_04:15` = c(0, 0, 0), `Friday_04:30` = c(0, 0, 0), `Friday_04:45` = c(0, 0, 0), `Friday_05:00` = c(0, 0, 0), `Friday_05:15` = c(0, 0, 0), `Friday_05:30` = c(0, 0, 0), `Friday_05:45` = c(0, 0, 0), `Friday_06:00` = c(0, 0, 0), `Friday_06:15` = c(0, 0, 0), `Friday_06:30` = c(0, 0, 0), `Friday_06:45` = c(0, 0, 0), `Friday_07:00` = c(0, 0, 0), `Friday_07:15` = c(0, 0, 0), `Friday_07:30` = c(0, 0, 0), `Friday_07:45` = c(0, 0, 0), `Friday_08:00` = c(0, 0, 0), `Friday_08:15` = c(2, 0, 0), `Friday_08:30` = c(2, 0, 2), `Friday_08:45` = c(2, 0, 2), `Friday_09:00` = c(2, 0, 2), `Friday_09:15` = c(2, 0, 2), `Friday_09:30` = c(2, 0, 2), `Friday_09:45` = c(2, 0, 2), `Friday_10:00` = c(2, 0, 2), `Friday_10:15` = c(2, 0, 2), `Friday_10:30` = c(2, 0, 2), `Friday_10:45` = c(2, 0, 2), `Friday_11:00` = c(2, 0, 2), `Friday_11:15` = c(2, 0, 2), `Friday_11:30` = c(2, 0, 0), `Friday_11:45` = c(2, 0, 0), `Friday_12:00` = c(0, 0, 0), `Friday_12:15` = c(0, 0, 0), `Friday_12:30` = c(0, 0, 0), `Friday_12:45` = c(0, 0, 0), `Friday_13:00` = c(0, 0, 0), `Friday_13:15` = c(2, 0, 0), `Friday_13:30` = c(2, 0, 0), `Friday_13:45` = c(2, 0, 0), `Friday_14:00` = c(2, 0, 0), `Friday_14:15` = c(2, 0, 0), `Friday_14:30` = c(2, 2, 0), `Friday_14:45` = c(2, 2, 0), `Friday_15:00` = c(2, 2, 0), `Friday_15:15` = c(2, 2, 0), `Friday_15:30` = c(2, 2, 0), `Friday_15:45` = c(2, 2, 0), `Friday_16:00` = c(2, 2, 0), `Friday_16:15` = c(2, 2, 0), `Friday_16:30` = c(2, 2, 0), `Friday_16:45` = c(2, 2, 0), `Friday_17:00` = c(2, 2, 0), `Friday_17:15` = c(2, 2, 0), `Friday_17:30` = c(2, 2, 0), `Friday_17:45` = c(2, 2, 0), `Friday_18:00` = c(2, 2, 0), `Friday_18:15` = c(0, 2, 0), `Friday_18:30` = c(0, 2, 0), `Friday_18:45` = c(0, 2, 0), `Friday_19:00` = c(0, 2, 0), `Friday_19:15` = c(0, 2, 0), `Friday_19:30` = c(0, 0, 0), `Friday_19:45` = c(0, 0, 0), `Friday_20:00` = c(0, 0, 0), `Friday_20:15` = c(0, 0, 0), `Friday_20:30` = c(0, 0, 0), `Friday_20:45` = c(0, 0, 0), `Friday_21:00` = c(0, 0, 0), `Friday_21:15` = c(0, 0, 0), `Friday_21:30` = c(0, 0, 0), `Friday_21:45` = c(0, 0, 0), `Friday_22:00` = c(0, 0, 0), `Friday_22:15` = c(0, 0, 0), `Friday_22:30` = c(0, 0, 0), `Friday_22:45` = c(0, 0, 0), `Friday_23:00` = c(0, 0, 0), `Friday_23:15` = c(0, 0, 0), `Friday_23:30` = c(0, 0, 0), `Friday_23:45` = c(0, 0, 0), `Friday_00:00` = c(0, 0, 0), `Friday_00:15` = c(0, 0, 0), `Friday_00:30` = c(0, 0, 0), `Friday_00:45` = c(0, 0, 0), `Friday_01:00` = c(0, 0, 0), `Friday_01:15` = c(0, 0, 0), `Friday_01:30` = c(0, 0, 0), `Friday_01:45` = c(0, 0, 0), `Friday_02:00` = c(0, 0, 0), `Friday_02:15` = c(0, 0, 0), `Friday_02:30` = c(0, 0, 0), `Friday_02:45` = c(0, 0, 0), `Friday_03:00` = c(0, 0, 0), `Friday_03:15` = c(0, 0, 0), `Friday_03:30` = c(0, 0, 0), `Friday_03:45` = c(0, 0, 0), `Saturday_04:00` = c(0, 0, 0), `Saturday_04:15` = c(0, 0, 0), `Saturday_04:30` = c(0, 0, 0), `Saturday_04:45` = c(0, 0, 0), `Saturday_05:00` = c(0, 0, 0), `Saturday_05:15` = c(0, 0, 0), `Saturday_05:30` = c(0, 0, 0), `Saturday_05:45` = c(0, 0, 0), `Saturday_06:00` = c(0, 0, 0), `Saturday_06:15` = c(0, 0, 0), `Saturday_06:30` = c(0, 0, 0), `Saturday_06:45` = c(0, 0, 0), `Saturday_07:00` = c(0, 0, 0), `Saturday_07:15` = c(0, 0, 0), `Saturday_07:30` = c(0, 0, 0), `Saturday_07:45` = c(0, 0, 0), `Saturday_08:00` = c(0, 0, 0), `Saturday_08:15` = c(2, 0, 0), `Saturday_08:30` = c(2, 0, 0), `Saturday_08:45` = c(2, 0, 0), `Saturday_09:00` = c(2, 0, 0), `Saturday_09:15` = c(2, 0, 0), `Saturday_09:30` = c(2, 0, 0), `Saturday_09:45` = c(2, 0, 0), `Saturday_10:00` = c(2, 0, 0), `Saturday_10:15` = c(2, 0, 0), `Saturday_10:30` = c(2, 0, 0), `Saturday_10:45` = c(2, 0, 0), `Saturday_11:00` = c(2, 0, 0), `Saturday_11:15` = c(2, 0, 0), `Saturday_11:30` = c(2, 0, 0), `Saturday_11:45` = c(2, 0, 0), `Saturday_12:00` = c(0, 0, 0), `Saturday_12:15` = c(0, 0, 0), `Saturday_12:30` = c(0, 0, 0), `Saturday_12:45` = c(0, 0, 0), `Saturday_13:00` = c(2, 0, 0), `Saturday_13:15` = c(2, 0, 0), `Saturday_13:30` = c(2, 0, 0), `Saturday_13:45` = c(2, 0, 0), `Saturday_14:00` = c(2, 0, 0), `Saturday_14:15` = c(2, 0, 0), `Saturday_14:30` = c(2, 0, 0), `Saturday_14:45` = c(2, 0, 0), `Saturday_15:00` = c(2, 0, 0), `Saturday_15:15` = c(2, 0, 0), `Saturday_15:30` = c(2, 0, 0), `Saturday_15:45` = c(2, 0, 0), `Saturday_16:00` = c(2, 0, 0), `Saturday_16:15` = c(2, 0, 0), `Saturday_16:30` = c(2, 0, 0), `Saturday_16:45` = c(2, 0, 0), `Saturday_17:00` = c(2, 0, 0), `Saturday_17:15` = c(2, 0, 0), `Saturday_17:30` = c(2, 0, 0), `Saturday_17:45` = c(2, 0, 0), `Saturday_18:00` = c(2, 0, 0), `Saturday_18:15` = c(0, 0, 0), `Saturday_18:30` = c(0, 0, 0), `Saturday_18:45` = c(0, 0, 0), `Saturday_19:00` = c(0, 0, 0), `Saturday_19:15` = c(0, 0, 0), `Saturday_19:30` = c(0, 0, 0), `Saturday_19:45` = c(0, 0, 0), `Saturday_20:00` = c(0, 0, 0), `Saturday_20:15` = c(0, 0, 0), `Saturday_20:30` = c(0, 0, 0), `Saturday_20:45` = c(0, 0, 0), `Saturday_21:00` = c(0, 0, 0), `Saturday_21:15` = c(0, 0, 0), `Saturday_21:30` = c(0, 0, 0), `Saturday_21:45` = c(0, 0, 0), `Saturday_22:00` = c(0, 0, 0), `Saturday_22:15` = c(0, 0, 0), `Saturday_22:30` = c(0, 0, 0), `Saturday_22:45` = c(0, 0, 0), `Saturday_23:00` = c(0, 0, 0), `Saturday_23:15` = c(0, 0, 0), `Saturday_23:30` = c(0, 0, 0), `Saturday_23:45` = c(0, 0, 0), `Saturday_00:00` = c(0, 0, 0), `Saturday_00:15` = c(0, 0, 0), `Saturday_00:30` = c(0, 0, 0), `Saturday_00:45` = c(0, 0, 0), `Saturday_01:00` = c(0, 0, 0), `Saturday_01:15` = c(0, 0, 0), `Saturday_01:30` = c(0, 0, 0), `Saturday_01:45` = c(0, 0, 0), `Saturday_02:00` = c(0, 0, 0), `Saturday_02:15` = c(0, 0, 0), `Saturday_02:30` = c(0, 0, 0), `Saturday_02:45` = c(0, 0, 0), `Saturday_03:00` = c(0, 0, 0), `Saturday_03:15` = c(0, 0, 0), `Saturday_03:30` = c(0, 0, 0), `Saturday_03:45` = c(0, 0, 0), `Sunday_04:00` = c(0, 0, 0), `Sunday_04:15` = c(0, 0, 0), `Sunday_04:30` = c(0, 0, 0), `Sunday_04:45` = c(0, 0, 0), `Sunday_05:00` = c(0, 0, 0), `Sunday_05:15` = c(0, 0, 0), `Sunday_05:30` = c(0, 0, 0), `Sunday_05:45` = c(0, 0, 0), `Sunday_06:00` = c(0, 0, 0), `Sunday_06:15` = c(0, 0, 0), `Sunday_06:30` = c(0, 0, 0), `Sunday_06:45` = c(0, 0, 0), `Sunday_07:00` = c(0, 0, 0), `Sunday_07:15` = c(0, 0, 0), `Sunday_07:30` = c(0, 0, 0), `Sunday_07:45` = c(0, 0, 0), `Sunday_08:00` = c(2, 0, 0), `Sunday_08:15` = c(2, 0, 0), `Sunday_08:30` = c(2, 0, 0), `Sunday_08:45` = c(2, 0, 0), `Sunday_09:00` = c(2, 0, 0), `Sunday_09:15` = c(2, 0, 0), `Sunday_09:30` = c(2, 0, 0), `Sunday_09:45` = c(2, 0, 0), `Sunday_10:00` = c(2, 0, 0), `Sunday_10:15` = c(2, 0, 0), `Sunday_10:30` = c(2, 0, 0), `Sunday_10:45` = c(2, 0, 0), `Sunday_11:00` = c(2, 0, 0), `Sunday_11:15` = c(2, 0, 0), `Sunday_11:30` = c(2, 0, 0), `Sunday_11:45` = c(2, 0, 0), `Sunday_12:00` = c(2, 0, 0), `Sunday_12:15` = c(2, 0, 0), `Sunday_12:30` = c(2, 0, 0), `Sunday_12:45` = c(2, 0, 0), `Sunday_13:00` = c(0, 0, 0), `Sunday_13:15` = c(0, 0, 0), `Sunday_13:30` = c(0, 0, 0), `Sunday_13:45` = c(0, 0, 0), `Sunday_14:00` = c(2, 0, 0), `Sunday_14:15` = c(2, 0, 0), `Sunday_14:30` = c(2, 0, 0), `Sunday_14:45` = c(2, 0, 0), `Sunday_15:00` = c(2, 0, 0), `Sunday_15:15` = c(2, 0, 0), `Sunday_15:30` = c(2, 0, 0), `Sunday_15:45` = c(2, 0, 0), `Sunday_16:00` = c(2, 0, 0), `Sunday_16:15` = c(2, 0, 0), `Sunday_16:30` = c(2, 0, 0), `Sunday_16:45` = c(2, 0, 0), `Sunday_17:00` = c(2, 0, 0), `Sunday_17:15` = c(2, 0, 0), `Sunday_17:30` = c(0, 0, 0), `Sunday_17:45` = c(0, 0, 0), `Sunday_18:00` = c(0, 0, 0), `Sunday_18:15` = c(0, 0, 0), `Sunday_18:30` = c(0, 0, 0), `Sunday_18:45` = c(0, 0, 0), `Sunday_19:00` = c(0, 0, 0), `Sunday_19:15` = c(0, 0, 0), `Sunday_19:30` = c(0, 0, 0), `Sunday_19:45` = c(0, 0, 0), `Sunday_20:00` = c(0, 0, 0), `Sunday_20:15` = c(0, 0, 0), `Sunday_20:30` = c(0, 0, 0), `Sunday_20:45` = c(0, 0, 0), `Sunday_21:00` = c(0, 0, 0), `Sunday_21:15` = c(0, 0, 0), `Sunday_21:30` = c(0, 0, 0), `Sunday_21:45` = c(0, 0, 0), `Sunday_22:00` = c(0, 0, 0), `Sunday_22:15` = c(0, 0, 0), `Sunday_22:30` = c(0, 0, 0), `Sunday_22:45` = c(0, 0, 0), `Sunday_23:00` = c(0, 0, 0), `Sunday_23:15` = c(0, 0, 0), `Sunday_23:30` = c(0, 0, 0), `Sunday_23:45` = c(0, 0, 0), `Sunday_00:00` = c(0, 0, 0), `Sunday_00:15` = c(0, 0, 0), `Sunday_00:30` = c(0, 0, 0), `Sunday_00:45` = c(0, 0, 0), `Sunday_01:00` = c(0, 0, 0), `Sunday_01:15` = c(0, 0, 0), `Sunday_01:30` = c(0, 0, 0), `Sunday_01:45` = c(0, 0, 0), `Sunday_02:00` = c(0, 0, 0), `Sunday_02:15` = c(0, 0, 0), `Sunday_02:30` = c(0, 0, 0), `Sunday_02:45` = c(0, 0, 0), `Sunday_03:00` = c(0, 0, 0), `Sunday_03:15` = c(0, 0, 0), `Sunday_03:30` = c(0, 0, 0), `Sunday_03:45` = c(0, 0, 0), index = 1:3), row.names = c(NA, 3L), class = "data.frame") > The first row (rn)contains numbers from 2 to 3523. The other 672 columns are time steps that record people works chedules: 0 - not worked and 2 - worked I am trying to calculate: a.) daily workhours per id (sum of 95 columns/day). b.) weekly workhours per id Any suggestion is welcomed
I would use tidyr and dplyr to go from wide to long format and then group_by and summarize. Try this: library(tidyverse) df %>% gather(day_time, worked, -index) %>% separate(day_time, c("day", "time"), "_") %>% group_by(index, day) %>% summarize(tot_work = sum(worked)/2*15/60) #> # A tibble: 21 x 3 #> # Groups: index [?] #> index day tot_work #> <int> <chr> <dbl> #> 1 1 Friday 8.75 #> 2 1 Monday 9.5 #> 3 1 Saturday 9 #> 4 1 Sunday 8.5 #> 5 1 Thursday 0 #> 6 1 Tuesday 9.5 #> 7 1 Wednesday 0 #> 8 2 Friday 5 #> 9 2 Monday 0 #> 10 2 Saturday 0 #> # … with 11 more rows df %>% gather(day_time, worked, -index) %>% separate(day_time, c("day", "time"), "_") %>% group_by(index) %>% summarize(tot_work = sum(worked)/2 * 15 / 60) # divided by 2 * 15 min and divided by 60 min to have everything in hours #> # A tibble: 3 x 2 #> index tot_work #> <int> <dbl> #> 1 1 45.2 #> 2 2 5 #> 3 3 28.2 If you want everything in minutes do not divide by 60.
Consider reshaping your data from the current wide format to long format. This is the ideal structure for most data analytics including aggregation and a storage efficient format as columns necessitate more meta data (i.e., tracking types) than rows. # RESHAPE WIDE TO LONG rdf <- reshape(df, idvar="index", varying=list(head(names(df),-1)), v.names="hours", times = head(names(df),-1), timevar = "day_time", new.row.names = 1:1E5, direction = "long") # SPLIT DAY AND TIME rdf[c("day", "time")] <- t(sapply(strsplit(rdf$day_time, split="_"), "[")) rdf$day_time <- NULL head(rdf, 10) # index hours day time # 1 1 0 Monday 04:00 # 2 2 0 Monday 04:00 # 3 3 0 Monday 04:00 # 4 1 0 Monday 04:15 # 5 2 0 Monday 04:15 # 6 3 0 Monday 04:15 # 7 1 0 Monday 04:30 # 8 2 0 Monday 04:30 # 9 3 0 Monday 04:30 # 10 1 0 Monday 04:45 # SUMMARIZE HOURS BY INDEX agg_df <- aggregate(hours ~ index, rdf, sum) agg_df # index hours # 1 1 362 # 2 2 40 # 3 3 226 By weekday: rdf$day <- factor(rdf$day, levels=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")) aggregate(hours ~ index + day, rdf, sum) # day index hours # 1 Monday 1 76 # 2 Tuesday 1 76 # 3 Wednesday 1 0 # 4 Thursday 1 0 # 5 Friday 1 70 # 6 Saturday 1 72 # 7 Sunday 1 68 # 8 Monday 2 0 # 9 Tuesday 2 0 # 10 Wednesday 2 0 # 11 Thursday 2 0 # 12 Friday 2 40 # 13 Saturday 2 0 # 14 Sunday 2 0 # 15 Monday 3 0 # 16 Tuesday 3 58 # 17 Wednesday 3 76 # 18 Thursday 3 68 # 19 Friday 3 24 # 20 Saturday 3 0 # 21 Sunday 3 0
Excluding one of the columns from the means calculating
I have a data.frame like this: > dput(head(dat)) structure(list(`Gene name` = c("at1g01050", "at1g01080", "at1g01090", "at1g01220", "at1g01320", "at1g01420"), `1_1` = c(0, 0, 0, 0, 0, 0), `1_2` = c(0, 0, 0, 0, 0, 0), `1_3` = c(0, 2.2266502274762, 0, 0, 0, 0), `1_4` = c(0, 1.42835007256373, 0, 0, 0, 0), `1_5` = c(0, 1, 0, 0, 0, 0.680307288653971), `1_6` = c(0, 0.974694551708235, 0.0703315834738149, 0, 0, 1.5411058346636), `1_7` = c(1, 1.06166030205396, 0, 0, 0, 0), `1_8` = c(1, 1.07309874414745, 0.129442847788922, 0, 0, 0), `1_9` = c(1.83566164452602, 0.770848509662441, 1.16522133036595, 1.02360016370994, 0, 0), `1_10` = c(0, 0, 0.96367393959757, 0, 0, 0), `1_11` = c(0, 1, 1.459452636222, 0, 0.992067202742928, 0), `1_12` = c(0, 0, 0.670100384155585, 0, 0.461601636474094, 0), `1_13` = c(0, 0, 1.43074917909221, 0, 1.35246977730244, 0 ), `1_14` = c(0, 0, 1.13052717277684, 0, 1.27971261718285, 0), `1_15` = c(0, 0, 0, 0, 0, 0), `1_16` = c(0, 0, 1.02186950513655, 0, 0.937805171752374, 0), `1_17` = c(0, 0, 0, 0, 1.82226410514639, 0), `1_18` = c(0, 0, 1.2057581396188, 0, 1, 0), `1_19` = c(0, 0, 2.54080080087007, 0, 1.74014162763125, 0), `1_20` = c(0, 0, 0, 0, 0, 0), `1_21` = c(0, 0, 1.85335086627868, 0, 2.93605031878879, 0), `1_22` = c(0, 0, 0, 0, 0, 0), `1_23` = c(0, 0, 0, 0, 0, 0), `1_24` = c(0, 0.59685787388353, 4.74450895485671, 0, 1.64665192735547, 0), `1_25` = c(0, 0, 0, 0, 0, 0), `1_26` = c(0, 0, 0, 0, 0, 0), `1_27` = c(0, 1.70324142554566, 0, 0, 0, 0), `1_28` = c(0, 4.02915818089525, 0, 0, 0, 0), `1_29` = c(0, 1.10050253348262, 0, 0, 0, 1.78705663080963), `1_30` = c(0, 0, 0, 0, 0, 0), `1_31` = c(0.525193634811661, 1.19203674964562, 0, 0, 0, 0), `1_32` = c(0.949695564218912, 0.511935958918944, 0.698256748091399, 0.924419021307232, 0, 0), `1_33` = c(1, 0.392202418854686, 0.981531026331928, 1, 0, 0), `1_34` = c(0, 0, 1.04480642952605, 0, 0, 0), `1_35` = c(0.875709646300199, 0.416787083481068, 0.910412293707794, 0, 0.931813162802324, 0), `1_36` = c(0.235817844851986, 0, 0.695496044366791, 0, 0, 0), `1_37` = c(0, 0, 0, 0, 0, 0), `1_38` = c(0, 0, 0, 0, 0, 0), `1_39` = c(0, 0, 0, 0, 0, 0), `1_40` = c(0, 0.426301584359177, 1.05916031917965, 0, 1.11716924423855, 0), `1_41` = c(0, 0, 0, 0, 0, 0), `1_42` = c(0, 0, 0, 0, 0, 0), `1_43` = c(0, 0, 0, 0, 0, 0), `1_44` = c(0, 0.817605484758179, 1, 0, 1, 0), `1_45` = c(0, 0, 0, 0, 1.83706702696725, 0), `1_46` = c(0, 0, 0, 0, 0, 0), `1_48` = c(0, 0, 0, 0, 0, 0), `1_49` = c(0, 0, 0, 0, 0, 0), `1_50` = c(0, 0, 0, 0, 0, 0), `1_51` = c(0, 0.822966241998042, 0, 0, 0, 0), `1_52` = c(0, 1.38548267401525, 0, 0, 0, 0), `1_53` = c(0, 0.693090058304095, 0, 0, 0, 1.200664746484 ), `1_54` = c(0, 7.58136662752864, 0, 0, 0, 0), `1_55` = c(0.519878111919004, 0.530809413647805, 0.343274113384907, 0, 0, 0), `1_56` = c(1.24511715957891, 0.545097856366912, 0.397440073804376, 0, 0, 0), `1_57` = c(1.26748496499576, 0.502893153188496, 1, 1.09278985531586, 0, 0), `1_58` = c(0.696198684496234, 0.68197003689249, 1.30108437738319, 0.778091049180591, 0.533017938104689, 0), `1_59` = c(1.15255606344999, 0.294294436704185, 1.07862692616479, 1, 0.250091116406616, 0), `1_60` = c(1.95634163405497, 0, 1.1602014253913, 0, 0, 0), `1_61` = c(1.09287167009628, 0, 2.05939536537347, 1.08165521287259, 0.68027384701565, 0), `1_62` = c(0.791776166968497, 0, 0.846107162142824, 0, 0.77013323652256, 0), `1_63` = c(0.378787010943447, 0.391876271945063, 0.623223753921758, 0, 0.651918444771296, 0), `1_64` = c(0.189585762007804, 0.361452381684218, 0.799519726870751, 0, 1.06818683719768, 0), `1_65` = c(0, 0, 2.5212953775211, 0, 0, 0), `1_66` = c(0, 0, 0, 0, 0, 0 ), `1_67` = c(0, 0, 0, 0, 2.44827717262786, 0), `1_68` = c(0, 0, 0, 0, 0, 0), `1_69` = c(0, 0, 0, 0, 0, 0), `1_70` = c(0, 0, 2.36142611074334, 0, 2.391093649557, 0), `1_71` = c(0, 0, 0.35565044656798, 0, 0, 0), `1_72` = c(0, 0, 5.86951313801941, 0, 0, 0)), .Names = c("Gene name", "1_1", "1_2", "1_3", "1_4", "1_5", "1_6", "1_7", "1_8", "1_9", "1_10", "1_11", "1_12", "1_13", "1_14", "1_15", "1_16", "1_17", "1_18", "1_19", "1_20", "1_21", "1_22", "1_23", "1_24", "1_25", "1_26", "1_27", "1_28", "1_29", "1_30", "1_31", "1_32", "1_33", "1_34", "1_35", "1_36", "1_37", "1_38", "1_39", "1_40", "1_41", "1_42", "1_43", "1_44", "1_45", "1_46", "1_48", "1_49", "1_50", "1_51", "1_52", "1_53", "1_54", "1_55", "1_56", "1_57", "1_58", "1_59", "1_60", "1_61", "1_62", "1_63", "1_64", "1_65", "1_66", "1_67", "1_68", "1_69", "1_70", "1_71", "1_72"), row.names = c(NA, 6L), class = "data.frame") That's the code I use for calculation of the mean for 3 replicates which I have in the data frame: ## Calculating the mean of 3 "replicates" ind <- c(1, 25, 49) dat2 <- dat[-1] tbl_end <- cbind(dat[1], sapply(0:23, function(i) rowMeans(dat2[ind+i]))) That's an error which comes: Error in `[.data.frame`(dat2, ind + i) : undefined columns selected Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)), envir = sys.frame(frame)) I have 71 columns of results (should be 72 because I have 24 fractions and 3 replicates what gives 72 in total) but there should be one more column. No idea why it's missing but anyway I have to solve it. There is no 1_47 which should come with 1_23 and 1_71. Do you have any idea how can I edit my function to just ignore fraction 1_47 and still get a mean of 1_23 and 1_71 ?
Why not just add in a dummy column for 1_47. That will make your data more regular and make it much easier to extract the indexes you need. To do this, try dat2<-cbind(dat[1:47], 1_47=rep(NA, nrow(dat)), dat[48:72]) ind <- c(1, 25, 49) tbl_end <- cbind(dat[1], sapply(0:23, function(i) rowMeans(dat2[ind+i+1], na.rm=T)))