tidyr spread does not aggregate data

余生长醉 提交于 2019-12-04 11:28:23

We need to create a sequence column to avoid the duplicate identifiers row Error.

library(tidyr)
library(dplyr)
data %>% 
    group_by(grouping) %>% 
    mutate(id = row_number()) %>% 
    select(-unique) %>%
    spread(grouping, value) %>%
    select(-id)
#     a     b     c
#  (int) (int) (int)
#1    15     8    17
#2    21     6     1
#3    26     4     3
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!