On Sun, Mar 4, 2012 at 8:04 AM, Hed Bar-Nissan <hed.barnis...@gmail.com> wrote:
> Following David example if i just wanted to do means
> would multiplying the cases according to the weight do the work?

If the weights are scaled to have mean 1, and you have no missing
data, then yes.  If you have missing data, the scaling to mean 1 would
be different for different variables.

>
> Something like this on a data.frame
> (Must be a simpler way to do it with R - the sapply scope confused me)

Yes, there must.  For a start, assign() is not your friend.

You should either use a simple weighted.mean() function (your own or
Frank Harrell's), or if you really want to package the weights with
the data, you would be better off doing it thoroughly and using the
survey package.


   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to