Hello. I have a dataset that looks like the following.
data <- data.frame(
Resp = rep(c(4,5,1,3,4,2,4,5,1,2,4,5), 4) ,
Letters = rep(c("A", "A", "B", "B"), each = 12),
Groups = rep(c("Group 1", "Group 2"))
)
What I am looking to do, is find the difference in my outcome (Resp
) between the two levels of Groups
( Group 1
and Group 2
) within each of a grouping variable (Letters
).
In other words, my desired output here would be 2 vectors. One with the differences between group 1 and group 2 when Letters = A and one with the differences between group 1 and group 2 when letters = B.
I was looking to do this in tidyverse somehow using group_by
but I couldn't figure it out.
Many thanks for any help here!