orderedNumeric: like as.ordered with extended formatting

View source: R/orderedNumeric.r

orderedNumericR Documentation

like as.ordered with extended formatting

Description

like as.ordered with extended formatting

Usage

orderedNumeric(
  x,
  prefix = "",
  suffix = "",
  paste.function = paste,
  special.x = NULL
)

Arguments

x

a vector of numeric values

prefix

text string to preceed the number (like drug name)

suffix

text string to ome after the number (like mg)

paste.function

function to use when glueing together prefix, x, and suffix

special.x

list of length 2, with first (numeric) element being the number that will be exchanged for the 2nd element which should be a text string.

Value

A formatted character vector containing count and percentage of unique values in x.

Examples

out = expand.grid(ID = 1:5, DOSE = c(0,500,100,4000))
factor(out$DOSE)
#Levels: 0 100 500 4000  ## W H A T ???
orderedNumeric(out$DOSE)
#Levels:  0   100   500   4000    #that's better, similar to ordered(out$DOSE)
orderedNumeric(out$DOSE, special.x = list(0, "Placebo"))
#Levels: Placebo  100   500   4000
orderedNumeric(out$DOSE, prefix = "DrugName ")
orderedNumeric(out$DOSE, prefix = "DrugName", suffix = "mcg")
orderedNumeric(out$DOSE, prefix = "DrugName", suffix = "mcg", special.x = list(0, "Placebo"))
orderedNumeric(out$DOSE, prefix = "DrugName ", suffix = "mcg", special.x = list(0, "Vehicle"),
paste.function = paste0)

qPharmetra/qpToolkit documentation built on May 24, 2023, 8:52 a.m.