Your data is still grouped. This will give you the proportions inside your og
data.frame:
og <- df %>%
group_by(y,z) %>%
summarise(x = sum(x)) %>%
ungroup()
og %>%
mutate(pr = x/sum(x))
Your data is still grouped. This will give you the proportions inside your og
data.frame:
og <- df %>%
group_by(y,z) %>%
summarise(x = sum(x)) %>%
ungroup()
og %>%
mutate(pr = x/sum(x))