0

I'm trying to replicate the chart linked below in r but have been unable to. I know that this probably isn't the best way to visualise the information but that's the task I have.

Any help would be great.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
jmc90
  • 11
  • 1
  • 1
  • Welcome to Stack Overflow! Please describe what you have tried so far and the results/errors you got. – bernie Sep 17 '15 at 17:19
  • Sharing some data always helps too, see [here for tips](http://stackoverflow.com/q/5963269/903061) (use `dput()`!) – Gregor Thomas Sep 17 '15 at 17:23

2 Answers2

1

As both comments say, the expectation on SO is that you share data and some code in a minimal example of how far you have gotten. That said, here is a crude starting point, based in part on pie charts in R:

titles <- c(38, 244, 34, 20, 25)
position <- c("Adm","GC","Lawyer","Lawyer2", "Other")
piedf <- cbind(titles, position)
dfpie <- data.frame(piedf)

ggplot(data=dfpie, aes(x=factor(1), y=titles, fill = factor(position))) + 
  geom_bar(width = .6, stat = "identity") +
  labs(x = "", y = "") +
  guides(fill = FALSE) +
  coord_polar(theta="y") +
  theme_bw()

enter image description here

As they say here, I leave it as an exercise for the OP to overlay a donut plot inside the larger pie chart.

lawyeR
  • 7,488
  • 5
  • 33
  • 63
1

you can reproduce the plot using the package ggsunburst

# install ggsunburst package
if (!require("ggplot2")) install.packages("ggplot2")
if (!require("rPython")) install.packages("rPython")
install.packages("http://genome.crg.es/~didac/ggsunburst/ggsunburst_0.0.9.tar.gz", repos=NULL, type="source")
library(ggsunburst)

# trying to replicate the data in your plot
df <- read.table(header = T, text = "
parent node size
Non-Domestic A 30
Non-Domestic B 10
Non-Domestic C 2
Domestic A 20
Domestic B 25
Domestic C 1
Transport A 10
Transport B 15
")

write.table(df, 'df.csv', row.names = F, sep = ",")

sb <- sunburst_data('df.csv', type="node_parent", sep = ",")
sunburst(sb, leaf_labels = F, node_labels = T, node_labels.min = 30, rects.fill.aes = "name") +
  scale_fill_discrete(guide = F)

enter image description here

didac
  • 311
  • 2
  • 4