Suppose I have the following data.frame
/data.table
object:
foo <- data.frame(sku = c('123','234','567'), shipped_units_wk1 = c(20,10,10), shipped_units_wk2 = c(25,25,50), category = c("AA", "AA", "BB"))
sku shipped_units_wk1 shipped_units_wk2 category
123 20 25 AA
234 10 25 AA
567 10 50 BB
I need it in the following format:
category shipped_units_wk1 shipped_units_wk2
AA 30 50
BB 10 50
I can use the sqldf
package to accomplish this, but is there a faster method in a different package for this? My actual data.frame
has tens of thousands of rows & 20 columns.