[R] Percent distributions with the package Survey

From: Wilbur Hadden <wchrch_at_verizon.net>
Date: Tue, 27 May 2008 20:50:20 +0500

How do you make percent distributions by subgroups with the package Survey?

Given a continuous variable X, this command calculates a mean for X.

svymean( ~ X, design=Sdescript, na.rm=T)

If I use cut() to create a factor, Xcat out of X, this command gives a percent distribution.

svymean( ~ Xcat, design=Sdescript, na.rm=T)

This command give means of X by sex.

svyby( ~ X, ~sex, design=Sdescript, svymean, na.rm=T)

But this command, issued in hopes of percent distributions by sex, gives and error.

svyby( ~ Xcat, ~sex, design=Sdescript, svymean, na.rm=T)

The ultimate objective here is to get percent distributions and standard errors for subgroup factors like sex=(M,F) by urban/ rural=(U,R) for factors from a stratified cluster survey.

/Wilbur Hadden

        [[alternative HTML version deleted]]

R-help_at_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. Received on Tue 27 May 2008 - 17:48:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 27 May 2008 - 18:30:46 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive