I have the following data frame and i want to use cast to create a \"pivot table\" with columns for two values (value and percent). Here is the data frame:
data.table can cast on multiple value.var variables. This is quite direct (and efficient).
value.var
Therefore:
library(data.table) # v1.9.5+ dcast(setDT(expensesByMonth), expense_type ~ month, value.var = c("value", "percent"))