Learn R Programming

Hmisc (version 5.1-0)

meltData: meltData

Description

Melt a Dataset To Examine All Xs vs Y

Usage

meltData(formula, data, vnames = c("labels", "names"))

Value

data table

Arguments

formula

a formula

data

data frame or table

vnames

set to names to always use variable names instead of labels for X

Author

Frank Harrell

Details

Uses a formula with a single left hand side variable (Y) and one or more numeric right hand side variables (X). Uses data.table::melt() to melt data so that each X is played against the same Y. The resulting data table has variables Y with its original name, variable, and value. By default variable is taken as label()s of X variables.

See Also

label()

Examples

Run this code
d <- data.frame(y=(1:10)/10, x1=1:10, x2=101:110)
label(d$x1) <- 'X1'
m=meltData(y ~ x1 + x2, data=d)
print(m)

Run the code above in your browser using DataLab