knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(aidR)
path <- system.file("extdata", "yourloops_example.zip", package = "aidR") tmpdir <- file.path(tempdir(), "yourloops_example") unzip(path, exdir = tmpdir) files <- list.files(tmpdir, recursive = TRUE)
A YourLoops export is a folder (possibly zipped) containing CSV files for several data types:
basename(files) # removes yourloops_example/ prefix
The column headers are always in English, regardless of the user's account language. Timestamps are given in UTC alongside a separate timezone offset in minutes, so recovering local (wall-clock) time requires combining the two. This example shows a file containing CGM data:
writeLines(readLines(file.path(tmpdir, files[4]), n = 10))
Because YourLoops headers are language-independent, aidR identifies each file by matching its column names exactly against a lookup of the expected headers for each data type.
To inspect the raw files, we parse the export with clean = FALSE, which returns the full information provided by YourLoops:
data <- parse_data(id = "1", paths = path, clean = FALSE)
Each entry below describes one raw file and shows an example.
cbg.csv: CGM data.head(data$cgm)
basal.csv: basal rates, including the delivery type and the duration (given in milliseconds).head(data$basal)
bolus.csv: insulin boluses, including a flag whether a bolus was biphasic or not.head(data$bolus)
meals.csv: carbohydrate intake communicated to the bolus calculator.head(data$meals)
rescuecarbs.csv: carbohydrates taken to treat a hypoglycaemic event.head(data$rescuecarbs)
alarms.csv: alarms raised by the loop or the pump, with code and acknowledgement status.head(data$alarms)
physicalActivities.csv: self-reported physical activity, with duration and reported intensity. Often sparse or missing entirely.head(data$physicalActivities)
settings-cgm.csv, settings-pump.csv, settings-device.csv, settings-current-parameters.csv, settings-security-basals.csv: the CGM, pump, smartphone, loop-parameter, and security-basal configuration.head(data$settings_pump)
Note that a YourLoops export contains no SMBG data; cgm, basal, bolus, and carbs are the core data types available from this platform.
When parse_data is run with clean = TRUE, the cleaned data types are built from the following raw files and attributes:
| Cleaned data type | Used files | Used attributes from clean = FALSE|
|-------------------|---------------------------------|-------------------------------------|
| cgm | cbg.csv | data$cgm |
| basal | basal.csv | data$basal |
| bolus | bolus.csv | data$bolus |
| carbs | meals.csv, rescuecarbs.csv | data$meals, data$rescuecarbs |
| total_basal | basal.csv | data$basal |
| total_bolus | bolus.csv | data$bolus |
aidR converts them to mg/dL automatically.clean = FALSE, timestamps are reported exactly as in the file: the timestamp column is in UTC and the timezoneOffSet column gives the offset, so local (wall-clock) time is obtained by adding the two.clean = TRUE, for consistency with the other formats the timestamp column instead holds local (wall-clock) time, while timezoneOffSet remains the same offset. UTC time can therefore be recovered by UTC = timestamp - timezoneOffSet.total_basal and total_bolus are summed from the cleaned basal and bolus data and carry source = "summed".aidR keeps them separate but flags them, so they can be recombined if needed.link_id is always NA for bolus and carbs: the export does not record which carbohydrate entry triggered which bolus. Matching them by timestamp and amount is not implemented.Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.