[R] Merge records in the same dataframe

Peter Alspach
Thu, 05 Nov 2009 21:24:24 -0000

Tena koe Satish

I'm not entirely sure what you want, but did you check aggregate()?

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Vadlamani,
> Satish {FLNA}
> Sent: Friday, 6 November 2009 10:16 a.m.
> To: 'R-help at r-project.org'
> Subject: [R] Merge records in the same dataframe
>
> Hi:
>
> Suppose that I have a data frame as below
>
> x1 x2 x3 ... x10 wk1 wk2 ... Wk208 (these are the column names)
>
> For each record, x1, x2, x3 ... x10 are attributes. and wk1,
> wk2, ..., wk208 are the sales recoreded for this attribute
> combination. Suppose that now, that I want to do the following
>
> 1. Merge the data frame so that I have a new data frame
> grouped by values of x2 and x3 (for example). That is, if two
> records have the same values of x2 and x3, they should be summed.
>
> I tried to look at merge, tapply etc. but did not see a fit
> with I want to do above.
>
> Thanks in advance.
>
> Satish
>
> ______________________________________________
> 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.
>