search for: weighted_mean

Displaying 1 result from an estimated 1 matches for "weighted_mean".

2012 Aug 27
2
looping through numbered variables
Hello, This is a beginner question. I am trying to loop through numbered variables with "apply" to calculate weighted means. My data is "data", the variables are "var1" to "var100", the weight is "weight". The command works using sapply(paste('data$var', 1:100, sep=''), function(x) weighted.mean(eval(parse(text=x)), data$weight))