plot_activity_period: Plot activity and periods

Description Usage Arguments Examples

View source: R/plot_agd.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
plot_activity_period(
  agdb,
  periods,
  act_var,
  start_var,
  end_var,
  color = "black",
  fill = "#525252",
  ncol = NULL,
  nrow = NULL
)

Arguments

agdb

A tibble (tbl) of activity data (at least) an epochlength attribute.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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
)

oslerinhealth/actigraph.sleepr documentation built on May 25, 2021, 1:06 p.m.