I have a data.table that includes a displayDate
field and also many rows per user, each with a different displayDate. Each user joined the service and started logging data at a different point in time. For each user I want to find the first week's worth of data only, so I'd like to get rid of rows that are not within the first week for a given user. Here's what I'd like to do, but this produces an error:
early_data = dt[displayDate <= min(displayDate) + 7, , by=user]
And I get the following error:
Error in `[.data.table`(dt, displayDate <= min(displayDate) + 14, , by = user) :
'by' or 'keyby' is supplied but not j
Is there a way to conditionally select rows by grouping on another column? What's wrong with my syntax above?