filterLabs: Filter labs

Description Usage Arguments Value

View source: R/filterLabs.R

Description

Filters and renames extracted Diamonds data by specified time points.

Usage

1
2
3
filterLabs(data, patients, ids = NULL, dates, timepoints = NULL,
  groups = NULL, range = "on", within = NULL, format = "raw",
  na.rm = FALSE, multiple = NULL)

Arguments

data

A data frame extracted from the Diamonds database in "raw" format.

patients

A required character vector of patient medical record numbers.

ids

An optional character vector of patient identifiers in the same order as patients. If provided, a new column titled "PatientId" is added to the output data frame.

dates

A required date vector in the same order as patients corresponding to the dates to filter the data with. There may be multiple dates per patient as long as the order remains the same.

timepoints

An optional character vector in the same order as dates corresponding to a description of the timepoint. If provided, a new column titled "TimePoints" is added to the output data frame.

groups

An optional character vector of patient groupings in the same order as patients. If provided, a new column titled "Groups" is added to the output data frame.

range

A character vector specifying the range of dates for each time point to be extracted. Available options include "on", "before", "after", and "within". If "within" is selected a range of values must be provided in the "within" argument.

within

An integer vector of length 2 providing the number of dates before and after each time point to filter. For example, c(-14, 14) would indicate that all dates less than or greater than 14 days of the specified time point are to be filtered.

format

A character vector indicating the output format. Options include "raw", "byObservationId", "byDaysFromFirstTimePoint", "byObservationDate", or "byTimePoint".

na.rm

A Boolean indicating whether rows with NA valules should be removed.

multiple

An optional character vector for how to handle multiple lab results available for the same patient. If "closet", then the lab result closet to the timepoint is given. If "furthest", the the lab result furthest to the timepoint is given. If NULL, then all test results that satisfiy the filter criteria are given.

Value

Returns a data frame with patient observations from the Diamonds filtered by the desired dates. A new column is added giving the number of days from the first specified time point. Optionally, additional columns for Groups, Timepoints, and PatientIds are added if specified.


davidcoffey/Diamonds documentation built on Aug. 16, 2018, 8:59 a.m.