calc_runtime: Calculate the running time for serial measurement data

Description Usage Arguments Details Value Examples

Description

calc_runtime calculates the duration of time at current value and total run time

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
calc_runtime(x, ...)

## Default S3 method:
calc_runtime(x, ...)

## S3 method for class 'meds_cont'
calc_runtime(x, ..., drip.off = 12, no.doc = 24,
  units = "hours")

## S3 method for class 'meds_inpt'
calc_runtime(x, ..., drip.off = 12, no.doc = 24,
  units = "hours", cont = TRUE)

## S3 method for class 'events'
calc_runtime(x, ..., units = "hours")

## S3 method for class 'labs'
calc_runtime(x, ..., units = "hours")

## S3 method for class 'meds_sched'
calc_runtime(x, ..., units = "hours")

## S3 method for class 'vitals'
calc_runtime(x, ..., units = "hours")

Arguments

x

A data frame with serial measurement data

...

optional grouping variables

drip.off

An optional numeric indicating the number of hours a medication infusion should be off to count as a new infusion, defaults to 12 hours

no.doc

An optional numeric indicating the number of hours without documentation which will be used to indicate a drip has ended, defaults to 24 hours

units

An optional character string specifying the time units to use in calculations, default is hours

cont

A logical, if TRUE (default), treat the medications as continuous when summarizing

Details

This function takes a data frame with serial measurement data (e.g., continuous medications or repeated lab data) and produces a data frame with the with the duration of time at each value and cumulative run time.

This could be used to then calculate the AUC or to summarize the continuous data.

For continuous medications, the data will be grouped into distinct sets of infusions, for patients who may have been restarted on the drip one or more times. Use the drip.off argument to modify the criteria for determining distinct infusions.

Value

A data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# make a reference data frame for tidying meds
ref <- tibble::tibble(
  name = c("heparin", "warfarin", "antiplatelet agents"),
  type = c("med", "med", "class"),
  group = c("cont", "sched", "sched")
)

# tidy continuous medications; will keep only heparin drips
x <- tidy_data(meds_cont, meds_sched, ref)

# calculate the runtime for continuous heparin infusion
print(head(
  calc_runtime(x)
))

bgulbis/edwr documentation built on May 12, 2019, 8:22 p.m.