我目前有一个矩阵如下:
mat
00:00 1
00:05 2
00:07 4
etc...
包含一天中某些感兴趣的事件发生的时间。但是,我希望在该矩阵的每一分钟都填充该表,从而生成如下矩阵:
mat
00:00 1
00:01 0
00:02 0
00:03 0
00:04 0
00:05 2
00:06 0
00:07 4
etc...
有没有一种简单的方法可以在 R 中做到这一点?
供您参考,`dput(head(mat))' 返回:
structure(list(Var1 = structure(1:6, .Label = c("00:00", "00:05",
"00:07", "05:52", "16:28", "19:34", "19:55", "20:01", "20:40",
"23:29", "23:56"), class = "factor"), Freq = c(1L, 2L, 4L, 1L,
1L, 1L)), .Names = c("Var1", "Freq"), row.names = c(NA, 6L), class = "data.frame")