Skip to content

function which can apply a function by a grouping variable and also hand over an additional variable, e.g. a weight

2 messages · Werner W., Hadley Wickham

#
Hi,

I was wondering if there is an easy way to accomplish the following in R:
Often I want to apply a function, e.g. weighted.quantile from the Hmisc package 
to grouped subsets of a data.frame (grouping variable) but then I also need to 
hand over the weights which seems not possible with summaryBy or aggregate or 
the like.

Is there a function to do this? Currently I do this with loops but it is very 
slow.

I would be very grateful for any hints.

Thanks,
  Werner
#
You might want to check out the plyr package.
Hadley
On Fri, Oct 1, 2010 at 6:05 AM, Werner W. <pensterfuzzer at yahoo.de> wrote: