R community,

My question is a bit complex to explain (and consequently difficult to
search for in the archives). I will illustrate it with a simplified
example.

If I have an array of sample sizes for various factor levels, of all
different sizes (due to missing data), and another array of those same
factor levels' means, and I would like to sum the squares and weight
them with their corresponding sample size as such:

ss <- sum( n*(yi.bar - y..bar)^2)

[note that y..bar is not an array]

Will R parse the array n at the same rate as it is yi.bar (an equally
long array of the means of those n samples)? Note that I am more sure
of using something like:
x <- c(data...)
ss <- sum(length(na.exclude(x))*(mean(na.exclude(x)) - y..bar)^2)

But alas, there are cases when only the means and the sample sizes are
supplied, but not the actual data. I would also like to stray away
from using built-in functions (weighted.mean perhaps?) do gain an
understanding of how this would be done.

Thank you!
Vince

-- 
"The greatest challenge to any thinker is stating the problem in a way
that will allow a solution."
-Bertrand Russell

______________________________________________
[email protected] 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