Skip to content
Prev 312374 / 398506 Next

Fast Normalize by Group

Not tested but should work:

sums = tapply(x, group, sum);
sums.ext = sums[ match(group, names(sums))]
normalized = x/sums.ext

It may be that the tapply is just as slow as your loop though, I'm not sure.

HTH,

Peter
On Thu, Nov 29, 2012 at 10:55 AM, Noah Silverman <noahsilverman at ucla.edu> wrote: