melt(DT, id.vars=c(..), variable.name="CategoryLabel", value.name="Value")
dcast(DT, LHS ~ RHS, value.var="Value", fun.aggregate=sum)
Parameter | Details |
---|---|
id.vars | tell melt which columns to retain |
variable.name | tell melt what to call the column with category labels |
value.name | tell melt what to call the column that has values associated with category labels |
value.var | tell dcast where to find the values to cast in columns |
formula | tell dcast which columns to retain to form a unique record identifier (LHS) and which one holds the category labels (RHS) |
fun.aggregate | specify the function to use when the casting operation generates a list of values in each cell |
Much of what goes into conditioning data to build models or visualizations can be accomplished with data.table
. As compare to other options, data.table
offers advantages of speed and flexibility.