I want to generate a result that includes also a final row find the sum of the previous results. I have the following scenario.
Input data:
Group <- c("A","S","A","T","A","S")
Id <- c(25, 34, 28, 52, 3 ,5)
dataframe <- data.frame(Group, Id)
dataframe
Current function:
result = group_by(dataframe,Group) %>%
summarise(q = n()) %>%
mutate (Freq = round(q / sum(q), 3))
result
Current result:
Group q Freq
(fctr) (int) (dbl)
1 A 3 0.500
2 S 2 0.333
3 T 1 0.167
Dessired result:
Group q Freq
(fctr) (int) (dbl)
1 A 3 0.500
2 S 2 0.333
3 T 1 0.167
Total 6 1
How can I generate the total row?
Thank you very much.