0

I am new to R. I have the following code for a plot, but I do not know how to change color of the bars. In the legend section, I also want to replace color with headache. I also need to change label in y axis to "frequency". How can I do it ?

library(tidyverse)

dat= data_frame(rating=1:5, headache=c(167,82, 132, 182, 200), No_headache=c(28, 22, 20, 27, 29))
dat = dat %>%
  gather(key=color, value=value, -rating)
ggplot(data=dat, aes(x=rating, y=value, fill=color)) + 
  geom_bar(stat='identity', position='dodge')
Mary
  • 1,142
  • 1
  • 16
  • 37

0 Answers0