我的数据框具有以下结构:
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")
>
第一行(rn)包含2到3523之间的数字。其他672列是记录人员工作时间表的时间步:0-不工作和2-工作
我试图计算:a。)每个id的每日工作时间(每天95列的总和)。 b。)每个id的每周工作时间
任何建议都受到欢迎
答案 0 :(得分:2)
我会使用tidyr
和dplyr
从宽格式转换为长格式,然后使用group_by
和summarize
。
尝试一下:
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
如果要在几分钟内完成所有操作,请不要除以60。
答案 1 :(得分:1)
请考虑将数据从当前的宽格式重整为长格式。这是大多数数据分析(包括聚合和高效存储格式)的理想结构,因为列比行需要更多的元数据(即跟踪类型)。
# 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
在工作日之前:
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