I need to create a numerical order of appearance depending on the nth time an "appln_id" appears in the data frame. The columns "numorder" is what I am trying to get:
appln_id numberclass weight order numorder
1 1 558 0.10000000 1 1
2 1 558 0.10000000 2 2
3 1 558 0.10000000 3 3
4 1 558 0.10000000 4 4
5 1 558 0.10000000 5 5
6 2 88 0.00435817 6 1
7 2 282 0.00435817 7 2
8 2 282 0.00435817 8 3
9 2 282 0.00435817 9 4
10 2 282 0.00435817 10 5
I am sure that there is a way around with dplyr, but I haven't been able to find a function that creates such a numerical order.
dput(mini)
structure(list(appln_id = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2), numberclass = c(558L,
558L, 558L, 558L, 558L, 88L, 282L, 282L, 282L, 282L), weight = c(0.1,
0.1, 0.1, 0.1, 0.1, 0.00435816993464052, 0.00435816993464052,
0.00435816993464052, 0.00435816993464052, 0.00435816993464052
), order = 1:10), row.names = c(NA, -10L), class = c("data.table",
"data.frame"))