I have a tidy dataframe with study data. "init_cont" and "family" represent the different conditions in this study. There are three possible options for init_cont (A, B, or C) and two possible options for family (D or E), yielding a 3x2 experimental design. In this example, there are two different questions that each participant must answer (specified in column "qnumber"). The "value" column indicates their response to the question asked.
id init_cont family qnumber value
1 A D 1 5
1 A D 2 3
2 B D 1 4
2 B D 2 2
3 C E 1 4
3 C E 2 3
4 A E 1 5
4 A E 2 2
I am trying to determine the best way (preferably within the tidyverse) to determine the average of the values for each question, separated by condition. There are 6 conditions, which come from the 6 combinations of the 3 options in init_cont combined with the 2 options in family. In this dataframe, there are only 2 questions, but the actual dataset has 14.
I know I could probably do this by making distinct dataframes for each of the 6 conditions and then breaking these down further to make distinct dataframes for each question, then finding the average values for each dataframe. There must be a better way to do this in fewer steps.