0

I have a dataframe with the following structure:

            Team S13.14 S14.15 S15.16 S16.17
1              A  12.70   4.15 118.60 122.53
2              B   1.20   7.25 232.33 140.23
3              C   2.35  70.02  84.63  90.83
4              D   2.98 126.10 129.80 122.33

I would like to obtain a data.frame like the following:

            Team  Season   Level 
1              A  S13.14   12.70
2              A  S14.15    4.15
....
n              C  S13.14    2.35
....
k              D  S16.17  122.33

In words: I would like to transform current column names into factors. I can't figure out a way of doing it without too much typing. Any suggestion?

k88074
  • 2,042
  • 5
  • 29
  • 43
  • 1
    The [`reshape`](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/reshape.html) function may be useful here – bouncyball Jan 10 '17 at 20:11
  • Both `reshape` and `melt` did the job, thanks. I noticed one difference: in the resulting dataframe `reshape` produces row indices of type "Team.S13.14", while `melt` produces numerical indices. I will prefer the latter alternative. – k88074 Jan 10 '17 at 20:32

0 Answers0