Aggregate R sum

后端 未结 3 755
遥遥无期
遥遥无期 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 10:05

    You need to tell the aggregate function to use sum, as the default is for it to get the mean of each category. For example:

    aggregate(datos[,c("a1","a2","a3")], by=list(datos$Position), "sum")
    

提交回复
热议问题