aidR: Tandem Source export format

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(aidR)
path <- system.file("extdata", "tandem_source_example.zip", package = "aidR")
tmpdir <- file.path(tempdir(), "tandem_source_example")
unzip(path, exdir = tmpdir)
files <- list.files(tmpdir, recursive = TRUE)

Overview

A Tandem Source export is a folder (possibly zipped) containing CSV files for several data types. Filenames combine the participant, serial number, and export date with a data-type suffix, for example:

files

Each file records the device type (e.g. Tandem Mobiā„¢ System) and serial number on every row:

writeLines(readLines(file.path(tmpdir, files[4]), n = 10))

How aidR detects this format

Because the headers in a Tandem Source export are language-specific, aidR cannot identify a file from its header names. It relies instead on the structure of the file, and distinguishes between data types by the expected number of columns, which columns are numeric, and, where available, a language-independent keyword such as "Tandem" or "t:slim X2" for the files containing CGM, SMBG and basal rates, as well as "Bolus" for the file containing the bolus data.

Files and the data types they produce

To inspect the raw files, we parse the export with clean = FALSE, which returns the full information provided by Tandem Source:

data <- parse_data(id = "1", paths = path, clean = FALSE)

Each entry below describes one raw file and shows an example.

head(data$cgm)
head(data$basal)
head(data$bolus)
head(data$SMBG)
head(data$hourly_basal)

Cleaning files

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 | -CGM.csv | data$cgm | | basal | -Basal-doses.csv | data$basal | | bolus | -Bolus.csv | data$bolus | | carbs | -Bolus.csv | data$bolus | | SMBG | -BG.csv | data$bg | | total_basal | -Hourly-basal-delivery.csv | data$hourly_basal | | total_bolus | *-Bolus.csv | data$bolus |

Notes



Try the aidR package in your browser

Any scripts or data that you put into this service are public.

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