I am trying to visualize continuous data points across two Time points (pre and post intervention) with three parallel Conditions (CET, RES, END), and Response to intervention (High or Low, i.e., CET_Hi, CET_Lo, etc)
I'd like to create a bar graph showing the mean output for each Condition on the X-axis, with separate bars for Time (Pre and Post). Then, I'd like to overlay the individual Subject data points at Pre and Post with lines to connect the Subjects data points and have the Responses grouped by color.
I have successfully created the bar graph using ggplot2 with the geom_bar function. I have also got geom_point to overlay the individual points by condition, but can't get the position aligned with the Time.
ggplot(Leg_Press_Summary, aes(x=Condition, y=Leg_Press, fill=as.factor(Time))) +
geom_bar(stat="identity", position=position_dodge()) +
scale_fill_brewer(palette="Blues", name = "Time", labels = c("Pre", "Post")) +
geom_point(data=Phys_Data, aes(x=Condition, y=Leg_Press, colour=Response, fill=as.factor(Time))) +
geom_line(data=Phys_Data, aes(x=Condition, y=Leg_Press, group=Subject)) +
labs(title="Leg Press", x="Condition", y ="Leg Press (kg)")
I expected the geom_points to be positioned according to Time, however, they points just stack in a vertical line between the Pre and Post bars for each condition.
My result:
Figure I'm trying to recreate:
How can I fix this?
Data set included below, which I forgot to include in original post.
LegPress
# A tibble: 36 x 5
Subject Time Condition Response Leg_Press
6 1 CET CET_Hi 212.
6 2 CET CET_Hi 300
9 1 CET CET_Lo 350
9 2 CET CET_Lo 370
14 1 CET CET_Hi 330
14 2 CET CET_Hi 450
26 1 CET CET_Hi 180
26 2 CET CET_Hi 250
28 1 CET CET_Lo 230
28 2 CET CET_Lo 275
29 1 CET CET_Lo 330
29 2 CET CET_Lo 325
2 1 RES RES_Hi 142.
2 2 RES RES_Hi 225
16 1 RES RES_Lo 280
16 2 RES RES_Lo 320
19 1 RES RES_Hi 205
19 2 RES RES_Hi 295
27 1 RES RES_Hi 175
27 2 RES RES_Hi 260
31 1 RES RES_Lo 340
31 2 RES RES_Lo 370
32 1 RES RES_Lo 310
32 2 RES RES_Lo 370
8 1 END END_Lo 205
8 2 END END_Lo 250
13 1 END END_Hi 310
13 2 END END_Hi 320
20 1 END END_Hi 200
20 2 END END_Hi 185
24 1 END END_Lo 260
24 2 END END_Lo 270
25 1 END END_Hi 210
25 2 END END_Hi 235
30 1 END END_Lo 250
30 2 END END_Lo 245