| agd | R Documentation |
agdagd is an R6 class that runs a data processing pipeline on
one or more jobs that include two .agd (ActiGraph; github.com/actigraph)
accelerometer files with LowFrequencyExtension and Normal filters per
participant. This class makes calls to the agd_worker R6 class.
argsA list of arguments passed into agd$new(). See
documentation for agd$new() for details.
logA tibble with method, timestamp, status, and message
vectors providing a record of events during the pipeline run.
jobsA tibble with vectors based on the args passed into
agd$new() representing jobs to be run that are distributed across the
number of CPUs set by cpu_max in agd$new().
resultsA list of five tibbles (summary_full,
summary_full_stc, summary_run, summary_sleeping_hours,
summary_waking_hours) summarizing pipeline run(s).
agd$new()This method creates an instance of an agd_worker class.
agd$new( id, age, agd_lfe, agd_nml, epoch_length = 60, day_max = 7, sleep_algo = "barreira", non_wear_algo = "barreira", start_date = NA, cpu_max = 1, dir = NA )
idRequired: a vector representing unique participant ID(s).
ageRequired: an integer vector representing participant age(s) in years.
agd_lfeRequired: a character vector representing the full path
to .agd file(s) with the LowFrequencyExtension filter.
agd_nmlRequired: a character vector representing the full path
to .agd file(s) with the Normal filter.
epoch_lengthRequired (default: 60): an integer vector
(length-one or the same length as id) representing the epoch length(s)
at which to process the data. Statistics Canada currently uses 15 for
participants under 18 years and 60 for participants at all other ages.
Note: if sleep_algo is set to "barreira" and epoch_length is set
to 15, the sleep algorithm will be applied to 60-second epoch data and
the results will be applied to the 15-second epoch data.
day_maxRequired (default: 7): an integer vector (length-one or
the same length as id) representing the maximum number of days of data
to load from agd_lfe and agd_nml.
sleep_algoRequired (default: "barreira"): a character vector
(length-one or the same length as id) representing the sleep algorithm
to apply. Options currently include "barreira". See
apply_barreira_algo() for more details.
non_wear_algoRequired (default: "barreira"): a character
vector (length-one or the same length as id) representing the non-wear
algorithm to apply. Options currently include "barreira",
"20-min-algo", "60-min-algo", "90-min-algo" and "choi". See
apply_barreira_algo() and apply_non_wear_algo() for more details.
start_dateOptional (default: NA): a character or date vector
(format: yyyy-mm-dd) that is length-one or the same length as id
representing the first day of data to load from agd_lfe and agd_nml.
If not set, data will be loaded from the first available day until
day_max is reached.
cpu_maxRequired (default: 1): a length-one integer vector
representing the number of CPUs to distribute the data processing across.
dirOptional (default: NA): a length-one character vector
representing the full path to the location where the results list will
be exported tibble by tibble in .csv format.
Returns an object of class agd.
agd$run()This method iterates jobs and calls run_agd_job().
agd$run()
Returns the results list from an agd_worker object and binds
it to self (an instance of agd).
agd$export()This method exports self$results tibble by tibble in
.csv format.
agd$export(dir = self$args$dir, stc = FALSE)
dirOptional (default: self$args$dir): a length-one character
vector representing the full path to the location where the results
list will be exported tibble by tibble in .csv format.
stcOptional (default: FALSE): a length-one logical vector
indicating whether to export only statcan-formatted results.
Returns the agd object (self) invisibly.
agd$print()This method renders details (arguments, issues, log) about
an instance agd to the console.
agd$print()
Returns the agd object (self) invisibly.
agd$sanity_check()This method renders a sanity check report in .html format.
agd$sanity_check( name = "sanity-check-report", id = self$jobs$id, dir = self$args$dir, include_plot = FALSE )
nameRequired (default: "sanity-check-report"): a length-one
character vector representing the file name of the report.
idRequired (default: self$jobs$id): a vector representing
unique participant ID(s).
dirRequired (default: self$args$dir): a length-one character
vector representing the full path to the location where the report will
be exported in .html format.
include_plotOptional (default: FALSE): a length-one logical
vector representing whether to render scatterplots.
Returns an .html-formatted report.
agd$view()This method renders data frames from $results in tab.
agd$view(results = c(names(self$results), "issues", "log"))
resultsOptional (default: c(names(self$results), "issues", "log")): a character vector representing the results to render to tab.
Options include: "summary_full",
"summary_full_stc", "summary_run", "summary_sleeping_hours",
"summary_waking_hours", "issues", "log".
Returns the agd object (self) invisibly.
agd$clone()The objects of this class are cloneable with this method.
agd$clone(deep = FALSE)
deepWhether to make a deep clone.
# Create meta data frame (external/non-statcan users)
meta <- data.frame(
id = c("jane-canuck", "john-canuck"),
age = c(10, 40),
agd_lfe = c(
system.file("extdata", "jane-canuck-lfe.agd", package = "chms"),
system.file("extdata", "john-canuck-lfe.agd", package = "chms")
),
agd_nml = c(
system.file("extdata", "jane-canuck-nml.agd", package = "chms"),
system.file("extdata", "john-canuck-nml.agd", package = "chms")
),
start_date = c("2021-05-30", "2021-05-27"),
epoch_length = c(15, 60)
)
# Initialize agd R6 class
agd_data <- agd$new(
id = meta$id,
age = meta$age,
agd_lfe = meta$agd_lfe,
agd_nml = meta$agd_nml,
epoch_length = meta$epoch_length,
day_max = 2,
sleep_algo = "barreira",
non_wear_algo = "barreira",
start_date = meta$start_date,
cpu_max = 1
)
# Run data processing pipeline (load, clean, classify and summarize data)
agd_data$run()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.