View source: R/apply-non-wear-algo.R
| apply_non_wear_algo | R Documentation |
This function uses a general algorithm to classify an accelerometer axis vector of epochs as wear time or non-wear time based on a set of bout rules
apply_non_wear_algo(
x,
axis1 = "axis1",
min_bout_length = 90,
target_values,
max_exceptions = 2,
return = "everything"
)
x |
Required: a data frame of accelerometer data. |
axis1 |
Required: a length-one character vector representing the name of the vertical axis (default: "axis1"). |
min_bout_length |
Required: a length-one numeric vector representing the minimum number of epochs in a bout (default: 10). |
target_values |
Required: a numeric vector representing the epoch value(s) that belong to a bout. |
max_exceptions |
Required: a length-one numeric vector representing
the maximum number of epochs permitted within a bout that outside the range
of the values in the |
return |
Required: a character vector representing which vectors to
return (default: "everything"). If set to "everything", the data frame in
the |
Returns the data frame in the x argument along with all vectors
that were derived while applying the bout algorithm.
# Initialize agd_worker R6 class
agd_data <- agd_worker$new(
id = "jane-canuck",
age = 10,
agd_lfe = system.file("extdata", "jane-canuck-lfe.agd", package = "chms"),
agd_nml = system.file("extdata", "jane-canuck-nml.agd", package = "chms"),
epoch_length = 15,
day_max = 3,
sleep_algo = "barreira",
non_wear_algo = "barreira"
)
# Load and clean data
agd_data$load()$clean()
# Apply Barreira sleep algorithm
dt <- apply_barreira_algo(
x = agd_data$data$clean |>
dplyr::filter(
epoch_length == 60,
filter == "LowFrequencyExtension"
),
age = agd_data$args$age
)
# Apply general non-wear algorithm
dt <- apply_non_wear_algo(
x = dt,
min_bout_length = 60,
target_values = 0,
max_exceptions = 2,
return = c("is_wearing", "is_sleeping", "ymd_hm")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.