summarize_actigraphy: Summarize Actigraphy Data

View source: R/create_day_data.R

summarize_daily_actigraphyR Documentation

Summarize Actigraphy Data

Description

Summarize Actigraphy Data

Usage

summarize_daily_actigraphy(
  x,
  unit = "1 min",
  fix_zeros = TRUE,
  fill_in = TRUE,
  trim = FALSE,
  verbose = TRUE,
  calculate_mims = FALSE,
  calculate_ac = FALSE,
  flag_data = TRUE,
  ensure_all_time = TRUE,
  flags = NULL,
  ...
)

summarise_daily_actigraphy(
  x,
  unit = "1 min",
  fix_zeros = TRUE,
  fill_in = TRUE,
  trim = FALSE,
  verbose = TRUE,
  calculate_mims = FALSE,
  calculate_ac = FALSE,
  flag_data = TRUE,
  ensure_all_time = TRUE,
  flags = NULL,
  ...
)

summarize_actigraphy(
  x,
  unit = "1 min",
  .fns = list(mean = mean, median = median),
  verbose = TRUE,
  ...
)

collapse_daily_actigraphy(
  x,
  .fns = list(mean = function(x) mean(x, na.rm = TRUE), median = function(x) median(x,
    na.rm = TRUE)),
  verbose = TRUE
)

summarise_actigraphy(
  x,
  unit = "1 min",
  .fns = list(mean = mean, median = median),
  verbose = TRUE,
  ...
)

Arguments

x

an AccData object. If 'x' is a character, then read_actigraphy will be run

unit

units to group the data to take the statistic over

fix_zeros

Should fix_zeros be run before calculating the measures?

fill_in

if fix_zeros = TRUE, should the zeros be filled in with the last observation carried forward?

trim

if fix_zeros = TRUE, should the time course be trimmed for zero values at the beginning and the end of the time course? observation carried forward?

verbose

print diagnostic messages

calculate_mims

Should MIMS units be calculated? Passed to calculate_measures

calculate_ac

Should Activity Counts from the activityCounts package be calculated?

flag_data

Should [SummarizedActigraphy::flag_qc()] be run? It will be executed after fix_zeros before any measure calculation

ensure_all_time

if TRUE, then all times from the first to last times will be in the output, even if data during that time was not in the input

flags

the flags to calculate, passed to [SummarizedActigraphy::flag_qc()]

...

Additional arguments to pass to read_actigraphy

.fns

Functions to apply to each of the selected columns. See across

Value

A tsibble object, with 86400 rows, with one row for each second of the day '24*60*60'.

Examples

path = system.file("extdata",
"TAS1H30182785_2019-09-17.gt3x",
package = "SummarizedActigraphy")

x = read_actigraphy(path)

options(digit.secs = 2)

fixed = fix_zeros(x)
daily = summarize_daily_actigraphy(fixed, fix_zeros = FALSE)
average_day = collapse_daily_actigraphy(daily)
## Not run: 
  average_day = summarize_actigraphy(fixed, fix_zeros = FALSE)
  if (requireNamespace("ggplot2", quietly = TRUE)) {
    library(magrittr)
    average_day %>%
      ggplot(aes(x = time, y = ai_mean)) +
      geom_line()

    average_day %>%
      ggplot(aes(x = time, y = ai_median)) +
      geom_line()
  }

## End(Not run)

muschellij2/SummarizedActigraphy documentation built on Aug. 12, 2024, 5:35 p.m.