Skip to content
Prev 22793 / 398502 Next

weighting means

Hi everyone,

I've got a dataframe called 'faculty'. I want to do a weighted mean on
the column called 'Q8' weighted by the contents of column 'CETP'. In
addition, I need to operate on the result of splitting 'faculty'
according to the contents of a column 'FACULTY'. For example
$"1"
[1] 2.2

$"2"
[1] 1.888889

gives the mean of 'Q8' after splitting by 'FACULTY'. When I try this
with weighted.mean, it doesn't work because I don't know how to specify
the result of the split as the argument for weighted.mean. For example,
$"1"
[1] 2.2

$"2"
[1] 1.888889

gives the same results as above because I haven't specified the vector
to use for weighting. The following doesn't work at all for the obvious
reason that weighted.mean is not operating on the result of the split.
faculty$CETP))
Error in match.fun(FUN) : not function, character, or symbol:
"weighted.mean(faculty$Q8, faculty$CETP)"
Any ideas?

-Tim