> I'm trying to get the proportion "true" for dichotomous variable for
various
> subgroups in a survey.

Sorry, I'm new to the list, and just saw the advice about minimally
reproducible code. Here goes:


library(survey)
foo <- data.frame(id       = 1:25,
                  weight   = runif(25),
                  year     = rep(2002:2006, 5),
                  problem  = rnorm(25) > 0)
foo.dsn = svydesign(id=~id, weight=~weight, data=foo)
svyby(~problem, ~year, foo.dsn, svymean, na.rm=TRUE) # Fine

# One year is missing 
foo[foo$year == 2004, "problem"] = NA
foo.dsn = svydesign(id=~id, weight=~weight, data=foo)
svyby(~problem, ~year, foo.dsn, svymean, na.rm=TRUE) # Error


thanks
alex

Please access the attached hyperlink for an important electronic communications 
disclaimer: http://lse.ac.uk/emailDisclaimer

______________________________________________
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