lab_change: Determine if a lab changed by a set amount within a specific...

Description Usage Arguments Details Value Examples

Description

lab_change checks for changes in lab values

Usage

1
lab_change(x, .lab, change.by, FUN, back = 2)

Arguments

x

A data frame with lab data

.lab

A character string indicating the name of the lab to evaluate

change.by

A numeric indicating the threshold for lab changes

FUN

A function for rollapplyr, most commonly max or min

back

An optional numeric specifying the number of days back to go. Defaults to 2 days.

Details

This function takes a data frame with lab data for a single lab and checks whether the lab changes by a certain amount within a given period of time.

For FUN, use max when looking for a decrease in lab value, and min when looking for an increase in lab value.

Value

A data frame

Examples

1
2
3
4
5
6
# checks for a >= 2 decrease in the hemoglobin value within the past 2 days
x <- tidy_data(labs)

print(head(
  lab_change(x, "hgb", -2, max, back = 2)
))

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