是否可以返回没有j的data.table?

时间:2016-03-28 19:55:34

标签: r data.table

有没有办法在没有任何j列的情况下返回data.table

我经常想要一把钥匙或一组钥匙的独特组合。

library(data.table)

## Warpbreaks data
wb <- as.data.table(warpbreaks)

## Say I just want the summary of wool / tension combos
## I would like to do one of these, but neither works
wb[ , j = NULL, keyby = list(wool, tension)]  ## <--- Seems legit
wb[keyby = list(wool, tension)]               ## <--- Even better!

## This works, but is two steps:
subset(wb[ , .N, keyby=list(wool, tension)], select=-N)

## This almost works, but there is no key
unique(wb[ , list(wool, tension)])

由于

0 个答案:

没有答案