get_cgmquantify_format: Convert CGM data to a format compatible with the R-package...

View source: R/06_conversions.R

get_cgmquantify_formatR Documentation

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 parse_data) or for multiple individuals (the output of merge_all). Requires cleaned and standardized CGM data.

id

Character or numeric participant identifier, naming the individual to convert. Can be omitted if data holds the CGM data of a single individual.

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)


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