R/extract_movement_functions.R
extract_timemask.RdExtract a timemask from a dataframe for use in extract_with_timemask
extract_timemask(df, ...)a list with a tibble for intervals and the total ON duration.
extract_with_timemask for using the timemask.
# Data-masking syntax similar to dplyr::filter
sample <- example_data$head_movement_data_0[[1]]
extract_timemask(sample, pos_x^2 + pos_y^2 + pos_z^2 > 15)
#> $total_on_duration
#> [1] 0
#>
#> $intervals
#> # A tibble: 0 × 2
#> # ℹ 2 variables: start_time <dbl>, end_time <dbl>
#>
#> attr(,"class")
#> [1] "timemask"
# Programmatic use with Data-masking looks like
column_name <- "pos_x"
value <- mean(sample[[column_name]])
extract_timemask(sample, .data[[column_name]] > value)
#> $total_on_duration
#> [1] 7.8865
#>
#> $intervals
#> # A tibble: 6 × 2
#> start_time end_time
#> <dbl> <dbl>
#> 1 641. 643.
#> 2 644. 644.
#> 3 647. 648.
#> 4 652. 653.
#> 5 656. 656.
#> 6 657. 660.
#>
#> attr(,"class")
#> [1] "timemask"