I want to embrace all the "name" with 0 "elect" in a new row with the tag "Others", like Others 1357 0 (1357 is the sum of all number with elect 0) and maintain the rest of df:
name
number
elect
PA2
10417
9
PA1
7436
6
PA4
2552
2
PA5
2660
2
PA6
2308
2
PA7
2988
2
PA8
2374
2
Others
1357
0
I'm try do it with forcats fct_lump, but I can't get it
In the original datraframe, number and elect are numbers. Applying this solution to dataframe the new name column is messy, but this is not a serious problem, always can reorder it. Thanks EconProf.