runDeriveExpr: runDeriveExpr

runDeriveExprR Documentation

runDeriveExpr

Description

Apply Derived Variable Specifications

Usage

runDeriveExpr(d, derv, pr = TRUE)

Arguments

d

a data table

derv

a list of expressions to evaluate

pr

set pr=FALSE to suppress information messages

Details

Function to apply derived variable specifications derv to a data table d. Actions on d are done in place, so call the function using ⁠runDeriveExpr(d, derv object)⁠ and not by running ⁠d <- runDeriveExpr(d, derv object)⁠. See this for an example.

Value

nothing; used to print information and add variables to data table

Author(s)

Frank Harrell

Examples

require(data.table)
d <- data.table(ht=c(68,  60), wt=c(280, 135), chol=c(120, 150))
derived <- list(
  list(bmi = expression(703 * wt / ht ^ 2),
       label='Body Mass Index',
       units='Kg/m^2'),
  list(bsa=expression(0.007184 * (0.4536 * wt) ^ 0.425 * (2.54 * ht) ^ 0.725),
       label='Body Surface Area',
       units='m^2', drop=.q(wt, ht) )   )
runDeriveExpr(d, derived)
print(d)
contents(d)

qreport documentation built on May 29, 2024, 3:51 a.m.