Reputation: 1
I have a large data set like the below example, How to assign a unique rank number to duplicate or repeated values with a combination of more than one column condition. like rank to be assigned with reference to cluster & value column.
Example data table & required output:
Upvotes: -1
Views: 2068
Reputation: 8484
I think this should do:
library(dplyr)
x=data.frame(id=c(1,1,2,3,4,4,5,6,7), value=c(10,10,10,20,20,20,20,20,30))
x %>%
arrange(id, value) %>%
group_by(value) %>%
mutate(rank=row_number(value))
Upvotes: 1