plot_activity_period: Plot activity and periods

View source: R/plot_agd.R

plot_activity_periodR Documentation

Plot activity and periods

Description

Plot activity values as a time series and periods as polygons.

Usage

plot_activity_period(
  agdb,
  periods,
  act_var,
  start_var,
  end_var,
  color = "black",
  fill = "#525252",
  ncol = NULL,
  nrow = NULL
)

Arguments

agdb

A tibble of activity data.

periods

A tibble of periods with at least two columns start_var and end_var.

act_var

The activity variable (unquoted) to plot on the y-axis.

start_var

The variable (unquoted) which indicates when the time periods start.

end_var

The variable (unquoted) which indicates when the time periods end.

color

Activity line color.

fill

Polygon fill color.

ncol

Number of rows and columns. Relevant only if the activity data is grouped.

nrow

Number of rows and columns. Relevant only if the activity data is grouped.

Examples

data("gtxplus1day")

sub_gt3x <- gtxplus1day %>%
  dplyr::filter(timestamp <= lubridate::as_datetime("2012-06-27 18:00:00"))
# Detect sleep periods using Sadeh as the sleep/awake algorithm
# and Tudor-Locke as the sleep period algorithm
periods_sleep <- sub_gt3x %>%
  collapse_epochs(60) %>%
  apply_cole_kripke() %>%
  apply_tudor_locke(min_sleep_period = 60)

plot_activity_period(
  sub_gt3x, periods_sleep, axis1,
  in_bed_time, out_bed_time
)

dipetkov/actigraph.sleepr documentation built on March 25, 2022, 2:33 a.m.