summarize_data: Summary calculations for serial measurement data

Description Usage Arguments Details Value Examples

Description

summarize_data summarizes serial measurement data

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
25
26
27
summarize_data(x, ...)

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

## S3 method for class 'meds_cont'
summarize_data(x, ..., units = "hours")

## S3 method for class 'meds_inpt'
summarize_data(x, ..., units = "hours",
  cont = TRUE)

## S3 method for class 'meds_home'
summarize_data(x, ..., ref, pts = NULL,
  home = TRUE)

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

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

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

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

Arguments

x

A data frame with continuous data

...

optional grouping variables

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

ref

A data frame with three columns: name, type, and group. See details below.

pts

An optional data frame with a column pie.id including all patients in study

home

A logical, if TRUE (default) look for home medications, otherwise look for discharge prescriptions

Details

This function takes a data frame with serial measurement data (e.g., medications, lab results) and produces a data frame with summary data for each patient.

For continuous medications, the calculations include: first rate, last rate, minimum rate, maximum rate, AUC, time-weighted average rate, total infusion duration, total infusion running time, and cumulative dose.

For labs and intermittent medications, the calculations include: first, last, median, maximum, minimum, AUC, and time-weighted average result.

The data frame passed to ref should contain three character columns: name, type, and group. The name column should contain either generic medication names or medication classes. The type column should specify whether the value in name is a "class" or "med". The group column should specify whether the medication is a continous ("cont") or scheduled ("sched") medication.

Value

A data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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 and calculate runtime
x <- tidy_data(meds_cont, meds_sched, ref)
x <- calc_runtime(x)

# pass runtime data to summarize
print(head(
  summarize_data(x)
))

# tidy home medications
print(head(
  summarize_data(meds_home, ref = ref)
))

# return all patients, even if they do not have any of the desired home meds
pts <- dplyr::distinct(meds_home, pie.id)
print(head(
  summarize_data(meds_home, ref = ref, pts = pts)
))

# return discharge prescriptions instead of home meds
print(head(
  summarize_data(meds_home, ref = ref, pts = pts, home = FALSE)
))

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