I have data that is ordered in classes, as described in this article: https://www.r-bloggers.com/from-continuous-to-categorical/ This makes it easier to see which values are common. After creating those classes I want to create a barchart with the frequency of the different classes, which I do with the following exemplary code:
set.seed(1)
df.v <- data.frame(val = rnorm(1000, mean(4, sd=2)))
df.v$val.clss <- cut(df.v$val, seq(min(df.v$val), max(df.v$val), 1))
p1 <- ggplot(data = df.v)+
geom_bar(aes(val.clss))
plot(p1)
What I can not figure out, is how to add a vertical line exactly between the two bars around 4, so the line is perfectly at the x-axis value. I have found this article, but this did not help me: How to get a vertical geom_vline to an x-axis of class date? Any help is appreciated. Maybe I am too new to adapt the solution to my data.frame, if so, please excuse the question.
See Question&Answers more detail:os