I have this df:
> head(orientadores)
name Var2 Freq rank
1 Author1 A 1 1
2 Author1 B 2 4
3 Author2 A 2 2
4 Author3 A 3 3
5 Author4 A 1 1
6 Author4 B 3 6
the rank
column was calculated like this, where, if the Var2
column is equal to "B"
, it should store it's value doubled.
orientadores$rank <- orientadores$Freq * ifelse(orientadores$Var2=="B",2,1)
i'd like to sum the rank values by name and order them, so it would look like this:
> head(orientadores)
name final_rank
1 Author4 7
2 Author1 5
3 Author3 3
4 Author2 2
How to do so? I've tried this but it wouldn't do the trick:
orientadores <- orientadores %>%
group_by(Var1) %>% mutate(final_rank = sum(Freq2))