I have a list of variables and values for several subjects in a data frame (see below). I am using R/R Studio and would like to reformat the data to return every possible combination of variables, as well as their corresponding values for each subject. The actual dataset is much larger than this, so any way of doing it programmatically would be greatly appreciated.
Thankyou
My current data
Variable Subject Value
V1 A 1
V1 B 0
V1 C 1
V2 A 0
V2 B 1
V2 C 0
V3 A 1
V3 B 1
V3 C 1
My desired output:
Subject Variable 1 Variable 2 Value 1 Value 2
A V1 V2 1 0
A V1 V3 1 1
A V2 V3 0 1
B V1 V2 0 1
B V1 V3 0 1
B V2 V3 1 1
C V1 V2 1 0
C V1 V3 1 1
C V2 V3 0 1