I want to see the percentage values on the stacked bars in my plot. Here is an example,
library(tidyverse)
year <- c(2011, 2011, 2012, 2012, 2013, 2013)
gender <- c("M", "F", "M", "F", "M", "F")
value <- c(10, 12, 12, 15, 32, 53)
dataf <- data.frame(year, gender, value)
dataf$year <- as.Date(as.character(dataf$year), format = "%Y")
ggplot(dataf, aes(fill = gender,
y = value,
x = year)) +
geom_bar(position = "fill",
stat = "identity")
Here is a post covering similar issues but not sure how to calculate percentage on the value column I have. Any suggestions?