Set up dummy dataframe
library(ggplot2)
set.seed(1234)
DF <- data.frame(variable = 1:10,
value = sample(10, replace = TRUE))
head(DF,3)
## variable value
## 1 1 10
## 2 2 6
## 3 3 5
Dougnut chart is essentially a bar chart using a polar coordinate system, so we start off with a simple bar chart. And to make life a bit more colourful will fill each slice with a different colour.
ggplot(DF, aes(factor(variable), value, fill = factor(variable))) +
geom_bar(stat="identity")
Next the coordinate system is changed and some of the plot elements are
removed for a cleaner look.
last_plot() + scale_y_continuous(breaks = 0:10) +
coord_polar() + labs(x = "", y = "") + theme(legend.position = "none")