R- Collapse rows and sum the values in the column

后端 未结 5 778
情话喂你
情话喂你 2021-02-06 02:46

I have the following dataframe (df1):

ID    someText    PSM OtherValues
ABC   c   2   qwe
CCC   v   3   wer
DDD   b   56  ert
EEE   m   78  yu
FFF           


        
5条回答
  •  星月不相逢
    2021-02-06 03:25

    This is super easy using the plyr package:

    library(plyr)
    ddply(df1, .(ID), summarize, Sum=sum(PSM))
    

提交回复
热议问题