I am trying to plot points on top of existing lines in ggplot. If I plot just the lines, the y axis is in the order that I'd like it to be in. However, when I try to add the points, the y axis order changes and I can't figure out why.
Here's the code I've been using to produce the plot:
ggplot(sincevax_reshape, aes(x=value,y=factor(record_id), group=factor(record_id))) +
xlab("Days Since Vaccine") + ylab("Participant ID") +
geom_line(data=sincevax_reshape[sincevax_reshape$variable=="Sample",], aes(x=value, y=factor(record_id), group=factor(record_id)), color="darkgrey", size=2) +
geom_point(aes(x=value, y=factor(record_id)))
And here's some reproducible data to play around with:
record_id variable value
6 10 Sample -182
7 11 Sample -233
14 21 Sample -189
16 23 Sample -232
17 24 Sample -214
18 24 Sample 20
19 24 Sample 102
1110 10 Today 177
1111 11 Today 118
1112 13 Today 115
1113 14 Today 62
1114 15 Today 111
1115 16 Today 211
1116 18 Today 120
1117 20 Today 97
1118 21 Today 134
1119 22 Today 15
1120 23 Today 90
1121 24 Today 107