R summarise by group, then build avg. spend based on condition
I have to create a table that shows average values of each variable DT06_1-DT06_19 (caution: I only have variables DT06_1-DT06_3, DT06_7, DT06_10-DT06_19.
The averages shall be computed by group. I have four groups shown in insuff_suff_res_cat (caution: not every participant shows values for each of the four categories. I dont have rows where the participant shows values for a category).
And last, the averages on each DT06-variable shall only be computed where the respective DT01-variable shows the value “1” instead of “0”.
So together: For each group of the variable “insuff_suff_res_cat”, please calculate the average value of each DT06-variable only if the respective DT01-variable == “1”.