R/stdzDoseSchedule.R

Defines functions stdzDoseSchedule

Documented in stdzDoseSchedule

#' Standardize Dose Schedule Entity
#'
#' This function standardizes the dose schedule entity.
#'
#' @param x character vector of extracted dose schedule values
#'
#' @return character vector
#'
#' @examples
#' stdzDoseSchedule(c('tapered','weaned','TAPER'))
#' @export

stdzDoseSchedule <- function(x) {
  ds <- tolower(x)
  uds <- unique(ds)
  useUnq <- length(uds) != length(ds)
  if(useUnq) {
    mix <- match(ds, uds)
    ds <- uds
  }
  ds[grep("taper|wean", ds)] <- 'taper'
  ds[grep("off|stop|done|gone", ds)] <- 'stop'
  ds[grep("alternat", ds)] <- 'alternate'
  ds[nchar(ds) == 0] <- NA
  if(useUnq) {
    ds <- ds[mix]
  }
  ds
}

Try the EHR package in your browser

Any scripts or data that you put into this service are public.

EHR documentation built on Oct. 7, 2021, 9:28 a.m.