Here's the code:
dummy <- data.frame(
Var1 = c("A", "B", "C", "D", "E"),
Freq = c(548, 326, 292, 199, 138)
)
dummy %>%
mutate(perc =scales::percent(Freq/sum(Freq))) %>%
arrange(desc(Var1)) %>%
mutate(pos = cumsum(Freq)- Freq/2) %>%
ggplot(aes(x = "", y = Freq, fill = factor(Var1) )) +
geom_bar(width = 1, stat = "identity") +
coord_polar("y", start = 0) +
ggrepel::geom_label_repel(aes(x = "", y = pos, label = perc), size=5, show.legend = F, nudge_x = 1) +
guides(fill = guide_legend(title = "Group"))
Is there a way to make it so that instead of having a legends tab, the names of each slice is placed within the slices in the pie graph itself?