write_DIAX_format: Write AID data (CGM, basal, bolus, carbs and SMBG, where...

View source: R/06_conversions.R

write_DIAX_formatR Documentation

Write AID data (CGM, basal, bolus, carbs and SMBG, where available) to a JSON file in DIAX format

Description

Accepts either the output of parse_data for a single individual or the output of merge_all for multiple individuals. One JSON file following the DIAX specification is written per individual.

Usage

write_DIAX_format(data, prefix, ids = NULL)

Arguments

data

A list with data of one individual (output of parse_data()) or of multiple individuals (output of merge_all()).

prefix

Character string prepended to the id to build each output filename, e.g. prefix = "output/id_" writes "output/id_1.json" for id "1".

ids

Character or numeric vector with the individual(s) to write. Defaults to all ids found in data.

Value

No return value, called for side effects: one JSON file is written per id.

Examples

path <- system.file("extdata", "glooko_example.zip", package = "aidR")
data <- parse_data(id = "1", paths = path)

out_dir <- tempfile("diax_")
dir.create(out_dir)
write_DIAX_format(data, prefix = file.path(out_dir, "id_"))
list.files(out_dir)

unlink(out_dir, recursive = TRUE)

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