I am trying to manipulate this data frame:
df
name date X Y
Person1 Monday 1 5
Person2 Monday 2 6
Person1 Tuesday 3 7
Person2 Tuesday 4 8
To look like this:
name variable Monday Tuesday
Person1 X 1 3
Person1 Y 5 7
Person2 X 2 4
Person2 Y 6 8
Is there a way to manipulate my original data frame to get this result using R?
This was marked as a duplicate, but neither of the links provided solved my problem because I am not quite going from wide to long or long to wide.