R- Collapse rows and sum the values in the column

后端 未结 5 723
情话喂你
情话喂你 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:36

    Using data.table

    setDT(df1)[,  lapply(.SD, sum) , by = ID, .SDcols = "PSM" ]
    

提交回复
热议问题