---
title: "excursion function"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{excursion function}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE)
library(cgmguru)
library(iglu)
```

# excursion

## Overview
Calculates glucose excursions: >70 mg/dL rise within 2 hours, not preceded by a value <70 mg/dL.

`excursion()` evaluates the rows supplied in `df`. It does not automatically call `interpolate_cgm()` and does not use the full-day event preprocessing grid unless you explicitly pass interpolated data to `excursion()`.

## Inputs
- **df**: CGM dataframe with `id`, `time` (POSIXct), `gl` (mg/dL)
- **gap**: Minimum minutes separating excursions (default 15)

## Returns
- **excursion_vector**: Logical/int vector marking excursions
- **episode_counts**: Counts per `id`
- **episode_start**: Starts with `id`, `time`, `gl`, `index`

## Run documented examples
```{r}
example(excursion, package = "cgmguru", run.dontrun = FALSE)
```

