Entering edit mode
5.6 years ago
kristopherfernandez
▴
10
Given a dataframe:
Sample_Name SNP1 SNP2 SNP3
Sample 1 AA AC GC
Sample 2 GA AC CG
Sample 3 AA AA GG
How do I get:
Sample_Name SNP Value
Sample 1 SNP1 AA
Sample 1 SNP2 AC
Sample 1 SNP3 GC
Sample 2 SNP1 GA
Sample 2 SNP2 AC
Sample 2 SNP3 CG
...
I'm a beginner and I've been trying to find a way to do this but none of the options I've tried have been successful. Thanks to anyone who could help!
Minor point: You're unpivoting the data (going from wide-form to long-form), not pivoting it.