I want to calculate the percentage in the column 'Color', ignoring blanks.
Example:
Df
Color
green
green
blue
blue
blue
blue
Code
Df %>%
group_by(color) %>%
summarise(n = n()) %>%
mutate(per = n/sum(n, na.rm = TRUE))
Desired output:
Color n per
green 2 0.33
blue 4 0.67
What is the code missing? I know this is a simple question, and would really appreciate insights you could offer!