In R, given the following data frame strucure:
Location Date1 Date2 Date3
a value1 value2 value3
b value4 value5 value6
c value7 value8 value9
I would like to trasform the data frame as:
Location Values Date
a value1 Date1
a value2 Date2
a value3 Date3
b value4 Date1
b value5 Date2
....
In order to collpse all columns into one I can use stack {utils}
, but I cannot figure out how to assign the corresponding column name to each observation.