Convert data frame common rows to columns

后端 未结 5 1393
时光取名叫无心
时光取名叫无心 2020-12-10 21:53

Say I have a data frame where one column is some repeating value (dates, IDs, etc). Is there a way to convert a data frame into a now data frame with columns instead of rep

5条回答
  •  無奈伤痛
    2020-12-10 22:05

    If there are always equal numbers of observations in each group, this would be very easy with split then as.data.frame

    as.data.frame(split(d$c, d$b))
    #    aa bb cc
    # 1  30 50 50
    # 2  45 35 40
    # 3  30 40 40
    # 4  50 40 50
    # 5  50 20 40
    # 6  20 50 40
    # 7  35 25 35
    # 8  50 20 40
    # 9  35 30 30
    # 10 35 50 25
    

提交回复
热议问题