| check_insulin_totals | R Documentation |
Compares the insulin summed over the individual data points with the daily
total reported by the export itself. Only daily totals with
source == "reported" are checked: where aidR summed the total itself
(source == "summed"), the two agree by construction. In practice this
means Glooko (basal and bolus) and Tandem Source (basal only).
check_insulin_totals(data, types = "basal", rel_tol = 0.2, abs_tol = 1)
data |
A list with all data found for one individual (the output of
|
types |
Character vector with the types of insulin that are checked, any
of |
rel_tol |
Numeric, the relative tolerance of the comparison. |
abs_tol |
Numeric, the absolute tolerance of the comparison, in units of
insulin. A day is flagged when the absolute difference exceeds both
|
Accepts either the output of parse_data for a single individual
or the output of merge_all for multiple individuals. Every
individual found in the data is checked separately.
By default, only the basal insulin is checked, which is where the mismatches
described below arise. Pass types = c("basal", "bolus") to check the
bolus insulin as well.
A large mismatch means that the individual data points do not cover the whole day. The most common cause are AID systems that record basal rates for manual mode only (e.g. Omnipod on Glooko): the basal insulin delivered in automated mode is missing from the basal rates, but is included in the reported total.
Note that the first and the last day of an export are usually only partially covered, so a mismatch on those days is expected.
Invisibly, a data frame with one row per checked individual, day and type, holding the summed and the reported total and whether the two agree. Called for its side effects: a message is issued for every day where they do not.
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- parse_data(id = "1", paths = path)
check_insulin_totals(data)
# Check bolus insulin as well, and keep the comparison
res <- check_insulin_totals(data, types = c("basal", "bolus"))
res
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.