I need to reshape my data frame according to the particular column numbers. My data frame has 2 columns and 1127 rows and it is like that;
Class Gluc
1 3.7
1 3.8
1 3.5
1 3.9
4 4.2
4 5.1
4 5.8
4 4.9
4 5.7
9 6.6
9 6.9
9 8.1
9 8.8
11 7.4
11 8.3
11 9.8
I want to do that the numbers in column 1 (Class) will be column names and glucose values will be align under these new column numbers according to their class number. Like this;
1 4 9 11
3.7 4.2 6.6 7.4
3.8 5.1 6.9 8.3
3.5 5.8 8.1 9.8
3.9 4.9 8.8
5.7
I used "group_by" and "mutate" functions but they didn't work and also they create a list. I want a data frame not a list. If someone help me I will be very appreciated..