r的时间秒
有人知道如何按“时间”秒进行分组?时间变量每秒有30个观测值。
structure(list(time = structure(c(1475049600, 1475049600.03333,
1475049600.06667, 1475049600.1, 1475049600.13333, 1475049600.16667,
1475049600.2, 1475049600.23333, 1475049600.26667, 1475049600.3,
1475049600.33333, 1475049600.36667, 1475049600.4, 1475049600.43333,
1475049600.46667, 1475049600.5, 1475049600.53333, 1475049600.56667,
1475049600.6, 1475049600.63333, 1475049600.66667, 1475049600.7,
1475049600.73333, 1475049600.76667, 1475049600.8, 1475049600.83333,
1475049600.86667, 1475049600.9, 1475049600.93333, 1475049600.96667,
1475049601, 1475049601.03333, 1475049601.06667, 1475049601.1,
1475049601.13333, 1475049601.16667, 1475049601.2, 1475049601.23333,
1475049601.26667, 1475049601.3), class = c("POSIXct", "POSIXt"
), tzone = "GMT"), X = c(-0.059, -0.023, -0.016, -0.016, -0.016,
-0.012, -0.016, -0.012, -0.016, -0.012, -0.016, -0.016, -0.016,
-0.02, -0.02, -0.027, -0.016, -0.02, -0.016, -0.016, -0.02, -0.023,
-0.016, -0.02, -0.012, -0.016, -0.012, -0.016, -0.016, -0.02,
-0.02, -0.02, -0.02, -0.008, -0.02, -0.016, -0.016, -0.012, -0.016,
-0.016), Y = c(-0.777, -0.777, -0.777, -0.777, -0.777, -0.777,
-0.777, -0.781, -0.773, -0.777, -0.777, -0.777, -0.777, -0.773,
-0.777, -0.777, -0.777, -0.777, -0.773, -0.777, -0.777, -0.777,
-0.77, -0.777, -0.777, -0.777, -0.781, -0.777, -0.777, -0.773,
-0.777, -0.777, -0.777, -0.773, -0.777, -0.777, -0.777, -0.777,
-0.777, -0.777), Z = c(0.688, 0.688, 0.691, 0.691, 0.688, 0.688,
0.688, 0.691, 0.691, 0.695, 0.688, 0.691, 0.691, 0.695, 0.691,
0.688, 0.688, 0.688, 0.691, 0.691, 0.691, 0.691, 0.695, 0.691,
0.691, 0.688, 0.695, 0.688, 0.691, 0.691, 0.688, 0.688, 0.688,
0.688, 0.688, 0.691, 0.691, 0.695, 0.695, 0.691)), subject_name = "1", time_zone = "02:00:00", missingness = structure(list(
time = structure(c(1475747248, 1475747249, 1475747250, 1475747292,
1475747293, 1475747294), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
n_missing = c(30L, 30L, 1230L, 30L, 30L, 32490L)), class = "data.frame", row.names = c("1475747248",
"1475747249", "1475747250", "1475747292", "1475747293", "1475747294"
)), old_version = FALSE, firmware = "1.5.0", last_sample_time = structure(1475748377, tzone = "GMT", class = c("POSIXct",
"POSIXt")), serial_prefix = "TAS", sample_rate = 30L, acceleration_min = "-8.0", acceleration_max = "8.0", header = structure(list(
`Serial Number` = "TAS1E44150325", `Device Type` = "Link",
Firmware = "1.5.0", `Battery Voltage` = "3,88", `Sample Rate` = 30,
`Start Date` = structure(1475049600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), `Stop Date` = structure(1475859600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), `Last Sample Time` = structure(1475748377, tzone = "GMT", class = c("POSIXct",
"POSIXt")), TimeZone = "02:00:00", `Download Date` = structure(1475748377, tzone = "GMT", class = c("POSIXct",
"POSIXt")), `Board Revision` = "5", `Unexpected Resets` = "0",
`Acceleration Scale` = 256L, `Acceleration Min` = "-8.0",
`Acceleration Max` = "8.0", Mass = "77,1107028999572", Age = "22",
Limb = "Waist", DateOfBirth = "628890912000000000", `Subject Name` = "1",
`Serial Prefix` = "TAS"), class = c("gt3x_info", "list")), start_time = structure(1475049600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), stop_time = structure(1475859600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), total_records = 20929470L, bad_samples = FALSE, n_head = 40, row.names = c(NA,
20929470L), class = c("activity_df", "activity_df", "activity_df",
"data.frame"))
Does anyone know how to group by 'time' seconds? The time variable has 30 observations per second.
structure(list(time = structure(c(1475049600, 1475049600.03333,
1475049600.06667, 1475049600.1, 1475049600.13333, 1475049600.16667,
1475049600.2, 1475049600.23333, 1475049600.26667, 1475049600.3,
1475049600.33333, 1475049600.36667, 1475049600.4, 1475049600.43333,
1475049600.46667, 1475049600.5, 1475049600.53333, 1475049600.56667,
1475049600.6, 1475049600.63333, 1475049600.66667, 1475049600.7,
1475049600.73333, 1475049600.76667, 1475049600.8, 1475049600.83333,
1475049600.86667, 1475049600.9, 1475049600.93333, 1475049600.96667,
1475049601, 1475049601.03333, 1475049601.06667, 1475049601.1,
1475049601.13333, 1475049601.16667, 1475049601.2, 1475049601.23333,
1475049601.26667, 1475049601.3), class = c("POSIXct", "POSIXt"
), tzone = "GMT"), X = c(-0.059, -0.023, -0.016, -0.016, -0.016,
-0.012, -0.016, -0.012, -0.016, -0.012, -0.016, -0.016, -0.016,
-0.02, -0.02, -0.027, -0.016, -0.02, -0.016, -0.016, -0.02, -0.023,
-0.016, -0.02, -0.012, -0.016, -0.012, -0.016, -0.016, -0.02,
-0.02, -0.02, -0.02, -0.008, -0.02, -0.016, -0.016, -0.012, -0.016,
-0.016), Y = c(-0.777, -0.777, -0.777, -0.777, -0.777, -0.777,
-0.777, -0.781, -0.773, -0.777, -0.777, -0.777, -0.777, -0.773,
-0.777, -0.777, -0.777, -0.777, -0.773, -0.777, -0.777, -0.777,
-0.77, -0.777, -0.777, -0.777, -0.781, -0.777, -0.777, -0.773,
-0.777, -0.777, -0.777, -0.773, -0.777, -0.777, -0.777, -0.777,
-0.777, -0.777), Z = c(0.688, 0.688, 0.691, 0.691, 0.688, 0.688,
0.688, 0.691, 0.691, 0.695, 0.688, 0.691, 0.691, 0.695, 0.691,
0.688, 0.688, 0.688, 0.691, 0.691, 0.691, 0.691, 0.695, 0.691,
0.691, 0.688, 0.695, 0.688, 0.691, 0.691, 0.688, 0.688, 0.688,
0.688, 0.688, 0.691, 0.691, 0.695, 0.695, 0.691)), subject_name = "1", time_zone = "02:00:00", missingness = structure(list(
time = structure(c(1475747248, 1475747249, 1475747250, 1475747292,
1475747293, 1475747294), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
n_missing = c(30L, 30L, 1230L, 30L, 30L, 32490L)), class = "data.frame", row.names = c("1475747248",
"1475747249", "1475747250", "1475747292", "1475747293", "1475747294"
)), old_version = FALSE, firmware = "1.5.0", last_sample_time = structure(1475748377, tzone = "GMT", class = c("POSIXct",
"POSIXt")), serial_prefix = "TAS", sample_rate = 30L, acceleration_min = "-8.0", acceleration_max = "8.0", header = structure(list(
`Serial Number` = "TAS1E44150325", `Device Type` = "Link",
Firmware = "1.5.0", `Battery Voltage` = "3,88", `Sample Rate` = 30,
`Start Date` = structure(1475049600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), `Stop Date` = structure(1475859600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), `Last Sample Time` = structure(1475748377, tzone = "GMT", class = c("POSIXct",
"POSIXt")), TimeZone = "02:00:00", `Download Date` = structure(1475748377, tzone = "GMT", class = c("POSIXct",
"POSIXt")), `Board Revision` = "5", `Unexpected Resets` = "0",
`Acceleration Scale` = 256L, `Acceleration Min` = "-8.0",
`Acceleration Max` = "8.0", Mass = "77,1107028999572", Age = "22",
Limb = "Waist", DateOfBirth = "628890912000000000", `Subject Name` = "1",
`Serial Prefix` = "TAS"), class = c("gt3x_info", "list")), start_time = structure(1475049600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), stop_time = structure(1475859600, tzone = "GMT", class = c("POSIXct",
"POSIXt")), total_records = 20929470L, bad_samples = FALSE, n_head = 40, row.names = c(NA,
20929470L), class = c("activity_df", "activity_df", "activity_df",
"data.frame"))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种简单的方法是从
{lubritation}
package使用第二个
函数。这是使用简单数据的示例:A simple way is to use
second
function from{lubridate}
package. Here is an example using simple data: