I've been struggling with trying to put percentage labels on a pie chart in ggplot2. I know this has been posted a lot but I wasn't able to use examples to get my code to work. I'm just looking for a simple and a efficient way to add percentages. Thank you. The code is as follows:
AccidentTypes <-read.csv(file.choose(),header=TRUE,sep=',')
dput(AccidentTypes)
Output:
'''
structure(list(X0 = 1:7, AccidType = c("MotorVeh", "Poison",
"Drowning", "Fires", "Falls", "Firearms", "Other"), Deaths = c(10547L,
942L, 679L, 350L, 258L, 205L, 1074L)), class = "data.frame", row.names = c(NA,
-7L))
'''
My code for the pie chart is as follows:
ggplot(AccidentTypes,aes(x="",y=Deaths,fill=AccidType)) +
geom_bar(stat='identity',width=1,color='white') +
coord_polar('y',start=0) +
ggtitle('Mortality Rates from Different Accident Types') +
theme_void()
Thank you again for taking the time to look.