[R] Sum according observation

Henrique Dallazuanna wwwhsd at gmail.com
Fri Sep 18 19:21:55 CEST 2009


Try this:

with(DF, tapply(var2, var1, sum))

On Fri, Sep 18, 2009 at 12:18 PM, MarcioRibeiro <mestat at pop.com.br> wrote:
>
> Hi listers,
> I have a simple doubt...
> I need to manipulate the data base as:
>
> var1 var2
> 7      0.1
> 7      0.1
> 8      0.12
> 10    0.15
> 12    0.18
> 20    0.31
>
> I would like to aggregate the equal cases as var1 making the sum of var2...
> I would get...
>
> var1 var2
> 7      0.2
> 8      0.12
> 10    0.15
> 12    0.18
> 20    0.31
>
> Thanks in advance,
> Marcio
> --
> View this message in context: http://www.nabble.com/Sum-according-observation-tp25510566p25510566.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list