## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## ----load---------------------------------------------------------------------
library(carwatch)

fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch")
study_results <- read_study_results(file.path(fixture, "results.csv"))
saliva <- read_saliva(file.path(fixture, "saliva.csv"))

saliva

## ----merge--------------------------------------------------------------------
merged <- merge_saliva(study_results, saliva, match_on = "sample")
samples <- as_sample_events(merged)
samples[c(
  "participant", "day", "sample_position", "sample", "recorded_sample",
  "cortisol", "sample_compliant", "mismatch_corrected"
)]

## ----features-----------------------------------------------------------------
compute_features_from_carwatch(merged, saliva_type = "cortisol")

## ----timeline, fig.width = 7, fig.height = 4.5--------------------------------
plot_sampling_timeline(merged, participant = "VP01", day = "D1")

## ----compliance, fig.width = 7, fig.height = 4.5------------------------------
plot_compliance_overview(merged)

## ----deviation, fig.width = 7, fig.height = 4.5-------------------------------
plot_timing_deviation(merged)

## ----curve, fig.width = 7, fig.height = 4.5-----------------------------------
plot_saliva_curve(merged, value = "cortisol", ci = NULL)

