Aggregate multiple rows of the same data.frame in R based on common values in given columns

后端 未结 5 905
情歌与酒
情歌与酒 2021-02-02 17:29

I have a data.frame that looks like this:

# set example data
df <- read.table(textConnection(\"item\\tsize\         


        
5条回答
  •  太阳男子
    2021-02-02 18:05

    aggregate(value ~ item + size + weight, FUN = mean, data=df)
    
      item size weight value
    1    B    1      2     3
    2    C    3      2     1
    3    A    2      3     5
    

提交回复
热议问题