I have a tibble or data frame as follows:
tib <- tibble(PlayerName=c("P1","P2","P3","P1","P2","P3"), GameNo=c(1,1,1,2,2,2), PlayerScore=c(10,15,9,8,12,18))
So, what I want to do is: group them according to the GameNo, and give it another column which will contain the Players' placement according to their PlayerScore.
tib <- tib %>% group_by(GameNo) %>% ...
The end result should look like this:
PlayerName GameNo PlayerScore Placement
<chr> <dbl> <dbl> <dbl>
1 P1 1 10 2
2 P2 1 15 1
3 P3 1 9 3
4 P1 2 8 3
5 P2 2 12 2
6 P3 2 18 1