process_data: Data Pre-Processor

View source: R/process_data.R

process_dataR Documentation

Data Pre-Processor

Description

A helper function to assist in pre-processing the user-supplied input data for use with other functions. Typically, this function will process the data and return another dataframe. This function ensures that the returned data will be compitable with every function within the iglu package. All NAs will be removed. See Vignette for further details.

Usage

process_data(data, id, timestamp, glu, time_parser = as.POSIXct)

Arguments

data

User-supplied dataset containing continuous glucose monitor data. Must contain data for time and glucose readings at a minimum. Accepted formats are dataframe and tibble.

id

Optional column name (character string) corresponding to subject id column. If no value is passed, an id of 1 will be assigned to the data.

timestamp

Required column name (character string) corresponding to time values in data. The dates can be in any format parsable by as.POSIXct, or any format accepted by the parser passed to time_parser. See time_parser param for an explanation on how to handle arbitrary formats.

glu

Required column name (character string) corresponding to blood glucose values, mg/dl

time_parser

Optional function used to convert datetime strings to time objects. Defaults to as.POSIXct. If your times are in a format not parsable by as.POSIXct, you can parse a custom format by passing function(time_string) {strptime(time_string, format = <format string>)} as the time_parser parameter.

Details

A dataframe with the columns "id", "time", and "gl" will be returned. All NAs will be removed. If there is a mention of "mmol/l" in the glucose column name, the glucose values will be multipled by 18 to convert to mg/dl Based on John Schwenck's data_process for his bp package https://github.com/johnschwenck/bp

Value

A processed dataframe object that cooperates with every other function within the iglu package - all column names and formats comply.

Author(s)

David Buchanan, John Schwenck

Examples

data("example_data_1_subject")

# Process example data
processed <- process_data(example_data_1_subject, id = "id", timestamp = "time", glu = "gl")

processed

data("example_data_5_subject")

# Process example data
processed_5subj <- process_data(example_data_5_subject, id = "id", timestamp = "time", glu = "gl")

processed_5subj


iglu documentation built on Oct. 20, 2023, 5:07 p.m.