[R] tapply for function taking of >1 argument?

sjaffe sjaffe at riskspan.com
Tue Feb 2 22:16:06 CET 2010

'fraid not :-((

tapply( data, groups, weighted.mean, weights) 

won't work because the *entire* weights vector is passed as the 2nd arg to
weighted.means. But weighted.mean needs 'weights' to be split in the same
way as 'data' -- the first and 2nd args need to correspond. 

Jorge Ivan Velez wrote:
> Hi sjaffem,
> You were almost there:
> tapply( yourdata, groups, weighted.mean, weights)
> See ?tapply for more information.
> HTH,
> Jorge

View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1460419.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list