I have data.table
X = data.table(x = c(1,1,1,1,1,2,2,2,2,2), y = c(3,2,1,-1,5,7,4,-2,3,5))
I want to subset only rows which are above negative values in one group:
res = data.table(x = c(1,1,1,2,2), y = c(3,2,1,7,4)
From five values in first group, I want to get only first three, because fourth is negative, and the same with second group.