在 R ggplot 或 ggvis 中分解 180 度饼图(包括图像)?

Exploded 180 degree pie chart in R ggplot or ggvis (image included)?

给定一个包含因子列 (X1) 和小计列 (X2) 的数据集

  X1 X2 
1  1  12  
2  2  200 
3  3  23  
4  4  86  
5  5  141  

我想创建这样的图形:

x2 占 X2 总数的百分比除以 X1。

编辑:清晰度并添加数据集以实现可重复性

例如

set.seed(1234)
df <- data.frame(x = 1:6)
df$y <- runif(nrow(df))
df$type <- sample(letters, nrow(df))
ggplot(df, aes(x+-.5, y, fill=type)) + 
  geom_bar(stat="identity", width=1) + 
  coord_polar(start = pi/2) + 
  scale_x_continuous(limits = c(0, nrow(df)*2)) + 
  geom_text(aes(label=scales::percent(y))) + 
  ggthemes::theme_map() + theme(legend.position = c(0,.15))

给你