0

Basically I have a data frame that looks like this:

   observed metric       id
      <dbl> <chr>      <int>
 1     31.4 metric1       1
 2     32.5 metric2       1
 3     23.7 metric3       1
 4     34.4 metric1       2
 5     36.5 metric2       2
 6     27.7 metric3       2
 7     39.4 metric1       3
 8     32.5 metric2       3
 9     21.7 metric3       3

And I would like to have the metric column to "turn into" headers, such as:

   observed  id    metric1     metric2     metric3
      <dbl> <int>   <dbl>       <dbl>       <dbl>
 1     31.4  1      31.4        32.5        23.7 
 2     32.5  2      34.4        36.5        27.7
 3     23.7  3      39.4        32.5        21.7

I've tried arrange and reshape2. But maybe I did it wrong, because I haven't been able to get the correct reshaping.

Denver Dang
  • 2,433
  • 3
  • 38
  • 68

0 Answers0