| Type: | Package |
| Title: | Reading and Standardizing Automated Insulin Delivery Data |
| Version: | 0.2.4 |
| Description: | Parses the native exports of several automated insulin delivery (AID) platforms into a common, platform-independent format for continuous glucose monitoring (CGM), basal, bolus, carbohydrate, and self-monitored blood glucose (SMBG) data. Additional functions check completeness, filter, produce visualizations, and convert the data to other formats. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| Imports: | readxl, tools, dplyr, lubridate, rjson, tidyr, stringr, utils, rlang, stats, graphics, iglu, hms |
| Config/roxygen2/version: | 8.1.0 |
| Suggests: | knitr, rmarkdown, cgmquantify, ggplot2, testthat (≥ 3.0.0), withr |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| URL: | https://github.com/madleina/aidR |
| BugReports: | https://github.com/madleina/aidR/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-10-16 12:43:03 UTC; madleina |
| Author: | Madleina Caduff |
| Maintainer: | Madleina Caduff <madleina.caduff@dcberne.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-28 11:00:09 UTC |
aidR: Reading and Standardizing Automated Insulin Delivery Data
Description
Parses the native exports of several automated insulin delivery (AID) platforms into a common, platform-independent format for continuous glucose monitoring (CGM), basal, bolus, carbohydrate, and self-monitored blood glucose (SMBG) data. Additional functions check completeness, filter, produce visualizations, and convert the data to other formats.
Author(s)
Maintainer: Madleina Caduff madleina.caduff@dcberne.com (ORCID)
Authors:
Madleina Caduff madleina.caduff@dcberne.com (ORCID)
Aritz Lizoain aritz.lizoain@dcberne.com (ORCID)
Other contributors:
Diabetes Center Berne (DCB) [copyright holder, funder]
See Also
Useful links:
Aggregate a standardized data frame into one value per day
Description
Aggregate a standardized data frame into one value per day
Usage
.aggregate_per_day.aidR(df, values, name, source)
Arguments
df |
A standardized data frame, with columns |
values |
A numeric vector of the same length as |
name |
Character string with the name of the resulting value column. |
source |
Character string describing where the daily total comes from,
either |
Value
A data frame with columns id, format, date,
name and source, holding one row per day. NULL if
df is empty.
The carbohydrate column names used in a CareLink export
Description
CareLink names the bolus wizard carbohydrate columns after the carbohydrate unit configured on the pump: grams ("BWZ Carb Input (grams)" and "BWZ Carb Ratio (g/U)") or exchanges ("BWZ Carb Input (exchanges)" and "BWZ Carb Ratio (U/Ex)").
Usage
.carelink_carb_variants.aidR()
Value
A list with one entry per carbohydrate unit, each a list with the
column names of the carbohydrate input (input) and the carbohydrate
ratio (ratio), as well as the corresponding unit (unit).
Check if data for different types are available for at least one day, for one individual
Description
Check if data for different types are available for at least one day, for one individual
Usage
.check_completeness_id.aidR(id, data_id, necessary_types)
Arguments
id |
Character participant identifier, or |
data_id |
A list with all data found for one individual. |
necessary_types |
A character vector with type names for which data should be available. |
Value
No return value, called for side effects.
Check if data for different types are available for a range of dates, for one individual
Description
Check if data for different types are available for a range of dates, for one individual
Usage
.check_completeness_range_id.aidR(id, data_id, expected, necessary_types)
Arguments
id |
Character participant identifier, or |
data_id |
A list with all data found for one individual. |
expected |
A vector of dates for which data should be available. |
necessary_types |
A character vector with type names for which data should be available. |
Value
No return value, called for side effects.
Check that no relevant columns were missed when splitting a data frame
Description
Throws an error if there are columns with non-NA entries in df that are
not present in subset.
Usage
.check_if_missing_columns_with_data.aidR(df, subset)
Arguments
df |
The full data frame. |
subset |
The subsetted data frame. |
Value
Called for its side effects. Returns NULL invisibly.
Compare the summed and the reported daily insulin of one data type
Description
Compare the summed and the reported daily insulin of one data type
Usage
.check_insulin_total.aidR(id, data_id, type, rel_tol, abs_tol)
Arguments
id |
Character participant identifier, or |
data_id |
A list with all data found for one individual. |
type |
Either |
rel_tol |
Numeric, the relative tolerance of the comparison. |
abs_tol |
Numeric, the absolute tolerance of the comparison. |
Value
A data frame with one row per checked day, or NULL if there is
nothing to compare.
Warn if the entries of two formats are shifted by one hour
Description
Exports of overlapping time periods may be shifted by one hour, e.g. because
of daylight saving time or time zone settings. Their entries are then not
detected as near-duplicates. For each pair of formats, the number of
near-duplicates is counted with the timestamps as they are, and with the
timestamps of one format shifted by +/- 1 hour. A warning is given if a
shift yields at least min_matches near-duplicates, and more than
twice as many as without the shift. Nothing is changed in the data.
Usage
.check_time_shift.aidR(
df,
type,
col,
tol,
max_minutes = 5,
min_matches = 5,
col2 = NULL,
tol2 = NULL
)
Arguments
df |
A data frame with the cleaned data of one data type. |
type |
Name of the data type (used in the warning). |
col |
Name of the column holding the value. |
tol |
Maximum difference in value between two near-duplicates. |
max_minutes |
Maximum time difference (in minutes) between two near-duplicates. |
min_matches |
Minimum number of near-duplicates with the shift to give a warning. |
col2 |
Optional name of a second column that must match as well, or |
tol2 |
Maximum difference in |
Value
TRUE (invisibly) if a warning was given, FALSE otherwise.
Format and clean CGM data from a CareLink export
Description
Format and clean CGM data from a CareLink export
Usage
.clean_carelink_CGM.aidR(id, cgm)
Arguments
id |
Character or numeric participant identifier. |
cgm |
A data frame containing the CGM data from a CareLink file. |
Value
A data frame containing the formatted and cleaned CGM data.
Format and clean SMBG data from a CareLink export
Description
Format and clean SMBG data from a CareLink export
Usage
.clean_carelink_SMBG.aidR(id, SMBG)
Arguments
id |
Character or numeric participant identifier. |
SMBG |
A data frame containing the SMBG data from a CareLink file. |
Value
A data frame containing the formatted and cleaned SMBG data.
Format and clean bolus data from a CareLink export
Description
Format and clean bolus data from a CareLink export
Usage
.clean_carelink_bolus.aidR(id, bolus)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a CareLink file. |
Value
A data frame containing the formatted and cleaned bolus data.
Format and clean carbohydrate data from a CareLink export
Description
Format and clean carbohydrate data from a CareLink export
Usage
.clean_carelink_carbs.aidR(id, bwz)
Arguments
id |
Character or numeric participant identifier. |
bwz |
A data frame containing the bolus wizard entries from a CareLink file, which hold the carbohydrates entered into the bolus calculator. |
Value
A data frame containing the formatted and cleaned carbohydrate data.
Format and clean SMBG data from a mylife export
Description
Format and clean SMBG data from a mylife export
Usage
.clean_mylife_SMBG.aidR(id, SMBG)
Arguments
id |
Character or numeric participant identifier. |
SMBG |
A data frame containing the SMBG data from a mylife file. |
Value
A data frame containing the formatted and cleaned SMBG data.
NULL if there is no SMBG data.
Format and clean bolus data from a mylife export
Description
Format and clean bolus data from a mylife export
Usage
.clean_mylife_bolus.aidR(id, bolus)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a mylife file. |
Value
A data frame containing the formatted and cleaned bolus data.
NULL if there is no bolus data.
Format and clean carbohydrate data from a mylife export
Description
Format and clean carbohydrate data from a mylife export
Usage
.clean_mylife_carbs.aidR(id, carbs)
Arguments
id |
Character or numeric participant identifier. |
carbs |
A data frame containing the carbohydrate data from a mylife file. |
Value
A data frame containing the formatted and cleaned carbohydrate data.
NULL if there is no carbohydrate data.
Coerce a vector to a target atomic type
Description
Wrapper around the as.* functions, dispatching on
a target type name as returned by .most_general_class.aidR. An
unrecognised target leaves the vector unchanged.
Usage
.coerce_to.aidR(x, target)
Arguments
x |
A vector to coerce. |
target |
Length-one character string naming the target type: one of
|
Value
x coerced to target, or x unchanged if
target is not recognised.
Convert blood glucose units to mg/dL in a CareLink file
Description
Convert blood glucose units to mg/dL in a CareLink file
Usage
.convert_BG_units_carelink.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame, with all mmol/L columns converted to mg/dL and renamed accordingly.
Convert timestamps from an Excel file formatted as fractional days
Description
Convert timestamps from an Excel file formatted as fractional days
Usage
.convert_excel_datetime.aidR(date_val, time_val)
Arguments
date_val |
The fractional value for the date. |
time_val |
The fractional value for the time of day. |
Value
A timestamp in POSIXct, or NULL if the values are not numeric
and must be parsed as strings instead.
Convert timestamps from an Excel file formatted as serial numbers
Description
Convert timestamps from an Excel file formatted as serial numbers
Usage
.convert_excel_serial.aidR(serial)
Arguments
serial |
The serial value. |
Value
A timestamp in POSIXct.
Convert timestamps of a CareLink file to POSIXct timestamps
Description
Convert timestamps of a CareLink file to POSIXct timestamps
Usage
.convert_timestamp_carelink.aidR(timestamp, date_val = NULL, time_val = NULL)
Arguments
timestamp |
The timestamp from the file. |
date_val |
The fractional value for the date, used if timestamp can not be parsed directly. |
time_val |
The fractional value for the time of day, used if timestamp can not be parsed directly. |
Value
A vector of timestamps in POSIXct.
Create a key linking bolus and carbohydrate entries of the same event
Description
Some exports record which carbohydrate entry triggered which bolus based on
information from the bolus calculator. To keep this link after splitting the
data when cleaning, a unique identifier is created that is stored in both
bolus and carbs (no link is encoded as NA).
Usage
.create_link_id.aidR(id, ..., linked = TRUE)
Arguments
id |
Participant identifier. |
... |
One or more vectors of equal length, with one element per event, which together describe the event. |
linked |
Logical vector with one element per event (or a single value),
|
Details
The key is built from the content of the event and consists of the
participant id and the fields passed in ...
(e.g. timestamp and amounts), separated by "|". Events that are
identical in all fields are numbered in the order they appear in the export,
which makes the key unique by construction. Identifiers given by the export
are only used to find out which entries belong together, never as the key
itself.
Value
A character vector with one key per event, NA where
linked is not TRUE.
The insulin delivered on one day, for the header of the therapy panel
Description
Uses the daily totals of data where they are available, since a
platform that reports them itself covers insulin that the individual data
points may not (e.g. the basal delivered in automated mode by an Omnipod).
Where they are absent, the day is summed over the data that is drawn.
Usage
.daily_insulin_totals.aidR(data, id, day, basal, bolus)
Arguments
data |
A list with the standardized aidR data frames, named by aidR type
( |
id |
Character string with the participant identifier. |
day |
The day to total, as a |
basal |
The basal data of that individual and that day, or |
bolus |
The bolus data of that individual and that day, or |
Value
A named numeric vector with entries basal, bolus and
total, in units. An entry is NA where the insulin is not
recorded, and total is NA as soon as either part is.
Detect the separator of a CSV file
Description
Detects whether a CSV file uses a comma or semicolon as the column separator.
Usage
.detect_csv_separator.aidR(file)
Arguments
file |
Path to the CSV file. |
Value
The detected separator as a character string.
Determine the device name(s) recorded for one data type
Description
Determine the device name(s) recorded for one data type
Usage
.diax_device.aidR(type, df)
Arguments
type |
One of |
df |
The corresponding standardized aidR data frame. |
Value
A character string with the device name(s), comma-separated if more
than one is present, or NA if no device is recorded.
Name of the column holding the device name, per aidR data type
Description
Name of the column holding the device name, per aidR data type
Usage
.diax_device_col.aidR()
Value
A named list, mapping aidR type names to column names (NA if
no device is recorded for that type).
Build a full DIAX list for one individual
Description
Build a full DIAX list for one individual
Usage
.diax_list.aidR(id, data_id)
Arguments
id |
Character or numeric participant identifier, stored as |
data_id |
A list with the standardized aidR data frames for one
individual, named by aidR type ( |
Value
A list following the DIAX specification.
Build the metadata section of a DIAX list
Description
Build the metadata section of a DIAX list
Usage
.diax_metadata.aidR(data_id)
Arguments
data_id |
A list with the standardized aidR data frames present for
one individual, named by aidR type ( |
Value
A named list to be used as the metadata entry of the DIAX list.
Describe the timestamp convention used, for the DIAX metadata
Description
The description depends on whether the timezone offset is known for all, some or none of the data points.
Usage
.diax_metadata_time.aidR(data_id)
Arguments
data_id |
A list with the standardized aidR data frames present for
one individual, named by aidR type ( |
Value
A named list to be used as the time entry of the DIAX metadata.
Build one DIAX time/value series from a standardized aidR data frame
Description
Build one DIAX time/value series from a standardized aidR data frame
Usage
.diax_series.aidR(type, df)
Arguments
type |
One of |
df |
The corresponding standardized aidR data frame. |
Value
A list with entries time and value.
Mapping from aidR data types to DIAX field names
Description
Mapping from aidR data types to DIAX field names
Usage
.diax_series_map.aidR()
Value
A named list, mapping aidR type names to DIAX field names.
Name of the column holding the series value, per aidR data type
Description
Name of the column holding the series value, per aidR data type
Usage
.diax_value_col.aidR()
Value
A named list, mapping aidR type names to column names.
Draw a leader line from a moved marker to the time it occurred
Description
Only markers that were actually moved by .spread_markers.aidR
get a line, ending in a small tick at the true time.
Usage
.draw_leader_lines.aidR(x_true, x_drawn, y_marker, y_anchor, tick, col, tol)
Arguments
x_true |
Numeric vector with the times the markers occurred, in hours. |
x_drawn |
Numeric vector with the positions the markers are drawn at. |
y_marker |
Numeric, the edge of the marker the line starts at. |
y_anchor |
Numeric, the height the line points down to. |
tick |
Numeric, the height of the tick at the true time. |
col |
Character string with the colour of the line. |
tol |
Numeric, how far a marker has to have moved to get a line. Markers nudged by less than this are drawn close enough to their time that a line would only add clutter. |
Value
No return value, called for side effects: the lines are drawn.
Extract the estimated absorption duration from the Food sheet of a Tidepool export
Description
The duration is either part of the JSON string in the Nutrition column,
or part of the JSON string in the Payload column.
Usage
.extract_estimated_absorption_duration_tidepool.aidR(row, data)
Arguments
row |
The current row index to parse. |
data |
The full data frame with the food data from a Tidepool file. |
Value
A numeric value with the estimated absorption duration in seconds,
NA if not found.
Extract the net carbohydrate amount from the Nutrition column of the Food sheet
Description
Extract the net carbohydrate amount from the Nutrition column of the Food sheet
Usage
.extract_net_carbs_tidepool.aidR(json_str)
Arguments
json_str |
A character string in JSON format, containing the net carbohydrate amount. |
Value
A numeric value with the net carbohydrate amount.
Filter CGM data
Description
Filter CGM data
Usage
.filter_cgm.aidR(
cgm,
truncate_min_cgm = 40,
truncate_max_cgm = 400,
min_minutes_difference_cgm = 5
)
Arguments
cgm |
A data frame containing the cleaned CGM data for one individual. |
truncate_min_cgm |
CGM values smaller than this threshold will be truncated. Default 40 mg/dL, if NULL, no filtering is performed. |
truncate_max_cgm |
CGM values larger than this threshold will be truncated. Default 400 mg/dL, if NULL, no filtering is performed. |
min_minutes_difference_cgm |
CGM values are downsampled to this time interval (in minutes). Default 5 minutes, if NULL, no downsampling is performed. |
Value
A data frame with the filtered CGM data.
Remove near-duplicate entries from different formats
Description
The same entry exported by two platforms may differ slightly, e.g. in the
timestamp (rounding), in the value (rounding) or because one platform
provides more details (e.g. a label). Two entries of the same data
type are near-duplicates if they
come from different formats
have the same
unitlie at most
max_minutesapartdiffer in value by at most the tolerance of the data type (
carbs: 1 g,SMBG: 1 mg/dL,bolus: 0.05 U,basal: 0.05 U/h).
Basal rates change frequently, so that neighbouring entries often have
similar rates. For basal, two entries must therefore lie at most
max_minutes_basal apart and their duration must differ by at
most tolerance_basal_duration. Entries with a missing duration
are never considered near-duplicates.
Of each pair of duplicates, one entry is kept: the one with a link_id,
otherwise the one with more information. Its timestamp and value are used,
and its missing information (e.g. a label) is filled from the other
entry. If information was filled, both formats are joined with a /
(e.g. "glooko/tidepool").
Usage
.filter_near_duplicates.aidR(
data_id,
max_minutes = 5,
tolerance_carbs = 1,
tolerance_SMBG = 1,
tolerance_bolus = 0.05,
tolerance_basal = 0.05,
tolerance_basal_duration = 1/60,
max_minutes_basal = 2
)
Arguments
data_id |
A list with all data found for one individual (cleaned), with one entry per data type. |
max_minutes |
Maximum time difference (in minutes) between two duplicates. |
tolerance_carbs |
Tolerance for detecting duplicate carb entries, default 1 g. |
tolerance_SMBG |
Tolerance for detecting duplicate SMBG entries, default 1 mg/dL. |
tolerance_bolus |
Tolerance for detecting duplicate bolus entries, default 0.05 U. |
tolerance_basal |
Tolerance for detecting duplicate basal rates, default 0.05 U/h. |
tolerance_basal_duration |
Tolerance for the |
max_minutes_basal |
Maximum time difference (in minutes) between two duplicate basal entries. |
Details
A warning is given if the entries of two formats match better when shifted
by one hour, see .check_time_shift.aidR.
Value
data_id without the duplicates. Removed rows are logged
in the attribute removed, see removed_entries.
Remove carbohydrate entries that were overwritten by another entry
Description
See filter_carbs() for filtering rules. The zero bolus rows are removed
from the bolus data as well, and all removed rows are logged.
Usage
.filter_overwritten_carbs.aidR(data_id, max_minutes_overwrite = 2)
Arguments
data_id |
A list with all data found for one individual. |
max_minutes_overwrite |
Maximum time difference (in minutes) between the overwritten entry and another entry. |
Value
data_id without the overwritten entries.
Filter a character vector to retain only recognized data file extensions
Description
Removes file paths whose extensions match a list of known non-data formats (PNG, PDF, BIB, JPG, JPEG, TXT, JSON). The check is case-insensitive.
Usage
.filter_relevant_files.aidR(filenames)
Arguments
filenames |
Character vector. File paths to filter. |
Value
A character vector containing only the paths whose extensions are not in the ignored list. May be of length 0 if all inputs are filtered out.
Find near-duplicate entries from different formats
Description
Find near-duplicate entries from different formats
Usage
.find_near_duplicates.aidR(
df,
col,
tol,
max_minutes = 5,
col2 = NULL,
tol2 = NULL
)
Arguments
df |
A data frame with the cleaned data of one data type, sorted by
|
col |
Name of the column holding the value. |
tol |
Maximum difference in value between two near-duplicates. |
max_minutes |
Maximum time difference (in minutes) between two near-duplicates. |
col2 |
Optional name of a second column that must match as well (e.g.
the |
tol2 |
Maximum difference in |
Value
A list with the row indices of the entries to remove
(remove) and of the entry kept instead of each (keep).
Find carbohydrate entries that were overwritten by another entry
Description
Find carbohydrate entries that were overwritten by another entry
Usage
.find_overwritten_carbs.aidR(carbs, bolus, max_minutes_overwrite = 2)
Arguments
carbs |
A data frame containing the cleaned carbohydrate data for one individual. |
bolus |
A data frame containing the cleaned bolus data for one individual. |
max_minutes_overwrite |
Maximum time difference (in minutes) between the overwritten entry and another entry. |
Value
A list with the row indices of the overwritten carbs
(carbs), of the closest other entry of each (close_carbs)
and of the zero bolus rows to remove (bolus).
Find series of slowly absorbed carbohydrates that Glooko split into 30-minute chunks
Description
Find series of slowly absorbed carbohydrates that Glooko split into 30-minute chunks
Usage
.find_slow_carbs.aidR(carbs)
Arguments
carbs |
A data frame containing the cleaned carbohydrate data of one Glooko bolus file. |
Value
A list with one element per series, holding the row indices of its chunks in time order.
Format and clean SMBG data from a Glooko export
Description
Format and clean SMBG data from a Glooko export
Usage
.format_SMBG_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the SMBG data from a Glooko file. |
Value
A data frame containing the formatted and cleaned SMBG data.
Format and clean SMBG data from a Tidepool export
Description
Format and clean SMBG data from a Tidepool export
Usage
.format_SMBG_tidepool.aidR(id, SMBG)
Arguments
id |
Character or numeric participant identifier. |
SMBG |
A data frame containing the SMBG data from a Tidepool file. |
Value
A data frame containing the formatted and cleaned SMBG data.
NULL if the export contains no SMBG sheet.
Format and clean basal data from a Glooko export
Description
Format and clean basal data from a Glooko export
Usage
.format_basal_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the basal data from a Glooko file. |
Value
A data frame containing the formatted and cleaned basal data.
Format and clean basal data from a Tandem Source export
Description
Tandem Source reports the insulin delivered since the previous entry; the rate is obtained by dividing it by the duration until the next entry.
Usage
.format_basal_tandem_source.aidR(id, basal)
Arguments
id |
Character or numeric participant identifier. |
basal |
A data frame containing the basal data from a Tandem Source file. |
Value
A data frame containing the formatted and cleaned basal data.
Format and clean basal data from a Tidepool export
Description
Format and clean basal data from a Tidepool export
Usage
.format_basal_tidepool.aidR(id, basal)
Arguments
id |
Character or numeric participant identifier. |
basal |
A data frame containing the basal data from a Tidepool file. |
Value
A data frame containing the formatted and cleaned basal data.
Format and clean basal data from a YourLoops export
Description
Format and clean basal data from a YourLoops export
Usage
.format_basal_yourloops.aidR(id, basal)
Arguments
id |
Character or numeric participant identifier. |
basal |
A data frame containing the basal data from a YourLoops file. |
Value
A data frame containing the formatted and cleaned basal data.
Format and clean SMBG data from a Tandem Source export
Description
Format and clean SMBG data from a Tandem Source export
Usage
.format_bg_tandem_source.aidR(id, bg)
Arguments
id |
Character or numeric participant identifier. |
bg |
A data frame containing the SMBG data from a Tandem Source file. |
Value
A data frame containing the formatted and cleaned SMBG data.
Format and clean carbohydrate data from the Bolus Calculator sheet of a Tidepool export
Description
Format and clean carbohydrate data from the Bolus Calculator sheet of a Tidepool export
Usage
.format_bolus_calculator_tidepool.aidR(id, bolus_calculator, link_id = NULL)
Arguments
id |
Character or numeric participant identifier. |
bolus_calculator |
A data frame containing the bolus calculator data from a Tidepool file. |
link_id |
A character vector with one key per row of
|
Value
A data frame containing the formatted and cleaned carbohydrate data.
NULL if no carbohydrates were entered.
Format and clean bolus data from a Glooko export
Description
Format and clean bolus data from a Glooko export
Usage
.format_bolus_glooko.aidR(id, data, link_id = NA)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the bolus data from a Glooko file. |
link_id |
A character vector with one key per row of |
Value
A data frame containing the formatted and cleaned bolus data.
Format and clean bolus data from a Tandem Source export
Description
Format and clean bolus data from a Tandem Source export
Usage
.format_bolus_tandem_source.aidR(id, bolus, link_id = NA)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a Tandem Source file. |
link_id |
A character vector with one key per row of |
Value
A data frame containing the formatted and cleaned bolus data.
Format and clean bolus data from a Tidepool export
Description
Format and clean bolus data from a Tidepool export
Usage
.format_bolus_tidepool.aidR(id, bolus, link_id = NULL)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a Tidepool file. |
link_id |
A character vector with one key per row of |
Value
A data frame containing the formatted and cleaned bolus data.
Format and clean bolus data from a YourLoops export
Description
Biphasic boluses are treated as two individual normal boluses, but are still
flagged as biphasic in the type column.
Usage
.format_bolus_yourloops.aidR(id, bolus)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a YourLoops file. |
Value
A data frame containing the formatted and cleaned bolus data.
Format and clean carbohydrate data from a Glooko export
Description
Format and clean carbohydrate data from a Glooko export
Usage
.format_carbs_glooko.aidR(id, data, link_id = NA)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the bolus data from a Glooko file, which holds the carbohydrates entered into the bolus calculator. |
link_id |
A character vector with one key per row of |
Value
A data frame containing the formatted and cleaned carbohydrate data.
Format and clean carbohydrate data from a Tandem Source export
Description
Format and clean carbohydrate data from a Tandem Source export
Usage
.format_carbs_tandem_source.aidR(id, carbs, link_id = NA)
Arguments
id |
Character or numeric participant identifier. |
carbs |
A data frame containing the bolus data from a Tandem Source file, which holds the carbohydrates entered into the bolus calculator. |
link_id |
A character vector with one key per row of |
Value
A data frame containing the formatted and cleaned carbohydrate data.
Format and clean carbohydrate data from a YourLoops export
Description
Format and clean carbohydrate data from a YourLoops export
Usage
.format_carbs_yourloops.aidR(id, carbs)
Arguments
id |
Character or numeric participant identifier. |
carbs |
A data frame containing the meal data from a YourLoops file. |
Value
A data frame containing the formatted and cleaned carbohydrate data.
Format and clean CGM data from a Dexcom Clarity export
Description
Format and clean CGM data from a Dexcom Clarity export
Usage
.format_cgm_dexcom_clarity.aidR(id, cgm)
Arguments
id |
Character or numeric participant identifier. |
cgm |
A data frame containing the CGM data from a Dexcom Clarity file. |
Value
A data frame containing the formatted and cleaned CGM data.
Format and clean CGM data from a Glooko export
Description
Format and clean CGM data from a Glooko export
Usage
.format_cgm_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the CGM data from a Glooko file. |
Value
A data frame containing the formatted and cleaned CGM data.
Format and clean CGM data from a Tandem Source export
Description
Format and clean CGM data from a Tandem Source export
Usage
.format_cgm_tandem_source.aidR(id, cgm)
Arguments
id |
Character or numeric participant identifier. |
cgm |
A data frame containing the CGM data from a Tandem Source file. |
Value
A data frame containing the formatted and cleaned CGM data.
Format and clean CGM data from a Tidepool export
Description
Format and clean CGM data from a Tidepool export
Usage
.format_cgm_tidepool.aidR(id, cgm)
Arguments
id |
Character or numeric participant identifier. |
cgm |
A data frame containing the CGM data from a Tidepool file. |
Value
A data frame containing the formatted and cleaned CGM data.
Format and clean CGM data from a YourLoops export
Description
Format and clean CGM data from a YourLoops export
Usage
.format_cgm_yourloops.aidR(id, cgm)
Arguments
id |
Character or numeric participant identifier. |
cgm |
A data frame containing the CGM data from a YourLoops file. |
Value
A data frame containing the formatted and cleaned CGM data.
Format date ranges
Description
Format date ranges
Usage
.format_date_ranges.aidR(dates)
Arguments
dates |
A vector with dates. |
Value
A string with all consecutive dates collapsed into ranges.
Format timestamps according to the DIAX ISO 8601 convention
Description
Per the DIAX specification, timestamps are "Y-m-d H:M:S" when the
timezone is unknown, or "Y-m-d H:M:S Z" (offset appended, no colon)
when it is known.
Usage
.format_diax_time.aidR(timestamp, timezone_offset)
Arguments
timestamp |
A vector of timestamps, in local time. |
timezone_offset |
A numeric vector (same length as |
Value
A character vector of formatted timestamps, e.g.
"2025-09-27 14:02:20 -0400" when the offset is known, or
"2025-09-27 14:02:20" when it is not.
Format and clean carbohydrate data from the Food sheet of a Tidepool export
Description
Format and clean carbohydrate data from the Food sheet of a Tidepool export
Usage
.format_food_tidepool.aidR(id, food)
Arguments
id |
Character or numeric participant identifier. |
food |
A data frame containing the food data from a Tidepool file. |
Value
A data frame containing the formatted and cleaned carbohydrate data.
Format any file from a Glooko export by configuring timestamps and numeric values
Description
Format any file from a Glooko export by configuring timestamps and numeric values
Usage
.format_glooko_file.aidR(filename, time_cols, numeric_cols)
Arguments
filename |
Character string with the filename to be formatted. |
time_cols |
A numeric vector corresponding to the column indices that contain timestamps to be formatted. |
numeric_cols |
A numeric vector corresponding to the column indices that contain numeric values to be formatted. |
Value
A data frame with the content of the file and properly formatted time- and numeric columns.
Format and clean rescue carbohydrate data from a YourLoops export
Description
Format and clean rescue carbohydrate data from a YourLoops export
Usage
.format_rescuecarbs_yourloops.aidR(id, carbs)
Arguments
id |
Character or numeric participant identifier. |
carbs |
A data frame containing the rescue carbohydrate data from a YourLoops file. |
Value
A data frame containing the formatted and cleaned carbohydrate data, flagged as hypoglycemia treatment.
Format any file from a Tandem Source export by configuring timestamps
Description
Format any file from a Tandem Source export by configuring timestamps
Usage
.format_tandem_source_file.aidR(filename, time_cols, date_cols)
Arguments
filename |
Character string with the filename to be formatted. |
time_cols |
A numeric vector corresponding to the column indices that contain timestamps to be formatted. |
date_cols |
A numeric vector corresponding to the column indices that contain dates to be formatted. |
Value
A data frame with the content of the file and properly formatted time- and numeric columns.
Format timestamps to get local (wall-clock) time of a YourLoops export
Description
Timestamps are given in Zulu (UTC) time; the timezone offset is added to obtain local time. Data frames without these two columns are left unchanged.
Usage
.format_timestamp_yourloops.aidR(file)
Arguments
file |
A data frame obtained from reading a YourLoops file. |
Value
A data frame where the timestamps have been converted to local time.
Total basal insulin per day, as reported by a Glooko export
Description
Total basal insulin per day, as reported by a Glooko export
Usage
.format_total_basal_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the daily aggregated insulin data from a Glooko file. |
Value
A data frame with columns id, format, date,
total_basal and source, holding one row per day.
Total basal insulin per day, as reported by a Tandem Source export
Description
Tandem Source reports the basal insulin delivered in each hour of the day, in one file with one row per day and one column per hour. Summing over the 24 hourly columns gives the total basal insulin delivered on that day.
Usage
.format_total_basal_tandem_source.aidR(id, hourly_basal)
Arguments
id |
Character or numeric participant identifier. |
hourly_basal |
A data frame containing the hourly basal data from a Tandem Source file. |
Value
A data frame with columns id, format, date,
total_basal and source, holding one row per day.
Total bolus insulin per day, as reported by a Glooko export
Description
Total bolus insulin per day, as reported by a Glooko export
Usage
.format_total_bolus_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the daily aggregated insulin data from a Glooko file. |
Value
A data frame with columns id, format, date,
total_bolus and source, holding one row per day.
Format and clean daily aggregated insulin data from a Glooko export
Description
Format and clean daily aggregated insulin data from a Glooko export
Usage
.format_total_insulin_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the daily aggregated insulin data from a Glooko file. |
Value
A data frame containing the formatted and cleaned total insulin data.
Write an amount of insulin for the plot
Description
Write an amount of insulin for the plot
Usage
.format_units.aidR(x)
Arguments
x |
Numeric, an amount of insulin in units, or |
Value
A character string, "-" where x is NA.
Recursively traverse a directory and return all contained files
Description
ZIP archives encountered at any level are automatically extracted to temporary directories and traversed recursively, including nested ZIP files.
Usage
.get_all_files_in_path.aidR(path)
Arguments
path |
Character string. Path to a file or directory. |
Details
macOS metadata files and folders such as __MACOSX, .DS_Store, and ._* files are ignored automatically.
ZIP archives are extracted into temporary directories created via
tempfile(). Invalid or corrupted ZIP archives are skipped with a warning.
Value
A character vector containing normalized paths to all discovered non-ZIP files.
Parse all entries corresponding to the bolus wizard in a CareLink export
Description
Parse all entries corresponding to the bolus wizard in a CareLink export
Usage
.get_carelink_BWZ.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to CGM data in a CareLink export
Description
Parse all entries corresponding to CGM data in a CareLink export
Usage
.get_carelink_CGM.aidR(df, sensor_name)
Arguments
df |
A data frame obtained from reading a CareLink file. |
sensor_name |
A character string with the name of the sensor, |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to SMBG in a CareLink export
Description
Parse all entries corresponding to SMBG in a CareLink export
Usage
.get_carelink_SMBG.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to the daily aggregated auto (closed-loop) insulin in a CareLink export
Description
Parse all entries corresponding to the daily aggregated auto (closed-loop) insulin in a CareLink export
Usage
.get_carelink_aggr_auto_insulin.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to alerts in a CareLink export
Description
Parse all entries corresponding to alerts in a CareLink export
Usage
.get_carelink_alerts.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to bolus deliveries in a CareLink export
Description
Parse all entries corresponding to bolus deliveries in a CareLink export
Usage
.get_carelink_bolus.aidR(df, pump_name)
Arguments
df |
A data frame obtained from reading a CareLink file. |
pump_name |
A character string with the name of the pump, |
Value
A data frame with the corresponding entries.
Find the carbohydrate columns present in a CareLink export
Description
Find the carbohydrate columns present in a CareLink export
Usage
.get_carelink_carb_variant.aidR(df)
Arguments
df |
A data frame containing the bolus wizard entries from a CareLink file. |
Value
A list with the column names of the carbohydrate input (input)
and the carbohydrate ratio (ratio), as well as the corresponding
unit (unit).
Parse all entries corresponding to correction boluses in a CareLink export
Description
Parse all entries corresponding to correction boluses in a CareLink export
Usage
.get_carelink_correction_bolus_info.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to device changes in a CareLink export
Description
Parse all entries corresponding to device changes in a CareLink export
Usage
.get_carelink_device_changes.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to insulin action curve over time in a CareLink export
Description
Parse all entries corresponding to insulin action curve over time in a CareLink export
Usage
.get_carelink_insulin_action_curve_over_time.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to prime events in a CareLink export
Description
Parse all entries corresponding to prime events in a CareLink export
Usage
.get_carelink_prime.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to the scheduled basal rates in a CareLink export
Description
Parse all entries corresponding to the scheduled basal rates in a CareLink export
Usage
.get_carelink_scheduled_basal_rates.aidR(df, pump_name)
Arguments
df |
A data frame obtained from reading a CareLink file. |
pump_name |
A character string with the name of the pump, |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to sensor calibration in a CareLink export
Description
Parse all entries corresponding to sensor calibration in a CareLink export
Usage
.get_carelink_sensor_calibration.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to sensor exceptions in a CareLink export
Description
Parse all entries corresponding to sensor exceptions in a CareLink export
Usage
.get_carelink_sensor_exceptions.aidR(df)
Arguments
df |
A data frame obtained from reading a CareLink file. |
Value
A data frame with the corresponding entries.
Parse all entries corresponding to temporary basal rates in a CareLink export
Description
Parse all entries corresponding to temporary basal rates in a CareLink export
Usage
.get_carelink_temp_basal.aidR(df, pump_name)
Arguments
df |
A data frame obtained from reading a CareLink file. |
pump_name |
A character string with the name of the pump, |
Value
A data frame with the corresponding entries.
A lookup with Glooko file characteristics
Description
A lookup with Glooko file characteristics
Usage
.get_glooko_file_lookup.aidR()
Value
A list with data types and their expected file formats, including the number of columns, the column indices of the time- and numeric columns and expected keywords in the header.
Find the separator used in a Dexcom Clarity export
Description
Find the separator used in a Dexcom Clarity export
Usage
.get_sep_dexcom_clarity.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A character string with the separator (";" or ","), or
NULL if the file does not come from a Dexcom Clarity export.
A lookup with Tandem Source file characteristics
Description
A lookup with Tandem Source file characteristics
Usage
.get_tandem_source_file_lookup.aidR()
Value
A list with data types and their expected file formats, including the number of columns, the column indices of the time- and numeric columns and expected keywords in the header.
A lookup with YourLoops file characteristics
Description
A lookup with YourLoops file characteristics
Usage
.get_yourloops_file_lookup.aidR()
Value
A list with data types and their expected headers.
Get the data type of a file from a YourLoops export
Description
Get the data type of a file from a YourLoops export
Usage
.get_yourloops_file_type.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A character string with the data type, or NULL if there was no
match. Throws an error if multiple data types matched.
Harmonise column types across a list of data frames
Description
Prepares a list of data frames for row-binding by resolving column type mismatches. For every column present in more than one data frame, the classes are compared: if they all agree the column is left untouched, otherwise every occurrence of the column is coerced to the most general common type.
Usage
.harmonise_column_types.aidR(dfs)
Arguments
dfs |
A list of data frames. |
Value
The input list with mismatched columns coerced to a common type.
Prefix identifying an individual in a message
Description
Prefix identifying an individual in a message
Usage
.id_prefix.aidR(id)
Arguments
id |
Character participant identifier, or |
Value
A string, empty if id is NA.
All participant identifiers found in a list of standardized data
Description
Collects the ids of every data frame that carries an id column, so
that the data of a single individual (the output of parse_data)
and the data of multiple individuals (the output of merge_all)
can be treated alike.
Usage
.ids_in_data.aidR(data)
Arguments
data |
A list with all data found for one or several individuals. |
Value
A character vector with the ids found, in the order in which they
appear. NA_character_ if no id could be determined (e.g. because
every data frame is empty), so that the data is still checked once, then as
an individual of unknown id.
Check if a file comes from a CareLink export
Description
CareLink is used for Medtronic MiniMed devices only, which is what the check looks for in the file header.
Usage
.is_carelink_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a CareLink export.
Check if a file comes from a Dexcom Clarity export
Description
Check if a file comes from a Dexcom Clarity export
Usage
.is_dexcom_clarity_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a Dexcom Clarity export.
Check if a Glooko file corresponds to a particular data type
Description
Check if a Glooko file corresponds to a particular data type
Usage
.is_glooko_file_type.aidR(
filename,
expected_num_cols,
numeric_cols,
non_numeric_cols = c(),
expected_keyword = NULL
)
Arguments
filename |
Character string with the filename to be checked. |
expected_num_cols |
A numeric value with the expected number of columns of that file. |
numeric_cols |
A numeric vector corresponding to the column indices that contain numeric values. |
non_numeric_cols |
A numeric vector corresponding to the column indices that should not contain numeric values. |
expected_keyword |
A list with keys |
Value
A logical value: TRUE if the file matches the data type format.
FALSE for empty files, whose columns can not be checked.
Check if a file comes from a Glooko export
Description
Check if a file comes from a Glooko export
Usage
.is_glooko_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a Glooko export.
Check if a file comes from a mylife export
Description
Check if a file comes from a mylife export
Usage
.is_mylife_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a mylife export.
Check if a vector can be converted to numeric values
Description
Check if a vector can be converted to numeric values
Usage
.is_numeric_col.aidR(vec)
Arguments
vec |
Character vector to be checked. |
Value
A logical value: TRUE if the vector can be converted to numeric values.
Check if a Tandem Source file corresponds to a particular data type
Description
Check if a Tandem Source file corresponds to a particular data type
Usage
.is_tandem_source_file_type.aidR(
filename,
expected_num_cols,
numeric_cols,
non_numeric_cols = c(),
expected_keyword = NULL
)
Arguments
filename |
Character string with the filename to be checked. |
expected_num_cols |
A numeric value with the expected number of columns of that file. |
numeric_cols |
A numeric vector corresponding to the column indices that contain numeric values. |
non_numeric_cols |
A numeric vector corresponding to the column indices that should not contain numeric values. |
expected_keyword |
A list with keys |
Value
A logical value: TRUE if the file matches the data type format.
FALSE for empty files, whose columns can not be checked.
Check if a file comes from a Tandem Source export
Description
Check if a file comes from a Tandem Source export
Usage
.is_tandem_source_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a Tandem Source export.
Check if a file comes from a Tidepool export
Description
Check if a file comes from a Tidepool export
Usage
.is_tidepool_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a Tidepool export.
Check if a file comes from a YourLoops export
Description
Check if a file comes from a YourLoops export
Usage
.is_yourloops_format.aidR(filename)
Arguments
filename |
Character string with the filename to be checked. |
Value
A logical value: TRUE if the file comes from a YourLoops export.
Link boluses and carbohydrate entries of a Glooko bolus file
Description
Each row of the bolus file corresponds to a bolus together with the
carbohydrates entered for it in the bolus calculator. Rows with carbohydrates
get a link_id.
Usage
.link_bolus_carbs_glooko.aidR(id, data)
Arguments
id |
Character or numeric participant identifier. |
data |
A data frame containing the bolus data from a Glooko file. |
Value
A character vector with one key per row of data, NA
for rows without carbohydrates.
Link boluses and carbohydrate entries of a Tandem Source bolus file
Description
Each row of the bolus file corresponds to a bolus together with the
carbohydrates entered for it in the bolus calculator. Rows with carbohydrates
get a link_id, built from the completion time, the carbohydrates, and
the insulin delivered.
Usage
.link_bolus_carbs_tandem_source.aidR(id, bolus)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a Tandem Source file. |
Value
A character vector with one key per row of bolus, NA
for rows without carbohydrates.
Link boluses and carbohydrate entries of a Tidepool export
Description
Use the column Bolus of the Bolus Calculator sheet and the column
Id of the Bolus sheet to match bolus and carbohydrate entries. Create
a new identifier based on local time, normal and extended amount, and
duration as for all other formats.
Usage
.link_bolus_carbs_tidepool.aidR(id, bolus, bolus_calculator)
Arguments
id |
Character or numeric participant identifier. |
bolus |
A data frame containing the bolus data from a Tidepool file. |
bolus_calculator |
A data frame containing the bolus calculator data from a Tidepool file. |
Value
A list with entries bolus and bolus_calculator,
holding one key per row of the respective data frame (NA for rows
without a link). NULL if the columns needed are missing.
Store removed rows with a reason
Description
Store removed rows with a reason
Usage
.log_removed.aidR(data_id, type, rows, reason)
Arguments
data_id |
A list with all data found for one individual. |
type |
The data type the rows were removed from (e.g. |
rows |
A data frame with the removed rows. |
reason |
Why the rows were removed. |
Value
data_id with rows added to the attribute
removed, with the column removed_reason.
Match the column types of multiple data frames
Description
Empty data frames are replaced by a zero-row data frame with the column types of the first non-empty data frame.
Usage
.match_types_before_merging.aidR(dfs_new)
Arguments
dfs_new |
A list of data frames. |
Value
A list of data frames, with harmonized types.
Merge all data available for one individual and one data type
Description
Merge all data available for one individual and one data type
Usage
.merge_by_type.aidR(data_id)
Arguments
data_id |
A list with all data found for one individual, with one entry per parsed file. |
Value
A list with all data found for one individual, with one entry per data
type. Rows removed during cleaning (attribute removed of each file)
are merged by type as well and stored in the attribute removed.
Merge all data available for one individual, separately per data type
Description
Merge all data available for one individual, separately per data type
Usage
.merge_per_id.aidR(data_id)
Arguments
data_id |
A list with all data found for one individual, with one entry per parsed file. |
Value
A list with all data found for one individual, merged for each data
type and sorted in time. Identical entries are removed, ignoring the format
column (e.g. the same data downloaded from two platforms is kept once, with the
format of its first occurrence). Entries where all measurement columns are NA are removed.
For total_basal and total_bolus, only the largest value is kept for days that occur more than once.
Near-duplicates from different formats are removed.
Merge slowly absorbed carbohydrates that Glooko split into 30-minute chunks
Description
See clean.glooko() for the rules. The other chunks and their zero
boluses are removed, and all removed rows are logged.
Usage
.merge_slow_carbs.aidR(data_id)
Arguments
data_id |
A named list with the cleaned |
Value
data_id with each series merged into its first entry.
Determine the most general atomic type among a set of classes
Description
Given the classes of a single column as it appears across several data
frames, returns the name of the most general atomic type that can hold all
of them, following the hierarchy
logical < integer < numeric < character.
If any supplied class is not one of the known atomic types (e.g.
Date), "character" is returned.
Usage
.most_general_class.aidR(classes)
Arguments
classes |
Character vector of class names (typically the first element
of |
Value
A length-one character string, one of "logical",
"integer", "numeric" or "character".
Open a CareLink file
Description
Works if the file is in xlsx or csv format, throws an error otherwise.
Usage
.open_carelink_file.aidR(filename)
Arguments
filename |
Character string with the filename to be opened. |
Value
A data frame with a single column V1, holding each line of the
file as a semicolon-separated string.
Draw a single day of diabetes data for one individual
Description
Draw a single day of diabetes data for one individual
Usage
.plot_single_day.aidR(data, id, day, target, ylim_cgm, min_bolus, units, main)
Arguments
data |
A list with the standardized aidR data frames, named by aidR type
( |
id |
Character string with the participant identifier. |
day |
The day to draw, as a |
target |
Numeric vector of length two with the glucose target range. |
ylim_cgm |
Numeric vector of length two with the limits of the glucose axis. |
min_bolus |
Numeric, the smallest bolus that is drawn in full, in units. Smaller ones are drawn as bare ticks. |
units |
Character string, the units of the glucose data, either
|
main |
Character string with the plot title, |
Value
No return value, called for side effects: one plot is drawn.
Select the data of one individual and one day, for plotting
Description
Select the data of one individual and one day, for plotting
Usage
.prep_plot_data.aidR(df, id, day)
Arguments
df |
A standardized aidR data frame, or |
id |
Character string with the participant identifier. |
day |
The day to select, as a |
Value
The rows of df of that individual and that day, with an
additional column hour_of_day holding the local (wall-clock) time as
a fraction of hours. NULL if there is no such row.
Read a single file and dispatch it to the matching format
Description
Checks whether the file has a recognized extension, then determines which
format it comes from and calls the corresponding read_*() function.
Files with non-data extensions (e.g. PNG, PDF, TXT) are silently ignored.
Unrecognized data files produce a console message.
Usage
.process_file.aidR(filename, id, clean = TRUE, ...)
Arguments
filename |
Character string with the filename to parse. |
id |
Character or numeric participant identifier. |
clean |
Logical, if |
... |
Additional arguments passed on to |
Value
A list with the data found in the file. NULL if the file was
ignored or could not be parsed.
Read the raw content of a CareLink file, split into its sections
Description
Read the raw content of a CareLink file, split into its sections
Usage
.read_carelink_raw.aidR(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
A list with entries dfs, sensor_name and pump_name.
dfs is a list of three data frames containing (1) pump and sensor
events of many different types, (2) daily aggregated auto (closed-loop)
insulin and (3) CGM measurement data. sensor_name and
pump_name are the device
names read from the file header, NA if the header is absent.
Read a file from a Dexcom Clarity export
Description
The separator (";" or ",") is detected automatically, as both
can occur, depending on the language of the export. Glucose values reported
in mmol/L are converted to mg/dL.
Usage
.read_dexcom_clarity_files.aidR(filename)
Arguments
filename |
Character string with the filename of the file to be read. |
Value
A data frame with the CGM data, with the columns timestamp,
device_id, value (in mg/dL) and transmitter_id.
Read the data from a Glooko file
Description
Read the data from a Glooko file
Usage
.read_glooko_file.aidR(filename)
Arguments
filename |
Character string with the filename to be parsed. |
Value
A named list with a single entry, named after the data type of the
file and holding a data frame with formatted timestamps and numeric columns.
NULL if the file is empty. Throws an error if the data type of a
non-empty file could not be determined.
Read the data from a Tandem file
Description
Read the data from a Tandem file
Usage
.read_tandem_source_file.aidR(filename)
Arguments
filename |
Character string with the filename to be parsed. |
Value
A named list with a single entry, named after the data type of the
file and holding a data frame with formatted timestamps and numeric columns.
NULL if the file is empty. Throws an error if the data type of a
non-empty file could not be determined.
Read a sheet from a Tidepool Excel file
Description
Read a sheet from a Tidepool Excel file
Usage
.read_tidepool_sheet.aidR(filename, sheet)
Arguments
filename |
Character string with the filename of the file to be read. |
sheet |
Character string with the name of the sheet to be read. |
Value
A data frame containing the contents of the specified sheet, or
NULL if the sheet does not exist in the file.
Read a file from a YourLoops export
Description
Read a file from a YourLoops export
Usage
.read_yourloops_files.aidR(filename)
Arguments
filename |
Character string with the filename of the file to be read. |
Value
A data frame containing the contents of the file.
Rename bolus data from a Tandem Source export for easier handling
Description
Rename bolus data from a Tandem Source export for easier handling
Usage
.rename_bolus_tandem_source.aidR(bolus)
Arguments
bolus |
A data frame containing the bolus data from a Tandem Source file. |
Value
A data frame containing the renamed bolus data.
Sort data frames of all data types according to timestamps
Description
Sort data frames of all data types according to timestamps
Usage
.sort_by_time.aidR(data_id)
Arguments
data_id |
A list with all data found for one individual, with one entry per data type. |
Value
A list with all data found for one individual, sorted in time.
Move markers apart until they no longer overlap
Description
Markers that are closer together than min_sep are unreadable when they
are drawn at their own time. They are pushed apart, keeping their order and
staying within xlim, so that a leader line can point back at the time
they actually occurred (see .draw_leader_lines.aidR).
Usage
.spread_markers.aidR(x, min_sep, xlim)
Arguments
x |
Numeric vector with the positions of the markers, in hours. |
min_sep |
Numeric, the smallest distance two markers may have, in hours. |
xlim |
Numeric vector of length two with the limits of the axis. |
Value
A numeric vector, the positions at which to draw the markers, in the
order of x.
Keep the rows of one individual only, across all data types
Description
Keep the rows of one individual only, across all data types
Usage
.subset_by_id.aidR(data, id)
Arguments
data |
A list with all data found for one or several individuals. |
id |
Character participant identifier, or |
Value
The input list, with every data frame reduced to the rows of
id. Data frames without an id column are returned unchanged.
Sum a vector, ignoring missing values
Description
Unlike sum(x, na.rm = TRUE), a vector without a single non-missing
value yields NA rather than zero.
Usage
.sum_or_na.aidR(x)
Arguments
x |
A numeric vector. |
Value
The sum over all non-missing values of x, or NA if
x holds no non-missing value.
Total basal insulin delivered per day, summed over the recorded basal rates
Description
Used by all formats that do not report a daily basal aggregate themselves. Note that the resulting total is only complete if the export records the basal rates of the entire day.
Usage
.total_basal_per_day.aidR(basal)
Arguments
basal |
A standardized basal data frame, with columns |
Value
A data frame with columns id, format, date,
total_basal and source, holding one row per day.
NULL if basal is empty.
Total bolus insulin delivered per day, summed over the recorded boluses
Description
Used by all formats that do not report a daily bolus aggregate themselves.
Usage
.total_bolus_per_day.aidR(bolus)
Arguments
bolus |
A standardized bolus data frame, with columns |
Value
A data frame with columns id, format, date,
total_bolus and source, holding one row per day.
NULL if bolus is empty.
Check if data for different types are available for at least one day
Description
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.
Usage
check_completeness(data, necessary_types = c("cgm", "basal", "bolus", "carbs"))
Arguments
data |
A list with all data found for one individual (the output of
|
necessary_types |
A character vector with type names for which data should be available. |
Value
No return value, called for side effects. Issues a message for every individual and data type with missing data.
Examples
# A mylife export contains no CGM and no basal data
path <- system.file("extdata", "mylife_example.csv", package = "aidR")
data <- parse_data(id = "1", paths = path)
check_completeness(data)
# Only require bolus and carbohydrate data
check_completeness(data, necessary_types = c("bolus", "carbs"))
Check if data for different types are available for a range of dates
Description
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.
Usage
check_completeness_range(
data,
first_date,
last_date,
necessary_types = c("cgm", "basal", "bolus", "carbs")
)
Arguments
data |
A list with all data found for one individual (the output of
|
first_date |
A character string representing the first date for which data should be available. |
last_date |
A character string representing the last date (included) for which data should be available. |
necessary_types |
A character vector with type names for which data should be available. |
Value
No return value, called for side effects. Issues a message for every individual and data type with missing days.
Examples
# The example export covers 2026-06-22 only
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- parse_data(id = "1", paths = path)
check_completeness_range(data, first_date = "2026-06-21", last_date = "2026-06-23")
Check that the summed insulin matches the daily totals reported by an export
Description
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).
Usage
check_insulin_totals(data, types = "basal", rel_tol = 0.2, abs_tol = 1)
Arguments
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
|
Details
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.
Value
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.
Examples
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
Generic function for cleaning data
Description
Generic function for cleaning data
Usage
clean(data, id, ...)
Arguments
data |
The data to clean, an instance of one of the format-specific
classes ( |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with the cleaned data, see the format-specific methods
(e.g. clean.glooko).
Format and clean the CareLink data to keep relevant columns only
Description
Format and clean the CareLink data to keep relevant columns only
Usage
## S3 method for class 'carelink'
clean(data, id, ...)
Arguments
data |
An instance of class |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with the cleaned data, with entries cgm,
bolus, carbs (extracted from the bolus wizard
entries) and SMBG.
Format and clean the Dexcom Clarity data to keep relevant columns only
Description
Format and clean the Dexcom Clarity data to keep relevant columns only
Usage
## S3 method for class 'dexcom_clarity'
clean(data, id, ...)
Arguments
data |
An instance of class |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with one element, cgm, containing the cleaned
CGM data.
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 |
id |
Character or numeric participant identifier. |
merge_slow_carbs |
Logical, if |
... |
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.
Format and clean the mylife data to keep relevant columns only
Description
The entry types are identified by their unit, since their labels are language-specific. Note that a mylife export contains no CGM and no basal data.
Usage
## S3 method for class 'mylife'
clean(data, id, ...)
Arguments
data |
An instance of class |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with the cleaned data, with entries bolus,
carbs and SMBG. Entries are NULL if the export holds
no data of that type.
Format and clean the Tandem Source data to keep relevant columns only
Description
Format and clean the Tandem Source data to keep relevant columns only
Usage
## S3 method for class 'tandem_source'
clean(data, id, ...)
Arguments
data |
An instance of class |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with the cleaned data, named according to the data type
of data: cgm, basal, bolus, carbs and
total_bolus (the latter three are extracted from the bolus file;
total_basal (extracted from the hourly basal file) or SMBG.
NULL for all other data types, which are not cleaned.
Format and clean the Tidepool data to keep relevant columns only
Description
Format and clean the Tidepool data to keep relevant columns only
Usage
## S3 method for class 'tidepool'
clean(data, id, ...)
Arguments
data |
An instance of class |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with the cleaned data, with entries cgm,
basal, bolus, SMBG and carbs. Carbohydrates are
taken from the Food sheet or, if that sheet is absent, from the Bolus
Calculator sheet. Only in the latter case are bolus and
carbs linked by link_id; otherwise it is NA.
Format and clean the YourLoops data to keep relevant columns only
Description
Format and clean the YourLoops data to keep relevant columns only
Usage
## S3 method for class 'yourloops'
clean(data, id, ...)
Arguments
data |
An instance of class |
id |
Character or numeric participant identifier. |
... |
Additional arguments passed to methods. |
Value
A named list with the cleaned data, named according to the data type
of data: cgm, basal, bolus or carbs (from
meals or from rescue carbohydrates). NULL for all other data types,
which are not cleaned. Note that a YourLoops export contains no SMBG data.
Filter CGM values
Description
Filter CGM values
Usage
filter_CGM(
data_id,
truncate_min_cgm = 40,
truncate_max_cgm = 400,
min_minutes_difference_cgm = 5
)
Arguments
data_id |
A list with all data found for one individual. Filtering is only performed if the CGM data was cleaned and standardized. |
truncate_min_cgm |
CGM values smaller than this threshold will be truncated. Default 40 mg/dL, if NULL, no filtering is performed. |
truncate_max_cgm |
CGM values larger than this threshold will be truncated. Default 400 mg/dL, if NULL, no filtering is performed. |
min_minutes_difference_cgm |
CGM values are downsampled to this time interval (in minutes). Default 5 minutes, if NULL, no downsampling is performed. |
Value
A list with all data found for one individual, filtered, if necessary.
Examples
path <- system.file("extdata", "tandem_source_example.zip", package = "aidR")
# Read data
data <- parse_data(id = "1", paths = path)
range(data$cgm$value)
length(data$cgm$value)
# Truncate to 40-400 mg/dL and downsample to 5-minute intervals
data_filtered <- filter_CGM(data)
range(data_filtered$cgm$value)
length(data_filtered$cgm$value)
# Truncate only, without downsampling
data_truncated <- filter_CGM(data, min_minutes_difference_cgm = NULL)
range(data_truncated$cgm$value)
length(data_truncated$cgm$value)
Filter carbohydrate entries
Description
Removes carbohydrate entries that were overwritten by another entry.
Usage
filter_carbs(data_id, max_minutes_overwrite = 2)
Arguments
data_id |
A list with all data found for one individual. Filtering is only performed if the carbohydrate and bolus data were cleaned and standardized. |
max_minutes_overwrite |
Maximum time difference (in minutes) between an overwritten entry and another entry. Default 2 minutes. If NULL, nothing is removed. |
Details
In the bolus calculator, carbs may be entered, but the bolus may not be delivered (or cancelled), and the carbs may then be entered again, with a bolus shortly after. Some platforms (e.g. Glooko) export all of these entries.
A carbohydrate entry is removed if
its bolus is zero (found via
link_id)another carbohydrate entry of the same
format(or sharing one, for combined formats such as"glooko/tidepool"), with a differentlink_id, lies at mostmax_minutes_overwriteminutes before or after it.it is not flagged as a hypo treatment (
is_hypo_treatment).
Slowly absorbed carbohydrates merged during cleaning (linked entries with an
estimated_absorption_duration, see clean.glooko) are
never removed and do not count as another entry. The zero bolus linked to a
removed entry is removed from the bolus data as well.
Value
A list with all data found for one individual, filtered, if
necessary. Removed rows are stored in the attribute removed, see
removed_entries().
Examples
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- parse_data(id = "1", paths = path)
nrow(data$carbs)
data_filtered <- filter_carbs(data)
nrow(data_filtered$carbs)
removed_entries(data_filtered)
Convert CGM data to a format compatible with the R-package cgmquantify
Description
Builds the data frame that the metric functions of the R-package
cgmquantify
expect, with columns Time, glucose, Date, time_of_day and
type_of_event. This is the same layout that cgmquantify::readfile()
produces from a Dexcom export.
Usage
get_cgmquantify_format(data, id = NULL)
Arguments
data |
A list with all data found for one individual (the output of
|
id |
Character or numeric participant identifier, naming the individual
to convert. Can be omitted if |
Details
Note that cgmquantify always related to a single subject.
Value
A data frame with columns Time (POSIXct), glucose
(mg/dL), Date, time_of_day and type_of_event
(1 above 180 mg/dL, -1 below 70 mg/dL and 0 in
between), sorted by time and compatible with the R-package cgmquantify.
Examples
path <- system.file("extdata", "dexcom_clarity_example.csv", package = "aidR")
data <- parse_data(id = "1", paths = path)
cgmquantify_df <- get_cgmquantify_format(data)
cgmquantify::summary_glucose(cgmquantify_df)
Convert CGM data to a format compatible with the R-package iglu
Description
Convert CGM data to a format compatible with the R-package iglu
Usage
get_iglu_format(data)
Arguments
data |
A list with all data found for one individual (the output of
|
Value
A data frame with columns id, time and gl,
compatible with the R-package iglu.
Examples
path <- system.file("extdata", "dexcom_clarity_example.csv", package = "aidR")
data <- parse_data(id = "1", paths = path)
iglu_df <- get_iglu_format(data)
iglu::plot_glu(iglu_df)
Merge data available for all individuals, separately per data type
Description
Merge data available for all individuals, separately per data type
Usage
merge_all(
data,
types = c("cgm", "basal", "bolus", "carbs", "SMBG", "total_basal", "total_bolus")
)
Arguments
data |
A named list with the data of each individual (the output of
|
types |
A character vector with the data type names to be merged. Defaults to the five standardized types and the two daily insulin totals. |
Value
A named list with one data frame per data type, holding the data of all individuals. Individuals without data of a given type contribute no rows.
Examples
all_data <- list(
"1" = parse_data("1", system.file("extdata", "glooko_example.zip", package = "aidR")),
"2" = parse_data("2", system.file("extdata", "dexcom_clarity_example.csv", package = "aidR"))
)
combined <- merge_all(all_data)
names(combined)
head(combined$cgm)
table(combined$cgm$id)
# Merge CGM data only
merge_all(all_data, types = "cgm")
Parse data files for a given participant ID
Description
Iterates over one or more paths, discovers all contained files (including inside ZIP archives), and dispatches each file to the appropriate format-specific reader. Supported formats are Glooko, CareLink, mylife, Tidepool, YourLoops, Tandem Source and Dexcom Clarity.
Usage
parse_data(id, paths, clean = TRUE, ...)
Arguments
id |
Character or numeric participant identifier. Used for logging and
stored in the |
paths |
Character vector. One or more file or directory paths to search for data files. Directories are traversed recursively; ZIP archives are extracted automatically. |
clean |
Logical, if |
... |
Additional arguments passed on to the format-specific cleaning
methods, e.g. |
Value
A list with all data found for one individual, merged per data type
and sorted by timestamp. Duplicate rows are removed. Rows removed
during cleaning are stored in the attribute removed, see
removed_entries. NULL if no valid data files were found.
Examples
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
# Raw data, as found in the export
data_raw <- parse_data(id = "1", paths = path, clean = FALSE)
names(data_raw)
head(data_raw$cgm)
# Cleaned and standardized data
data <- parse_data(id = "1", paths = path)
names(data)
head(data$cgm)
Plot one or more days of diabetes data for a single subject
Description
Draws a two-panel plot per day. The upper panel shows the CGM trace over a shaded target range, with the SMBG measurements as diamonds; the lower panel shows the basal rate as a filled step area, the boluses as labelled circles and the carbohydrates as labelled boxes, headed by the insulin delivered over the whole day. Both panels share a 0-24 h axis of the local (wall-clock) time, and a legend is drawn underneath them.
Usage
plot_day(
data,
id = NULL,
days = NULL,
target = NULL,
ylim_cgm = NULL,
min_bolus = 0,
units = "mg/dl",
main = NULL
)
Arguments
data |
A list with all data found for one individual (the output of
|
id |
Character or numeric participant identifier, naming the individual
to plot. Can be omitted if |
days |
The day(s) to plot, as a |
target |
Numeric vector of length two with the glucose target range, drawn as a shaded band. |
ylim_cgm |
Numeric vector of length two with the limits of the glucose axis. |
min_bolus |
Numeric, the smallest bolus that is drawn in full, in units.
Small correction boluses crowd the panel without adding much, and
|
units |
Character string, the units of the glucose data, either
|
main |
Character string with the plot title. Defaults to the id and the day. Note that the same title is used for every day if several are plotted. |
Details
The daily totals are taken from total_basal and total_bolus
where the export provides them, and are summed over the day otherwise. They
therefore cover insulin that the drawn data may not, such as the basal
delivered in automated mode by an Omnipod, and they are unaffected by
min_bolus. A total that is not recorded at all is shown as "-".
Where min_bolus leaves boluses out of the labelled circles, a note next
to the totals says so.
Value
No return value, called for side effects: one plot is drawn per day.
Examples
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- parse_data(id = "1", paths = path)
plot_day(data, days = "2026-06-22")
# Custom target range, with boluses below 1 U drawn as ticks only
plot_day(data, days = "2026-06-22", target = c(70, 140), min_bolus = 1)
Read a file from a CareLink export
Description
Read a file from a CareLink export
Usage
read_carelink(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class carelink, wrapping a named list with the
data of the different types found in the file.
Read a file from a Dexcom clarity export
Description
Read a file from a Dexcom clarity export
Usage
read_dexcom_clarity(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class dexcom_clarity, wrapping a named list with
the CGM data.
Read a file from a Glooko export
Description
Read a file from a Glooko export
Usage
read_glooko(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class glooko, wrapping a named list with the
data of one data type. NULL if the file is empty.
Read a file from a mylife export
Description
Read a file from a mylife export
Usage
read_mylife(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class mylife, wrapping a named list with one
entry per entry type found in the file. NULL if the file is empty.
Read a file from a Tandem Source export
Description
Read a file from a Tandem Source export
Usage
read_tandem_source(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class tandem_source, wrapping a named list with
the data of one data type.
Read a file from a Tidepool export
Description
Read a file from a Tidepool export
Usage
read_tidepool(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class tidepool, wrapping a named list with one
entry per sheet of the export. Entries of optional sheets that are absent
from the file are NULL.
Read a file from a YourLoops export
Description
Read a file from a YourLoops export
Usage
read_yourloops(id, filename)
Arguments
id |
Character or numeric participant identifier. |
filename |
Character string with the filename of the file to be read. |
Value
An instance of class yourloops, wrapping a named list with the
data of one data type.
Get all entries removed during cleaning and filtering
Description
Rows can be removed while cleaning (e.g. merged slowly absorbed
carbohydrates in clean.glooko) and by filters (e.g.
overwritten carbohydrate entries in filter_carbs).
Usage
removed_entries(data_id)
Arguments
data_id |
A list with all data found for one individual. |
Value
A named list with one data frame per data type, holding the removed
rows and the column removed_reason. NULL if nothing was
removed.
Examples
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- filter_carbs(parse_data(id = "1", paths = path))
removed_entries(data)
Write AID data (CGM, basal, bolus, carbs and SMBG, where available) to a JSON file in DIAX format
Description
Accepts either the output of parse_data for a single
individual or the output of merge_all for
multiple individuals. One JSON file following the
DIAX
specification is written per individual.
Usage
write_DIAX_format(data, prefix, ids = NULL)
Arguments
data |
A list with data of one individual (output of |
prefix |
Character string prepended to the id to build each output
filename, e.g. |
ids |
Character or numeric vector with the individual(s) to write.
Defaults to all ids found in |
Value
No return value, called for side effects: one JSON file is written per id.
Examples
path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- parse_data(id = "1", paths = path)
out_dir <- tempfile("diax_")
dir.create(out_dir)
write_DIAX_format(data, prefix = file.path(out_dir, "id_"))
list.files(out_dir)
unlink(out_dir, recursive = TRUE)