--- title: "Plotting Minute-Level Activity Data" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Plotting Minute-Level Activity Data} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 14, fig.height = 7, out.width = "100%" ) ``` ```{r setup} library(actiplot) ``` This vignette uses the packaged `acti_minute_data` accelerometer recording. It contains seven days of minute-level vector-magnitude activity counts. It is processed from the [upper-limb activity Figshare collection](https://doi.org/10.6084/m9.figshare.c.4457855) described by [Chadwell et al. (2019)](https://doi.org/10.1038/s41597-019-0211-6). ```{r data} activity <- acti_minute_data ``` ## Complete recording Use `acti_plot_time()` to inspect activity across the entire recording. The `breaks` argument accepts ordinary duration strings and sets the interval of the time-axis labels. ```{r full-time} acti_plot_time(activity, counts, breaks = "4 hours") ``` For a more legible complete-recording axis, set `x_axis = "12 hours"`. It shows date and 12-hour-clock labels at midnight and noon. Alternatively, `x_axis = "midnight"` prints just the date at midnight, without `00:00:00`. ```{r full-time-readable-axis} acti_plot_time(activity, counts, x_axis = "12 hours") acti_plot_time(activity, counts, x_axis = "midnight") ``` ## Daily aligned rows Use `acti_plot_day()` to align each day on the same time-of-day axis. Each facet row is one calendar date, which makes day-to-day activity patterns easy to compare. ```{r daily, fig.height=12} acti_plot_day(activity, counts, breaks = "4 hours") ``` Set `facet = "month-day"` to remove the year from date strips, or `facet = "day"` to use the baseline-relative day calculated by `actibase::acti_separate_times()`. ```{r daily-facet-labels, fig.height=12} acti_plot_day(activity, counts, facet = "month-day") acti_plot_day(activity, counts, facet = "day") ``` ## Date-by-time heat map `acti_plot_heatmap()` uses the same alignment with counts represented by fill. ```{r heatmap, fig.height=9} acti_plot_heatmap(activity, counts, breaks = "4 hours") ``` ## Actogram and daily profile ```{r actogram, fig.height=9} acti_plot_actogram(activity, counts, breaks = "4 hours") ``` ```{r minute-profile} acti_plot_minute_profile(activity, counts, summary = "median") ``` ## Interval annotations Episode layers use an explicit interval table with POSIXct start and end columns. The example creates deterministic nightly windows for illustration. ```{r intervals} sleep_windows <- data.frame( start = as.POSIXct(c("2017-06-03 22:00:00", "2017-06-04 22:00:00"), tz = "GMT"), end = as.POSIXct(c("2017-06-04 07:00:00", "2017-06-05 07:00:00"), tz = "GMT") ) acti_plot_time(activity, counts) + geom_sleep_window(sleep_windows) + geom_day_boundary("noon", linetype = "dashed") ``` The same interval schema supports generic episodes and wear annotations. ```{r episode-and-wear} acti_plot_time(activity, counts) + geom_episode(sleep_windows, fill = "grey30", alpha = 0.10) + geom_wear(sleep_windows) ``` Additional lightweight annotations can mark selected activity and intensity. ```{r rug-threshold-vline} acti_plot_time(activity, counts) + geom_activity_rug(activity[activity$counts > 10000, ]) + geom_threshold_band(activity, "counts", threshold = 10000) + geom_time_vline(xintercept = "12:00:00", linetype = "dotted") ```