Is it possible to return a data table without j?

Is there any way to return data.tablewithout j columns?

Quite often, I just need unique combinations of a key or a set of keys.

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)])

thank

+4
source share

All Articles