Calculate percentage of each category in each group in R [duplicate]

You can use dplyr package

library(dplyr)
df <- data.frame(Group = c(1, 1, 1, 2, 2, 2), Category = c(LETTERS[1:3], LETTERS[1:3]), Freq = c(2, 3, 5, 5, 1, 14))
df %>% group_by(Group) %>% mutate(proc = (Freq/sum(Freq) * 100))

We can use dplyr

library(dplyr)
df1 %>% 
    group_by(Group) %>% 
    mutate(Percent = 100*Freq/sum(Freq))