0

I want to group the output of this dataframe into the maximum of values starting from each 0.

For example, the first group would be [0,221,551,...,2356]

Each grouping is to be added, if that helps!

print(without_Errors2$timeRelativeToTrialStart)

[1] 0   221   551   771   991  1154  1392  1596  1830  2041  2365     0   309   539   747   992  1198  1471  1681  1911  2129  2391     0   243   527   742   958  1207
[29]  1473  1671  1934  2188  2469     0   239  
manotheshark
  • 4,297
  • 17
  • 30
  • This is sorting the data by first the grouping column, then your time column. = `without_Errors2[order(without_Errors2$grouping_column, without_Errors2$timeRelativeToTrialStart), ]` – Gregor Thomas Nov 16 '20 at 18:25
  • If you don't have a grouping column, create one with `without_Errors2$grouper = cumsum(without_Errors2$timeRelativeToTrialStart == 0)` – Gregor Thomas Nov 16 '20 at 18:31
  • And if you need more help than that, or your intent is different, please edit your question to include sample input in a copy/pasteable way and desired output. `dput()` is best for sharing inputs, e.g., `dput(without_Errors2[1:20, c("timeRelativeToTrialStart", "other_relevant_column")])`. – Gregor Thomas Nov 16 '20 at 18:32

0 Answers0