1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
library(ggpubr)
library(tidygraph)
library(patchwork)
df <- data.frame(
group = c("Male", "Female", "Child"),
value = c(25, 25, 50)
) %>%
dplyr::mutate(pc = paste0(value/sum(value)*100,"%"))
df
# group value pc
# 1 Male 25 25%
# 2 Female 25 25%
# 3 Child 50 50%
p1 = ggpie(df, "value", label = "pc",
lab.pos = "in", lab.font = "white",
fill = "group", color = "white",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
p2 = ggdonutchart(df, "value", label = "pc",
lab.pos = "in", lab.font = "white",
fill = "group", color = "white",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
p1 | p2
|