parse_data: Parse data files for a given participant ID

View source: R/01a_common_functions.R

parse_dataR Documentation

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 id column of the cleaned data.

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 TRUE (the default), the main data types (CGM, basal, bolus, carbohydrates and SMBG) are cleaned and standardized. If FALSE, all data is returned as found in the export.

...

Additional arguments passed on to the format-specific cleaning methods, e.g. merge_slow_carbs for Glooko (see clean.glooko). Arguments that do not apply to a format are skipped. Ignored if clean = FALSE.

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)


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