[R] Stratified weighted statistics
vikasrawal at gmail.com
Wed Aug 29 09:19:05 CEST 2007
I need to compute weighted descriptive statistics (mean, median,
variance) for a vector of data disaggregated by a set of index
variables. The weights to be used are vector in the same data frame
and have to be disaggregated by the same index variables.
Package Hmisc has functions for computing weighted statistics. But
both by/aggregate and summarise (in Hmisc) allow a function to have
only a simgle argument. In my case, I need to specify by the variable
and the weights as argument to the function.
Could anyone please advice how to do it.
As an example, say I have a data.frame giving incomes of persons in
different towns along with weights to be given for each sampled
person. How will I compute weighted statistics for each town?
JNU, New Delhi.
More information about the R-help