Indeed, missing data are the problem. The function removes any row with missing 
data and the means are based on the remaining rows. So, I wrote a function that 
just loops over each variable individually and organizes the data as I need it.


-----Original Message-----
From: James Reilly on behalf of James Reilly
Sent: Tue 8/26/2008 5:39 PM
To: Doran, Harold
Cc: r-help@r-project.org
Subject: Re: [R] svymeans question
 

On 26/8/08 9:40 AM, Doran, Harold wrote:
> Computing the mean of the item by itself with svymeans agrees with the
> sample mean
>
>> mean(lower_dat$W524787, na.rm=T)
> [1] 0.8555471
>
> Compare this to the value in the row 9 up from the bottom to see it is
> different.

You might be omitting more cases due to missing values than you expect.
Does the following calculation give you the same results as in rr1?

mean( lower_dat$W524787[ apply( lower_dat[lset], 1,
     function(x) !any(is.na(x)) ) ] )


James
-- 
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand


        [[alternative HTML version deleted]]

______________________________________________
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