I'm looking to convert a data frame from wide to long format, while maintaining multiple columns.
Here is sample data:
df <- read.table(header=T, text='
Subject Day Correct1 Correct2 Correct3 Percent1 Percent2 Percent3
1 1 1 0 1 50 25 70
2 1 1 0 0 75 30 80
3 1 0 1 1 70 45 90
4 1 0 1 0 80 50 100
5 1 1 1 1 90 60 100
1 2 0 1 0 30 75 90
2 2 0 0 1 45 70 80
3 2 1 1 0 50 30 90
4 2 1 0 0 60 45 100
5 2 1 1 1 80 45 90
')
And would like it to look like this -- where I have a Correct and Percent column.
Subject Day Correct CorrectValue Percent PercentValue
1 1 1 1 1 50
2 1 1 1 1 75
3 1 1 0 1 70
4 1 1 0 1 80
5 1 1 1 1 90
1 1 2 0 2 25
2 1 2 0 2 30
3 1 2 1 2 45
4 1 2 1 2 50
5 1 2 1 2 60
1 1 3 1 3 70
2 1 3 0 3 80
3 1 3 1 3 90
4 1 3 0 3 100
5 1 3 1 3 100
1 2 1 0 1 30
2 2 1 0 1 45
3 2 1 1 1 50
4 2 1 1 1 60
5 2 1 1 1 80
1 2 2 1 2 75
2 2 2 0 2 70
3 2 2 1 2 30
4 2 2 0 2 45
5 2 2 1 2 45
1 2 3 0 3 90
2 2 3 1 3 80
3 2 3 0 3 90
4 2 3 0 3 100
5 2 3 1 3 90
Thank you!