I have a data table:
df <- data.table(Points = 1:5, A = c(2,4,6,8,10), B = c(1,3,4,5,9)) df <- Points A B 1 2 1 2 4 3 3 6 4 4 8 5 5 10 9
I want the value of column Points corresponding to the first value in column B that is higher than the current value of column A.
Expected output if A == 4:
4 (the first value in B bigger than 4 has a corresponding value of Points equal to 4)
https://stackoverflow.com/questions/67410227/first-row-where-value-in-one-column-higher-than-in-another-column-r May 06, 2021 at 08:02AM
没有评论:
发表评论