I have followed code from a previous thread ggplot Donut chart
However, when displaying said 'donut graph' R turns out a pie chart. How do I get a donut chart?
I'm new to R and ggplot.
## add columns for drawing with geom_rect
microcolour.df$Percentage = microcolour.df$Freq / sum(microcolour.df$Freq)*100
microcolour.df = microcolour.df[rev(order(microcolour.df$Percentage)), ]
microcolour.df$ymax = cumsum(microcolour.df$Percentage)
microcolour.df$ymin = c(0, head(microcolour.df$ymax, n=-1))
microcolour.df
## reorder colour levels
print(levels(microcolour.df$Colour))
microcolour.df$Colour <- reorder(microcolour.df$Colour,
new.order = c(10, 1, 9, 5, 2, 11, 4, 8, 7, 6, 3))
## create donut
ggplot(microcolour.df, aes(fill = Colour, ymax = ymax, ymin = ymin, xmax = 100, xmin = 0)) +
geom_rect(colour = "black") +
coord_polar(theta = "y") +
xlim(c(0, 100)) +
theme(panel.grid=element_blank()) +
theme(axis.text=element_blank()) +
theme(axis.ticks=element_blank())
Any help or words of wisdom would be greatly appreciated. I will modify colours etc. after I get round this blip.
Thank you.