This is my code for creating a bar plot using ggplot.
library(tidyverse)
dat= data_frame(rating=1:5, No=c(167,82, 132, 182, 200), Yes=c(28, 22, 20, 27, 29))
dat = dat %>%
gather(key=color, value=value, -rating)
d = ggplot(data=dat, aes(x=rating, y=value, fill=color)) +
geom_bar(stat='identity', position='dodge')+ labs(fill = "headache", y = "frequency")
d = d + scale_fill_manual(values=c("blue", "yellow"))
d = d + theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"))
I need to add frequency of each data to to the top of each bar. Any suggestion?