Skip to content
Back to formatted view

Raw Message

Message-ID: <4ECCBC54.6040208@statistik.tu-dortmund.de>
Date: 2011-11-23T09:26:44Z
From: Uwe Ligges
Subject: Aggregating two or more vaiables
In-Reply-To: <1322037189001-4098855.post@n4.nabble.com>

On 23.11.2011 09:33, aa99 wrote:
> hey;
>
> i am new to R and require some help. i have below table data and i would
> like to aggregate Retail and QSold by BrandName.
>
>
> BrandName	Segment	Retail	QSlod
> Oral B	        Whitening	10	2
> Colgate	Sensitive	20	4
> Colgate	Sensitive	30	6
> Oral B	        Whitening	40	8
> Close Up	Whitening	50	10
> Oral B	        Whitening	60	12
>
>
> OutPut I would like:
>
> BrandName	Retail 	QSlod
> Oral B	        sum(Retail)	Sum (Qsold)
> Colgate		
> Close Up		
>


aggregate(cbind(Retail, QSlod) ~ BrandName, data=dat, sum)

Uwe Ligges


>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Aggregating-two-or-more-vaiables-tp4098855p4098855.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.