[R] Merge records in the same dataframe

Vadlamani, Satish {FLNA}
Thu, 05 Nov 2009 21:15:46 -0000

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