Message-ID: <200505251650.j4PGoJFo020825@meitner.gene.com>
Date: 2005-05-25T16:50:19Z
From: Bert Gunter
Subject: weighted.mean and tapply (again)
In-Reply-To: <7CBBD627E4E688499349A5D11D07831602ECB966@msgpacpbs.rhq.pac.dfo-mpo.gc.ca>
>
> In this simple case you can just coerce directly to a vector like so:
>
> > foo <- by(dat, dat$GROUP, function(x) {weighted.mean(x$VALUE,
> x$FREQUENCY)})
> > bar <- as.vector(foo)
>
> but look at the examples for ?by; in particular the use of 'sapply'.
>
> Norm
As a general practice, I believe unlist() is preferable. ?unlist explains
why.
Cheers,
Bert Gunter