У меня есть метки времени начала и конца.
df <- structure(list(Vagt_Start = structure(c(1535412600, 1531006200,
1518823800, 1535671800, 1531092600, 1527550200, 1535499000, 1530919800,
1518910200, 1535585400), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
Vagt_Slut = structure(c(1535441400, 1531035000, 1518852600,
1535700600, 1531121400, 1527579000, 1535527800, 1530948600,
1518939000, 1535614200), class = c("POSIXct", "POSIXt"), tzone = "UTC")), .Names = c("start",
"end"), row.names = c(NA, -10L), class = c("tbl_df", "tbl",
"data.frame"))
Я хотел бы создать 24 новых столбца и поместить их в эти часы.Например, если первая строка имеет начало = 23: 30 и конец = 7: 30, я бы хотел поместить их в столбцы 23, 00, 01, ..., 07. Как мне записать все «часы» периодакресты.
новый набор данных с 100 строками:
df <- structure(list(start = structure(c(1514818800, 1514793600, 1514764800,
1514791800, 1514793600, 1514764800, 1514764800, 1514793600, 1514793600,
1514793600, 1514847600, 1514764800, 1514764800, 1514764800, 1514793600,
1514764800, 1514790000, 1514764800, 1514764800, 1514794500, 1514793600,
1514793600, 1514764800, 1514793600, 1514793600, 1514793600, 1514764800,
1514764800, 1514793600, 1514793600, 1514764800, 1514791800, 1514764800,
1514764800, 1514764800, 1514794500, 1514793600, 1514793600, 1514793600,
1514818800, 1514764800, 1514793600, 1514793600, 1514793600, 1514764800,
1514793600, 1514764800, 1514764800, 1514764800, 1514793600, 1514793600,
1514764800, 1514764800, 1514764800, 1514820600, 1514764800, 1514764800,
1514764800, 1514792700, 1514764800, 1514793600, 1514793600, 1514793600,
1514764800, 1514793600, 1514793600, 1514764800, 1514793600, 1514793600,
1514764800, 1514797200, 1514793600, 1514764800, 1514793600, 1514791800,
1514764800, 1514793600, 1514764800, 1514764800, 1514764800, 1514793600,
1514764800, 1514764800, 1514793600, 1514764800, 1514791800, 1514764800,
1514764800, 1514764800, 1514793600, 1514764800, 1514764800, 1514793600,
1514793600, 1514764800, 1514764800, 1514793600, 1514764800, 1514764800,
1514793600), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
end = structure(c(1514847600, 1514820600, 1514851200, 1514819700,
1514820600, 1514851200, 1514851200, 1514820240, 1514820600,
1514817000, 1514876400, 1514851200, 1514851200, 1514851200,
1514820600, 1514851200, 1514804400, 1514851200, 1514851200,
1514819700, 1514818800, 1514820600, 1514851200, 1514820600,
1514820600, 1514820600, 1514851200, 1514851200, 1514820600,
1514820240, 1514851200, 1514818800, 1514851200, 1514851200,
1514851200, 1514821500, 1514820600, 1514820240, 1514820240,
1514847600, 1514851200, 1514820600, 1514822400, 1514820600,
1514851200, 1514820600, 1514851200, 1514851200, 1514851200,
1514820600, 1514820600, 1514791800, 1514851200, 1514851200,
1514849400, 1514851200, 1514851200, 1514851200, 1514819340,
1514851200, 1514820240, 1514820600, 1514820600, 1514851200,
1514817000, 1514820240, 1514851200, 1514820600, 1514820240,
1514851200, 1514808000, 1514820600, 1514851200, 1514820600,
1514819700, 1514851200, 1514820240, 1514851200, 1514851200,
1514851200, 1514820600, 1514851200, 1514851200, 1514820600,
1514851200, 1514818800, 1514851200, 1514851200, 1514851200,
1514820600, 1514851200, 1514851200, 1514820600, 1514820600,
1514851200, 1514851200, 1514820600, 1514851200, 1514791800,
1514820600), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
startN = c(1514818800, 1514793600, 1514764800, 1514791800,
1514793600, 1514764800, 1514764800, 1514793600, 1514793600,
1514793600, 1514847600, 1514764800, 1514764800, 1514764800,
1514793600, 1514764800, 1514790000, 1514764800, 1514764800,
1514794500, 1514793600, 1514793600, 1514764800, 1514793600,
1514793600, 1514793600, 1514764800, 1514764800, 1514793600,
1514793600, 1514764800, 1514791800, 1514764800, 1514764800,
1514764800, 1514794500, 1514793600, 1514793600, 1514793600,
1514818800, 1514764800, 1514793600, 1514793600, 1514793600,
1514764800, 1514793600, 1514764800, 1514764800, 1514764800,
1514793600, 1514793600, 1514764800, 1514764800, 1514764800,
1514820600, 1514764800, 1514764800, 1514764800, 1514792700,
1514764800, 1514793600, 1514793600, 1514793600, 1514764800,
1514793600, 1514793600, 1514764800, 1514793600, 1514793600,
1514764800, 1514797200, 1514793600, 1514764800, 1514793600,
1514791800, 1514764800, 1514793600, 1514764800, 1514764800,
1514764800, 1514793600, 1514764800, 1514764800, 1514793600,
1514764800, 1514791800, 1514764800, 1514764800, 1514764800,
1514793600, 1514764800, 1514764800, 1514793600, 1514793600,
1514764800, 1514764800, 1514793600, 1514764800, 1514764800,
1514793600), endN = c(1514847600, 1514820600, 1514851200,
1514819700, 1514820600, 1514851200, 1514851200, 1514820240,
1514820600, 1514817000, 1514876400, 1514851200, 1514851200,
1514851200, 1514820600, 1514851200, 1514804400, 1514851200,
1514851200, 1514819700, 1514818800, 1514820600, 1514851200,
1514820600, 1514820600, 1514820600, 1514851200, 1514851200,
1514820600, 1514820240, 1514851200, 1514818800, 1514851200,
1514851200, 1514851200, 1514821500, 1514820600, 1514820240,
1514820240, 1514847600, 1514851200, 1514820600, 1514822400,
1514820600, 1514851200, 1514820600, 1514851200, 1514851200,
1514851200, 1514820600, 1514820600, 1514791800, 1514851200,
1514851200, 1514849400, 1514851200, 1514851200, 1514851200,
1514819340, 1514851200, 1514820240, 1514820600, 1514820600,
1514851200, 1514817000, 1514820240, 1514851200, 1514820600,
1514820240, 1514851200, 1514808000, 1514820600, 1514851200,
1514820600, 1514819700, 1514851200, 1514820240, 1514851200,
1514851200, 1514851200, 1514820600, 1514851200, 1514851200,
1514820600, 1514851200, 1514818800, 1514851200, 1514851200,
1514851200, 1514820600, 1514851200, 1514851200, 1514820600,
1514820600, 1514851200, 1514851200, 1514820600, 1514851200,
1514791800, 1514820600)), .Names = c("start", "end", "startN",
"endN"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-100L))