I have created a bar chart using ggplot()
ggplot(data=combined_data) +
geom_bar(mapping=aes(member_casual), fill='green', alpha = 0.5, stat = 'count') +
stat_count(geom = 'text', color='black', position = position_stack(vjust = 0.75),
aes(x = member_casual, label = ..count..))
labs(title = 'Cyclistic: Bike Rentals by Type of Rider',
subtitle = 'November 1, 2021 to October 31, 2022',
caption = 'Public dataset made available by Motivate International Inc.',
x = 'type of rider') +
theme(plot.title = element_text(face = 'bold', size=14,hjust= 0.5),
plot.subtitle = element_text(size = 12,hjust = 0.5),
plot.caption = element_text(face = 'italic', size=9),
axis.title = element_text(size = 12),
axis.text = element_text(size = 12))
The bars are annotated with the count of rides for each category of rider type (member or casual).
How can I add the percentage to the annotation. For example, the bar for member would be annotated as "2589227 (60%)"
I can annotate each bar with the count of rides, but I don't know how to add the percentage or annotate with the percentage instead of the count.