Below code can't get the wished plot (the data structure can' show in current plot), How to fixed it and change the plot to wished plot ? Thanks!
library(ggraph)
library(igraph)
library(tidyverse)
md <- data.frame(category = c('FDM','FDM','FDM'),
item =c('A1','A1','C1'),
subitem =c('A11','A12','C1'),
amount = c(1,2,3))
vertices <- md %>% gather(key='type',value = 'item',- amount) %>% select(- type) %>%
group_by(item) %>% summarise(amount= sum(amount))
pt <- graph_from_data_frame(md,vertices = vertices)
ggraph(pt,layout = 'circlepack', weight =amount)+
geom_node_circle(aes(fill=depth))+
geom_node_label(aes(label = paste0(name,'\n',amount )))+theme_void()