[R] problem with svyby and NAs (survey package)
A.F.Fenton at lse.ac.uk
A.F.Fenton at lse.ac.uk
Fri Apr 13 19:44:04 CEST 2012
Hello
I'm trying to get the proportion "true" for dichotomous variable for
various subgroups in a survey.
This works fine, but obviously doesn't give proportions directly:
svytable(~SurvYear+problem.vandal, seh.dsn, round=TRUE)
problem.vandal
SurvYear FALSE TRUE
1995 8906 786
1997 17164 2494
1998 17890 1921
1999 18322 1669
2001 17623 2122
...
Note some years are missing - they are part of the dataset, but all
responses are NA (the question wasn't asked).
However, this gives an error, and I'd like to understand why - it works
for variables without missing years:
svyby(~problem.vandal, ~SurvYear, seh.dsn, svymean, na.rm=TRUE)
Error in tapply(1:NROW(x), list(factor(strata)), function(index) { :
arguments must have same length
The error only occurs when na.rm=TRUE and there are no observations in
one year.
Thanks
alex
Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer
More information about the R-help
mailing list