r - First element in a data.table aggregation -
i have data.table
of tick data, want aggregate seconds timeframe. while getting max
, min
, last
pretty straightforward:
data[, list(max(value), min(value), last(value)), by=time]
i struggling first datapoint corresponds second timestamp. there nothing in manual. there easy way it, say, sql top
?
i managed find solution. query first element subset column's first value using [
:
data[, list(value[1], max(value), min(value), last(value)),by=time]
maybe helps someone.
Comments
Post a Comment