Aggregate R sum

后端 未结 3 749
遥遥无期
遥遥无期 2020-12-11 09:34

I\'m writting my first program in R and as a newbie I\'m having some troubles, hope you can help me.

I\'ve got a data frame like this:

> v1<-c         


        
3条回答
  •  既然无缘
    2020-12-11 09:47

    This is fairly straightforward with the plyr library.

    library("plyr")
    ddply(datos, .(Position), colwise(sum))
    

    If you have additional non-numeric columns that shouldn't be averaged, you can use

    ddply(datos, .(Position), numcolwise(sum))
    

提交回复
热议问题