I am looking for patterns for manipulating data.table objects whose structure resembles that of dataframes created with melt from the reshape
data.table
melt
reshape
I'm not sure if this is the best way, but you can try:
input[, list(x = sum(value[variable == "x"]), y = sum(value[variable == "y"])), by = "id"] # id x y # 1: 1 1 5 # 2: 2 4 11 # 3: 3 15 9