GenEpisode: Calculate pseudo admission episodes

Description Usage Arguments Value Author(s) Examples

View source: R/GenEpisode.R

Description

Read in glucose data and calculate pseudo admission episodes, calculate the time interval between consecutive readings and accumulated time intervals within each episode for each individual, identify the day in a week, month, year, week number in a year, convert timings into hours using the standard 24-hour clock.

Usage

1
GenEpisode(dat, epiMethod = "Admininfo")

Arguments

dat

A data.frame with at least have three key variables:

  • RESULT.DATE a date and time column of classes “POSIXlt” and “POSIXct” (can be generated by FormatDate);

  • ADMISSION.ID a character or numeric column for the ID of each hospital stay;

  • RESULT a numeric column for Blood Glucose readings.

epiMethod

This indicates the method takes to compute episodes. If Admininfo (the default), the admission id will be assumed to be case id; if Pseudo, then episode number will be generated using 48 hours as a cutoff.

Value

The input data.table with the following additional variables:

LOS.EACH

time difference between readings

LOS.PSUM

cumulative time differences between readings

EPISODE.ID

In the case of pseudo, admission times will be increase by 1 if LOS.EACH greater than 48 hours. Otherwise, it will always be 1, corresponding to that each admission id identifies one hospital stay.

mond

day of month

weekd

day of week

yday

day of year

hour

numerical hours

weekn

number of weeks in a year

These variables are created using original key variable RESULT.DATE.

Author(s)

Chuen Seng Tan, Ying Chen

Examples

1
2
3
4
5
6
# Load example data
data("gluDat")
# Focus on data from Ward A. Process date-time variable and blood glucose readings:
gluDat2 <- FormatDate(dat = gluDat[gluDat$LOCATION == "A", ], yy = 2020, mm = 7)
# Specify admission episodes based on admission ID:
gluDat3 <- GenEpisode(dat = gluDat2, epiMethod = "Admininfo")

nyilin/QcDM documentation built on June 29, 2021, 1:14 a.m.