[R] aggravating aggregate

Jim Burke javajimburke at gmail.com
Wed Aug 5 19:45:50 CEST 2015


Greetings R mavens (and that's YOU). Given the following how on earth do I
aggregate and sum duplicate PCT rows into one combined row per PCT?

Data types
> str(xxx)
'data.frame':   9 obs. of  3 variables:
 $ Registered: int  1327 2129 10 433 5 166 1784 17 787 700
 $ GA_Total  : int  127 150 0 32 1 76 153 7 31 23
 $ PCT       : chr  "1120" "1121" "1121" "1122" ...

Data desired to be summarized
Registered GA_Total  PCT
1327       127      1120
2129       150      1121
  10         0      1121
 433        32      1122
   5         1      1124
 166        76      1125
1784       153      1125
  17         7      1125
 787        31      1126

Desired summary
Registered GA_Total  PCT
1327       127      1120
2139       150      1121
 433        32      1122
   5         1      1124
1967       236      1125
 787        31      1126

When answered this please make the reply suitable as a tutorial for many
other puzzled "R" "aggregate" people. Scarce useful examples on the
web. "Aggregate"
is a basic for statistical programming. Yet even ISBN 978-1461471370 An
Introduction to Statistical Learning with "R" does not appear to delve into
"aggerate". Basic simple and useful fully explained answers. If you have to
use "apply" then explain why.

Thanks
Jim Burke

	[[alternative HTML version deleted]]



More information about the R-help mailing list