Re: [R] Weighted descriptives by levels of another variables

2009-11-16 Thread Karl Ove Hufthammer
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

Re: [R] Weighted descriptives by levels of another variables

2009-11-16 Thread Andrew Miles
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

Re: [R] Weighted descriptives by levels of another variables

2009-11-14 Thread David Freedman
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

Re: [R] Weighted descriptives by levels of another variables

2009-11-14 Thread David Freedman
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

Re: [R] Weighted descriptives by levels of another variables

2009-11-14 Thread David Winsemius
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

[R] Weighted descriptives by levels of another variables

2009-11-14 Thread Andrew Miles
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