-
Notifications
You must be signed in to change notification settings - Fork 132
Closed
Milestone
Description
Is there a way of adding the total called via adorn_totals as a new level to an existing factor? E.G. Adding the Total row produced by adorn_totals() as a factor level to the starwars sex variable?
Repex below:
# starwars data
data(starwars)
# gender
starwars %>%
count(sex)
# A tibble: 5 × 2
sex n
<chr> <int>
1 female 16
2 hermaphroditic 1
3 male 60
4 none 6
5 NA 4
# make fct
starwars$sex <- as.factor(as.character(starwars$sex))
# with totals
starwars %>%
count(sex) %>%
adorn_totals()
sex n
female 16
hermaphroditic 1
male 60
none 6
<NA> 4
Total 87