最佳答案
I'm using the data.table
package to speed up some summary statistic collection on a data set.
I'm curious if there's a way to group by more than one column. My data looks like this:
purchaseAmt adShown url
15.54 00001 150000001
4.82 00002 150000001
157.99 05005 776300044
... ... ...
I can do something like this:
adShownMedian <- df1[,median(purchaseAmt),by="adShown"]
to get each ad's median. How would I do something that combines adShown
and url
?
I've tried this:
adShownMedian <- df1[,median(purchaseAmt),by=c("adShown","url")]
but no luck.
Any suggestions?