I have data from a study using a 2x2x3 repeated measures design. Participants provided a numeric response ('tcons') at two time-points (test: 'pre', 'post'). They were further grouped with respect to two between-persons factors, one with two levels (pretest_leaning: 'pro', 'anti'), the other with three levels (condition: 'both', 'counter', 'favour')
I would like to graph mean responses at both time points, grouped by combinations of each factors. That is, have means at both timepoints for each of the 6 different combinations of the other factors.
Here is the data, with means already calculated:
structure(list(condition = c("both", "both", "both", "both",
"counter", "counter", "counter", "counter", "favour", "favour",
"favour", "favour"), pretest_leaning = c("anti", "anti", "pro",
"pro", "anti", "anti", "pro", "pro", "anti", "anti", "pro", "pro"
), test = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L), levels = c("pre", "post"), class = "factor"), tcons_mean = c(-0.407142857142857,
-0.289285714285714, 0.357142857142857, 0.398809523809524, -0.357142857142857,
-0.0676691729323308, 0.272727272727273, 0.155844155844156, -0.43984962406015,
-0.488721804511278, 0.357142857142857, 0.279220779220779)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -12L), groups = structure(list(
condition = c("both", "both", "counter", "counter", "favour",
"favour"), pretest_leaning = c("anti", "pro", "anti", "pro",
"anti", "pro"), .rows = structure(list(1:2, 3:4, 5:6, 7:8,
9:10, 11:12), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -6L), .drop = TRUE))
I have tried the following. I receive no errors, but the graph is empty.
ggplot(tcons_long, aes(x = test, y = tcons_mean, colour = pretest_leaning, linetype = condition)) + geom_path()