clean.glooko: Format and clean the Glooko data to keep relevant columns...

View source: R/01b_glooko.R

clean.glookoR Documentation

Format and clean the Glooko data to keep relevant columns only

Description

Slowly absorbed carbohydrates. In CamAPS, users can flag carbohydrates as slowly absorbed (over 3 to 4 hours). Glooko exports such an intake as a series of equal-sized entries, one every 30 minutes. Because these entries are not separate intakes, this function merges them back into a single entry if merge_slow_carbs = TRUE. This keeps the data consistent with export platforms that do not split slowly absorbed carbohydrates (e.g. mylife), so that later filtering and duplicate detection across platforms work correctly.

Usage

## S3 method for class 'glooko'
clean(data, id, merge_slow_carbs = TRUE, ...)

Arguments

data

An instance of class glooko, wrapping a named list with data of a particular data type.

id

Character or numeric participant identifier.

merge_slow_carbs

Logical, if TRUE (the default), slowly absorbed carbohydrates are merged (see Details).

...

Additional arguments passed to methods.

Details

A series is merged if

  • all entries have the same amount,

  • each entry lies 30 +/- 5 minutes after the previous one (unrelated entries in between are ignored), and

  • the series consists of exactly 6, 7, or 8 entries (corresponding to 2 to 3 hours absorption time, every 30 minutes).

The merged entry takes the time and link_id of the first entry. Its amount is the sum of all entries, and estimated_absorption_duration is set to 0.5 hours per entry (e.g. 3 hours for 6 entries). The zero-unit boluses linked to the other entries are removed. All removed rows are stored in the attribute removed; see removed_entries.

Value

A named list with the cleaned data, named according to the data type of data: cgm, basal, bolus and carbs (both are extracted from the bolus file), total_basal and total_bolus (both are extracted from the daily aggregated insulin file) or SMBG. NULL for all other data types, which are not cleaned.


aidR documentation built on Oct. 28, 2026, 5:13 p.m.