Suppose I have an R-frame:
Subject Session Property.A Property.B Property.C
1 100 1 -1.22527548 -0.9193751 -1.7501693
2 100 10 2.30627980 1.8940830 -0.8443976
3 100 2 2.33243332 -0.5860868 -4.2074489
4 100 3 0.38130810 -0.7336206 4.8016230
5 100 4 1.44685875 0.5066249 2.0138624
6 100 5 0.08907721 -0.3715202 1.4983700
I have heard this style of data frame called “short form” or “wide form”. Now suppose I want to make it look like what I heard, called the "long form":
Subject Session Property Value
1 100 1 A -1.2252754
2 100 1 B -0.9193751
3 100 1 C -1.7501693
4 100 2 A 2.3324333
5 100 2 B -0.5860868
6 100 2 C -4.2074489
That is, I have N columns that I want to reduce to two name / value columns, with any other columns in the DataFrame being expanded with duplicate values as needed.
Obviously, I could do this conversion using a bundle for loops, but it seems really ugly, and it would be painful to support if / when I add more property columns.
R ? - , ?