On Mon, 16 Nov 2009 10:43:38 -0500 Andrew Miles
wrote:
> Thanks! Using the plyr package and the approach you outlined seems to
> work well for relatively simple functions (like wtd.mean), but so far
> I haven't had much success in using it with more complex descriptive
> functions like des
Thanks! Using the plyr package and the approach you outlined seems to
work well for relatively simple functions (like wtd.mean), but so far
I haven't had much success in using it with more complex descriptive
functions like describe {Hmisc}. I'll take a look later, though, and
see if I ca
In addition to using the survey package (and the svyby function), I've found
that many of the 'weighted' functions, such as wtd.mean, work well with the
plyr package. For example,
wtdmean=function(df)wtd.mean(df$obese,df$sampwt);
ddply(mydata, ~cut2(age,c(2,6,12,16)),'wtdmean')
hth, david free
In addition to using the survey package (and the svyby function), I've found
that many of the 'weighted' functions, such as wtd.mean, work well with the
plyr package. For example,
wtdmean=function(df)wtd.mean(df$obese,df$sampwt);
ddply(mydata, ~cut2(age,c(2,6,12,16)),'wtdmean')
hth, david free
Have you reviewed the survey package functions?
--
David
On Nov 14, 2009, at 5:31 PM, Andrew Miles wrote:
I've noticed that R has a number of very useful functions for
obtaining descriptive statistics on groups of variables, including
summary {stats}, describe {Hmisc}, and describe {psych}, but
I've noticed that R has a number of very useful functions for
obtaining descriptive statistics on groups of variables, including
summary {stats}, describe {Hmisc}, and describe {psych}, but none that
I have found is able to provided weighted descriptives of subsets of a
data set (ex. descri
6 matches
Mail list logo