View source: R/apply-general-bout-algo.R
| apply_general_bout_algo | R Documentation |
This function uses a general algorithm to classify an accelerometer axis vector of of epochs based on a set of bout rules.
apply_general_bout_algo(
x,
axis1 = "axis1",
is_wearing = "is_wearing",
min_bout_length = 10,
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"). |
is_wearing |
Required: a character vector of "Yes" and "No" values
representing wear time and non-wear time respectively (default:
"is_wearing"). See |
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 is 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, clean and classify data
agd_data$load()$clean()$classify()
# Look for 10+ minute bouts of moderate-intensity physical activity
dt <- apply_general_bout_algo(
x = agd_data$data$classify,
min_bout_length = 10 * (60 / agd_data$args$movement_epoch_length),
target_values = 574:1002,
max_exceptions = 2 * (60 / agd_data$args$movement_epoch_length),
return = c("dataTimestamp", "axis1", "in_bout")
)
# Get bout lengths
rle(dt$in_bout)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.