data_utils: Data loading utilities

id_originR Documentation

Data loading utilities

Description

Two important tools for smoothing out differences among used datasets are id_origin() which returns origin times for a given ID and id_map() which returns a mapping between two ID systems alongside start and end columns of the target ID system relative to the source ID system. As both these function are called frequently during data loading and might involve somewhat expensive operations, both rely on internal helper functions (id_orig_helper() and id_map_helper()) which perform the heavy lifting and wrap those helper functions, providing a memoization layer. When adding a new data source, a class specific implementation of the S3 generic function id_map_helper() might be required, as this is used during data loading using load_id() and load_ts() via change_id().

Usage

id_origin(x, id, origin_name = NULL, copy = TRUE)

id_orig_helper(x, id)

## S3 method for class 'src_env'
id_orig_helper(x, id)

## S3 method for class 'miiv_env'
id_orig_helper(x, id)

id_windows(x, copy = TRUE)

id_win_helper(x)

## S3 method for class 'mimic_env'
id_win_helper(x)

## S3 method for class 'eicu_env'
id_win_helper(x)

## S3 method for class 'hirid_env'
id_win_helper(x)

## S3 method for class 'aumc_env'
id_win_helper(x)

## S3 method for class 'miiv_env'
id_win_helper(x)

id_map(x, id_var, win_var, in_time = NULL, out_time = NULL)

id_map_helper(x, id_var, win_var)

## S3 method for class 'src_env'
id_map_helper(x, id_var, win_var)

Arguments

x

Object identify the ID system (passed to as_src_env())

id

ID name for which to return origin times

origin_name

String-valued name which will be used to label the origin column

copy

Logical flag indicating whether to return a copy of the memoized ⁠0data.table⁠ for safety

id_var

Type of ID all returned times are relative to

win_var

Type of ID for which the in/out times is returned

in_time, out_time

column names of the returned in/out times

Details

For the internal datasets, id_map_helper() relies on yet another S3 generic function id_windows(), which provides a table containing all available ID systems, as well as all ID windows for a given data source. As for the other two functions, the same helper-function approach is in place, with the data loading function id_win_helper(). The function id_map_helper() is then implemented in a data source agnostic manner (dispatching on the src_env class), providing subsetting of this larger ID map table and ensuring timestamps are relative to the correct ID system. For adding a new data source however, this layer can be forgone. Similarly for id_origin(), this is used for the internal datasets in load_difftime(). An implementation of load_difftime(), specific to a new data source can be provided that does not rely on id_windows(), making this function irrelevant for this specific dataset.

Value

  • id_origin()/id_orig_helper(): an id_tbl with admission time stamps corresponding to the selected ID

  • id_windows()/id_win_helper(): an id_tbl holding all IDs and their respective start and end times

  • id_map()/id_map_helper(): an id_tbl containing the selected IDs and depending on values passed as in_time and out_time, start and end times of the ID passed as win_var


ricu documentation built on Sept. 8, 2023, 5:45 p.m.