Мы можем использовать seq
, так как он указывает аргумент by
как 0,5.
start = as.POSIXct("2020-01-28 03:31:22.209", format = "%Y-%m-%d %H:%M:%OS",tz = "UTC")
end = as.POSIXct("2020-01-28 05:31:22.209", format = "%Y-%m-%d %H:%M:%OS",tz = "UTC")
seq(start, end, by = 0.5) %>% head
#[1] "2020-01-28 03:31:22.209 UTC" "2020-01-28 03:31:22.709 UTC"
#[3] "2020-01-28 03:31:23.209 UTC" "2020-01-28 03:31:23.709 UTC"
#[5] "2020-01-28 03:31:24.209 UTC" "2020-01-28 03:31:24.709 UTC"
Или, если вы хотите использовать его в secz
фрейме данных
tidyr::complete(secz, minz = seq(min(minz), max(minz), by = 0.5))
# minz
# <dttm>
# 1 2020-01-28 03:31:22.209
# 2 2020-01-28 03:31:22.709
# 3 2020-01-28 03:31:23.209
# 4 2020-01-28 03:31:23.709
# 5 2020-01-28 03:31:24.209
# 6 2020-01-28 03:31:24.709
# 7 2020-01-28 03:31:25.209
# 8 2020-01-28 03:31:25.709
# 9 2020-01-28 03:31:26.209
#10 2020-01-28 03:31:26.709
# … with 14,391 more rows