agd_worker: R6 class: 'agd_worker'

agd_workerR Documentation

R6 class: agd_worker

Description

agd_worker is an R6 class that runs a data processing pipeline on two .agd (ActiGraph; github.com/actigraph) accelerometer files with LowFrequencyExtension and Normal filters for a single participant. This class does all the heavy lifting for the agd R6 class.

Public fields

args

A list of arguments passed into agd_worker$new(). See documentation for agd_worker$new() for details.

data

A list of four tibbles created during agd_worker$load() (settings, raw), agd_worker$clean() (clean) and agd_worker$classify() (classify) representing .agd data at various stages of the pipeline.

issues

A list of seven length-one, dichotomous ("yes"/"") character vectors (file_missing, files_identical, files_mismatched, non_midnight_start, no_complete_days, sleep_missing, age_out_of_range) representing flags for issues affecting pipeline results.

log

A tibble with method, timestamp, status and message vectors providing a record of events during the pipeline run.

results

A list of four tibbles (summary_full, summary_full_stc, summary_sleeping_hours, summary_waking_hours) summarizing the pipeline run.

Methods

Public methods


agd_worker$new()

This method creates an instance of an agd_worker class.

Usage
agd_worker$new(
  id,
  age,
  agd_lfe,
  agd_nml,
  epoch_length = 60,
  day_max = 7,
  sleep_algo = "barreira",
  non_wear_algo = "barreira",
  start_date = NA
)
Arguments
id

Required: a length-one vector representing a unique participant ID.

age

Required: a length-one integer vector representing a participant's age in years.

agd_lfe

Required: a length-one character vector representing the full path to an .agd file with the LowFrequencyExtension filter.

agd_nml

Required: a length-one character vector representing the full path to an .agd file with the Normal filter.

epoch_length

Required (default: 60): a length-one integer vector representing the epoch length 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_max

Required (default: 7): a length-one integer vector representing the maximum number of days of data to load from agd_lfe and agd_nml.

sleep_algo

Required (default: "barreira"): a length-one character vector representing the sleep algorithm to apply. Options currently include "barreira". See apply_barreira_algo() for more details.

non_wear_algo

Required (default: "barreira"): a length-one character vector 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_date

Optional (default: NA): a length-one date vector (format: yyyy-mm-dd) 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.

Returns

Returns an object of class agd_worker.


agd_worker$load()

This method calls load_agd_settings() and load_agd_data().

Usage
agd_worker$load()
Returns

Returns the agd_worker object (self) invisibly.


agd_worker$clean()

This method calls clean_agd_data().

Usage
agd_worker$clean()
Returns

Returns the agd_worker object (self) invisibly.


agd_worker$classify()

This method calls classify_agd_data().

Usage
agd_worker$classify()
Returns

Returns the agd_worker object (self) invisibly.


agd_worker$summarize()

This method calls summarize_agd_data().

Usage
agd_worker$summarize()
Returns

Returns the agd_worker object (self) invisibly.


agd_worker$run()

This method calls agd_worker$load(), agd_worker$clean(), agd_worker$classify() and agd_worker$summarize().

Usage
agd_worker$run()
Returns

Returns the agd_worker object (self) invisibly.


agd_worker$print()

This method renders details (arguments, issues, log) about an instance of agd_worker to the console.

Usage
agd_worker$print()
Returns

Returns the agd_worker object (self) invisibly.


agd_worker$clone()

The objects of this class are cloneable with this method.

Usage
agd_worker$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

# 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"
)

# Run data processing pipeline (load, clean, classify and summarize data)
agd_data$run()

chms documentation built on Oct. 17, 2026, 5:07 p.m.