#' Determine non-wear for ActiGraph data using the Choi algorithm
#'
#' @param AG data frame containing ActiGraph data read in using
#' \code{AGread::read_AG_counts}
#'
#' @keywords internal
AG_nonwear <- function(AG) {
ag60 <- AGread::reintegrate(
AG, 60, "Timestamp", "forwards"
)
invisible(utils::capture.output(
nonwear <-
within(ag60, {Timestamp = as.character(Timestamp)}) %>%
PhysicalActivity::wearingMarking(
perMinuteCts = 1, TS = "Timestamp", cts = "Axis1"
) %>%
.$wearing %>%
as.character(.) %>%
PAutilities::index_runs(.) %>%
{.[.$values == "nw", ]} %>%
within({
start_index = ag60$Timestamp[start_index]
end_index = ag60$Timestamp[end_index] + 59
}) %>%
{lubridate::interval(.$start_index, .$end_index)}
))
AG$Choi_isNonWear <-
AG$Timestamp %>%
sapply(function(x) {
lubridate::`%within%`(x, nonwear) %>%
any(.)
})
AG
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.