RE: [R] weighted.mean and tapply (again)

From: Berton Gunter <gunter.berton_at_gene.com>
Date: Thu 26 May 2005 - 02:50:19 EST


>
> 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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 26 03:02:25 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:05 EST