filter_CGM: Filter CGM values

View source: R/04_filtering.R

filter_CGMR Documentation

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)

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