'Pivot_longer dependent on value in another column
My df looks like this:
Name V1 V2 V3 choice
Apple sports sports sports v2
Banana hobbies hobbies hobbies v3
Mango interests interests interests v1
I would like to manipulate the df to look like this using pivot_longer:
Name choice choice_word
Apple v2 hobbies
Banana v3 interests
Mango v1 sports
Unfortunately, I could not find an appropriate answer online. Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
