Data loading

Data can be loaded from cofigured data sources, either in the form of data concepts or by directly querying one of the underlying tables. Depending on what route is taken for loading, data is returned either as data.table or as one of the ricu-provided tabular data types id_tbl or ts_tbl.

Concept loading

Data concepts in ricu provide an abstraction that allows to define how a clinical concept (such as heart rate) can be retrieved from a data source. Once defined, concepts can be loaded in a data source agnostic and concise manner.

load_concepts()

Load concept data

new_cncpt() is_cncpt() init_cncpt() new_concept() concept() is_concept() as_concept()

Data Concepts

new_itm() is_itm() init_itm() new_item() item() as_item() is_item()

Data items

load_dictionary() concept_availability() explain_dictionary()

Load concept dictionaries

Callback functions

To provided the required flexibility for defining data concepts, individual items can specify callback functions that are used for post-processing steps for loaded data. Some function fatories are provided for creating simple callback functions and more involved scenarios, such as a SOFA score concept require specialized functions, which might even expose function arguments which can be used to fine-tune the concept bahavior.

transform_fun() binary_op() comp_na() set_val() apply_map() convert_unit()

Item callback utilities

msg_progress() fmt_msg()

Message signaling nested with progress reporting

pafi() safi() vent_ind() gcs() urine24() vaso60() vaso_ind() supp_o2() avpu() bmi() norepi_equiv()

Concept callback functions

sofa_score() sofa_resp() sofa_coag() sofa_liver() sofa_cardio() sofa_cns() sofa_renal()

SOFA score label

sep3() delta_cummin() delta_start() delta_min()

Sepsis 3 label

susp_inf()

Suspicion of infection label

sirs_score() qsofa_score() news_score() mews_score()

SIRS score label

Query loading

Tables can be queried directly by creating an R expression that evaluates to a logical vector indicating which rows to load. The expression is evaluated within the data context, powered by the non-standard evaluation framework provided by rlang.

load_id() load_ts() load_win()

Load data as id_tbl or ts_tbl objects

load_src() load_difftime()

Low level functions for loading data

Tabular ICU data

Inheriting from data.table, ricu provides classes intended to simplify handling of tabular ICU data. For dynamic (i.e. time-varying) data (such as vital sign data), ts_tbl is used and for static data (for example an admission diagnonsis), id_tbl objects are used. Alongside these data structures, several utility functions are provided.

id_tbl() is_id_tbl() as_id_tbl() ts_tbl() is_ts_tbl() as_ts_tbl() win_tbl() is_win_tbl() as_win_tbl() as.data.table(<id_tbl>) as.data.frame(<id_tbl>) validate_tbl()

Tabular ICU data classes

id_vars() id_var() id_col() index_var() index_col() dur_var() dur_col() dur_unit() meta_vars() data_vars() data_var() data_col() interval() time_unit() time_step() time_vars()

ICU class meta data utilities

rename_cols() rm_cols() change_interval() change_dur_unit() rm_na() sort(<id_tbl>) is_sorted() duplicated(<id_tbl>) anyDuplicated(<id_tbl>) unique(<id_tbl>) is_unique() aggregate(<id_tbl>) dt_gforce() replace_na()

ICU class data utilities

expand() collapse() has_no_gaps() has_gaps() is_regular() fill_gaps() remove_gaps() slide() slide_index() hop()

Time series utility functions

change_id() upgrade_id() downgrade_id()

Switch between id types

stay_windows()

Stays

Data source setup

For a data source to be usable via ricu, a JSON-based configuration is required and some preprocessing is carried out by ricu as an initial setup step by import_src() and for data sets hosted on Physionet, a downloader is available as download_src(). As a final step, making data available to ricu, attach_src() is automatically called for configured data sources at package loading.

data

ICU datasets

download_src()

Data download utilities

import_src() import_tbl()

Data import utilities

attach_src() detach_src() setup_src_env()

Data attach utilities

setup_src_data()

Data setup

load_src_cfg()

Load configuration for a data source

data_dir() src_data_dir() auto_attach_srcs() config_paths() get_config() set_config()

File system utilities

Utilities

secs() mins() hours() days() weeks()

Utilities for difftime

min_or_na() max_or_na() is_val() not_val() is_true() is_false() last_elem() first_elem()

Utility functions

write_psv() read_psv()

Read and write utilities