Group by using base R

前端 未结 2 1321
温柔的废话
温柔的废话 2020-11-30 14:30

Dataset

I have a datasets with column year,quarter,Channel,sales,units

df <- structure(list(year = c(2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 
         


        
2条回答
  •  一整个雨季
    2020-11-30 15:24

    you can try this

    aggregate(sales~year+quarter+Channel, data=df, FUN = sum) # sum of sale
    aggregate(units~year+quarter+Channel, data=df, FUN = mean) # mean of units
    

提交回复
热议问题