Aggregate data in one column based on values in another column

前端 未结 4 1724
轮回少年
轮回少年 2021-02-14 00:10

I know there is an easy way to do this...but, I can\'t figure it out.

I have a dataframe in my R script that looks something like this:

A      B    C
1.2         


        
4条回答
  •  你的背包
    2021-02-14 00:12

    Here is a solution using the plyr package

    plyr::ddply(df, .(A), summarize, num = length(A), totalB = sum(B))
    

提交回复
热议问题