Here's a simple use of the tapply function to get a trimmean for each
stratum of X
>tapply(X, strata, mean, trim = 0.1)
The trim argument works. It is atomic.
I'd like to use tapply (or any function) to get a weighted mean for each
stratum of X
>tapply(X, strata, weighted.mean, w = weights)
where weights is a vector of equal length as X and strata.
This generates incorrect weighted means, and a slew of warnings from the
weighted.mean function that w is not the same length as y.
I realize what's happening is the entire weights vector is being used for
strata of X.
In S-Plus 4.5 for Windows, is there a vectorized way to apply to the strata
of a dataset functions like weighted.mean that ask for more than one
stratified argument?
Any advice is appreciated.
************************************************************
John J. Thaden, Ph.D., Instructor jjthaden@life.uams.edu
Department of Geriatrics (501) 257-5583
University of Arkansas for Medical Sciences FAX: (501) 257-4822
mail & ship to: J. L. McClellan V.A. Medical Center
Research-151 (Room GB103 or GC124)
4300 West 7th Street
Little Rock AR 72205 USA
***********************************************************
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|