runDeriveExpr | R Documentation |
Apply Derived Variable Specifications
runDeriveExpr(d, derv, pr = TRUE)
d |
a data table |
derv |
a |
pr |
set |
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.
nothing; used to print information and add variables to data table
Frank Harrell
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.