С dplyr
:
library(dplyr)
filter(df, C <= lead(C, default = C[n()]))
Выход:
A B C
1 1 10 100
2 2 20 200
3 4 40 400
4 5 50 500
Данные:
df <- structure(list(A = 1:5, B = c(10L, 20L, 30L, 40L, 50L), C = c(100L,
200L, 800L, 400L, 500L)), class = "data.frame", row.names = c("1:",
"2:", "3:", "4:", "5:"))