Create Grid Data for single subject from raw accelerometry
create_subject_predictor.Rd
Create Grid Data for single subject from raw accelerometry
Usage
create_subject_predictor(
data,
max_signal = 3,
bin_size = 0.25,
lags = c(15, 30, 45)
)
Arguments
- data
a
data.frame
with the columnstime
andvm
- max_signal
maximum signal of vector magnitude to create grid over, grid will be
0
tomax_signal
bybin_size
- bin_size
Size of the bins.
max_signal
must be evenly divisible bybin_size
.- lags
the lag (in samples, not seconds) to compute bin inclusion.
Examples
df = example_walking %>%
dplyr::mutate(time = lubridate::floor_date(Sys.time(), "seconds") + time)
create_subject_predictor(df)
#> # A tibble: 207 × 433
#> second `lag_15_[0,0.25]_[0,0.25]` `lag_15_[0,0.25]_(0.25,0.5]`
#> <dttm> <int> <int>
#> 1 2023-10-13 14:56:03 0 0
#> 2 2023-10-13 14:56:04 0 0
#> 3 2023-10-13 14:56:05 0 0
#> 4 2023-10-13 14:56:06 0 0
#> 5 2023-10-13 14:56:07 0 0
#> 6 2023-10-13 14:56:08 0 0
#> 7 2023-10-13 14:56:09 0 0
#> 8 2023-10-13 14:56:10 0 0
#> 9 2023-10-13 14:56:11 0 0
#> 10 2023-10-13 14:56:12 0 0
#> # ℹ 197 more rows
#> # ℹ 430 more variables: `lag_15_[0,0.25]_(0.5,0.75]` <int>,
#> # `lag_15_[0,0.25]_(0.75,1]` <int>, `lag_15_[0,0.25]_(1,1.25]` <int>,
#> # `lag_15_[0,0.25]_(1.25,1.5]` <int>, `lag_15_[0,0.25]_(1.5,1.75]` <int>,
#> # `lag_15_[0,0.25]_(1.75,2]` <int>, `lag_15_[0,0.25]_(2,2.25]` <int>,
#> # `lag_15_[0,0.25]_(2.25,2.5]` <int>, `lag_15_[0,0.25]_(2.5,2.75]` <int>,
#> # `lag_15_[0,0.25]_(2.75,3]` <int>, `lag_15_(0.25,0.5]_[0,0.25]` <int>, …
create_subject_predictor(df, lags = c(1, 15))
#> # A tibble: 207 × 289
#> second `lag_1_[0,0.25]_[0,0.25]` `lag_1_[0,0.25]_(0.25,0.5]`
#> <dttm> <int> <int>
#> 1 2023-10-13 14:56:03 0 0
#> 2 2023-10-13 14:56:04 0 0
#> 3 2023-10-13 14:56:05 0 0
#> 4 2023-10-13 14:56:06 0 0
#> 5 2023-10-13 14:56:07 0 0
#> 6 2023-10-13 14:56:08 0 0
#> 7 2023-10-13 14:56:09 0 0
#> 8 2023-10-13 14:56:10 0 0
#> 9 2023-10-13 14:56:11 0 0
#> 10 2023-10-13 14:56:12 0 0
#> # ℹ 197 more rows
#> # ℹ 286 more variables: `lag_1_[0,0.25]_(0.5,0.75]` <int>,
#> # `lag_1_[0,0.25]_(0.75,1]` <int>, `lag_1_[0,0.25]_(1,1.25]` <int>,
#> # `lag_1_[0,0.25]_(1.25,1.5]` <int>, `lag_1_[0,0.25]_(1.5,1.75]` <int>,
#> # `lag_1_[0,0.25]_(1.75,2]` <int>, `lag_1_[0,0.25]_(2,2.25]` <int>,
#> # `lag_1_[0,0.25]_(2.25,2.5]` <int>, `lag_1_[0,0.25]_(2.5,2.75]` <int>,
#> # `lag_1_[0,0.25]_(2.75,3]` <int>, `lag_1_(0.25,0.5]_[0,0.25]` <int>, …