【发布时间】:2019-05-18 22:14:25
【问题描述】:
我正在尝试从 1 分钟的数据中以 5 分钟的间隔提取行。我的数据如下所示:
structure(list(Date = structure(c(1509408000, 1509408000, 1509408000,
1509408000, 1509408000, 1509408000), class = c("POSIXct", "POSIXt"
), tzone = "UTC"), Time = structure(c(-2209021500, -2209021560,
-2209021620, -2209021680, -2209021740, -2209021800), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), O = c(3674, 3675, 3674, 3675, 3675,
3675), H = c(3674, 3675, 3675, 3676, 3676, 3675), L = c(3673,
3674, 3674, 3674, 3675, 3675), C = c(3673, 3674, 3674, 3675,
3675, 3675)), row.names = c(NA, -6L), class = c("tbl_df", "tbl",
"data.frame"))
structure(list(Date = structure(c(1506902400, 1506902400, 1506902400,
1506902400, 1506902400, 1506902400), class = c("POSIXct", "POSIXt"
), tzone = "UTC"), Time = structure(c(-2209071300, -2209071360,
-2209071420, -2209071480, -2209071540, -2209071600), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), O = c(3450, 3451, 3451, 3452, 3450,
3449), H = c(3451, 3451, 3451, 3452, 3452, 3451), L = c(3448,
3449, 3449, 3450, 3450, 3449), C = c(3448, 3451, 3450, 3451,
3452, 3450)), row.names = c(NA, -6L), class = c("tbl_df", "tbl",
"data.frame"))
我看过:
Create a time interval of 15 minutes from minutely data in R?
How to subset and extract time series by time interval in row
但没有人能完全按照我的意愿行事。也许我可以使用这个:
substr(t,15,16)=="00".
但我不确定如何将其与filter 结合使用。
期望的输出:每隔 30 分钟查找行:
【问题讨论】:
-
您能在示例中添加更多数据吗?
-
那么您想要
Time值在5 分钟标记处的行吗? -
欢迎来到 SO!你能提供想要的输出吗?
-
Select every nth row from dataframe 的可能重复项,因为您知道每一行之间的间隔为 1 百万
-
我没有使用过查看每第 n 行,因为缺少一些数据