0

Suppose I have a tibble that looks like this:

Name | Category | Rank
----------------------
  A  |    a     |  1   
  A  |    b     |  2   
  A  |    c     |  3   
  A  |    d     |  4  
  B  |    a     |  2   
  B  |    b     |  3   
  B  |    c     |  4   
  B  |    d     |  5   

How do I convert this to a table like this:

Name | a | b | c | d
---------------------
  A  | 1 | 2 | 3 | 4
  B  | 2 | 3 | 4 | 5

The only way I can think of to convert is to do it manually, i.e take a subset of all the rows with that category and convert it to a column in a different tibble. Is there a cleaner way to do this?

Alex Peniz
  • 483
  • 5
  • 14

0 Answers0