I am trying to modify aggregate.data.frame to create an aggregate method for
survey design objects. I am running into problems because survey design
objects are lists, with the variables and other design information stored in
separate dataframes, or objects of other classes, in this list. *Apply and split
functions do not seem to work on the design objects. How do I approach this,
without having to rewrite *apply and split (and what would that involve?)? I
thought of creating lots of subsets, using "subset", but that does not
seem to be
a good approach.
For example, the following line which does most of the work in the
aggregate.data.frame does not work for design objects:
y <- lapply(income, tapply, list(age,sex), svymean, brf.d.na,simplify =
FALSE)
neither does the following:
y <- lapply(split(income, list(age,sex)), svymean,brf.d.na)
[[alternative HTML version deleted]]
On Wed, 15 Oct 2003 TyagiAnupam at aol.com wrote:> I am trying to modify aggregate.data.frame to create an aggregate method for > survey design objects. I am running into problems because survey design > objects are lists, with the variables and other design information stored in > separate dataframes, or objects of other classes, in this list. *Apply and split > functions do not seem to work on the design objects. How do I approach this, > without having to rewrite *apply and split (and what would that involve?)? I > thought of creating lots of subsets, using "subset", but that does not seem to be > a good approach. >I think the right approach is to extract the `variables' component of the survey.design, use aggregate on it, and then work out how to attach the right design metadata (weights, clusters, &c) to it. This is not completely trivial, or I would have done it already. -thomas