Hi,
I'm trying to generate an overlaying plot including bar plot and line plot.
The data for line plot, however, has some missing values in some categories. I was able to create bar plot with geom_point but no line was plotted when using geom_line - I also added group = 1 in aes but no luck.
a <- data.frame(score = c("2.51-3.00", "3.01-3.50", "3.51-4.00", "4.01-4.50", "4.51-5.00"),
count = c(2, 1, 4, 6, 2),
ch = c(1, NA, 3, NA, 4))
And here is the code I tried:
ggplot(a) +
geom_bar(aes(x=score, y=count), stat = "identity") +
geom_point(aes(x = score, y = ch), color="red") +
geom_line(aes(x = score, y = ch, group = 1), stat = "identity", color="red")
Any comments and suggestions on how to add a line to the plot are appreciated!
Thank you!