Thanks Jean, that worked perfectly!
Try this
sapply(split(df, df$g), function(x) apply(x[, 1:2], 2, weighted.mean,
x$w))
Jean
StellathePug wrote on 09/21/2011 01:15:33 PM:
>
> I have a data frame, say df, which has 4 variables, one of which I would
> like to use as a grouping variable (g), an
Try this
sapply(split(df, df$g), function(x) apply(x[, 1:2], 2, weighted.mean,
x$w))
Jean
StellathePug wrote on 09/21/2011 01:15:33 PM:
>
> Dear R Users,
> I have looked for a solution to the following problem and I have not
been
> able to find it on the archive, through Google or in the R
Dear R Users,
I have looked for a solution to the following problem and I have not been
able to find it on the archive, through Google or in the R documentation.
I have a data frame, say df, which has 4 variables, one of which I would
like to use as a grouping variable (g), another one that I woul
3 matches
Mail list logo