calc_perctime: Calculate proportion of time above or below a threshold

Description Usage Arguments Details Value Examples

Description

calc_perctime calculates percent time above / below a threshold

Usage

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

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

## S3 method for class 'meds_cont'
calc_perctime(x, thrshld, ...)

## S3 method for class 'meds_inpt'
calc_perctime(x, thrshld, cont = TRUE, ...)

## S3 method for class 'events'
calc_perctime(x, thrshld, ...)

## S3 method for class 'labs'
calc_perctime(x, thrshld, ...)

## S3 method for class 'meds_sched'
calc_perctime(x, thrshld, ...)

## S3 method for class 'vitals'
calc_perctime(x, thrshld, ...)

Arguments

x

A data frame with serial measurement data

...

additional arguments passed on to individual methods

thrshld

A charactor vector of the criteria

cont

A logical, if TRUE (default), treat the data as continuous when calculating the percent time

Details

This function takes a data frame with serial measurement data and produces a data frame with percent time above or below a threshold for each infusion.

The argument thrshld must be provided as a list with one or more criteria, which indicate whether to calculate time above, below, or between the threshold values. The criteria should be written as a formula, of the form: list(~variable > value) or list(~variable < value1, ~variable > value2)

Value

A data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# make a reference data frame for tidying meds
library(dplyr)
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)
y <- calc_runtime(x)

# calculate the proportion of time the infusion rate was > 10 units/kg/hour
print(head(
  calc_perctime(y, "med.rate > 10")
))

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