Spreading a two column data frame with tidyr

后端 未结 5 2001
渐次进展
渐次进展 2020-11-30 14:47

I have a data frame that looks like this:

  a b
1 x 8
2 x 6
3 y 3
4 y 4
5 z 5
6 z 6

and I want to turn it into this:

  x y          


        
5条回答
  •  一向
    一向 (楼主)
    2020-11-30 15:31

    Another base answer (that also looks like fast):

    data.frame(split(df$b,df$a))
    

提交回复
热议问题