Skip to content
Prev 304235 / 398503 Next

looping through numbered variables

On Aug 27, 2012, at 7:11 AM, Daniel Caro wrote:

            
You should read the Posting Guide. (As well as following Bert's  
suggestion to work through "Intro to R".
I'm guessing you want:

library( <some package which was not named> )
lapply(data, function(x) weighted_mean(x, data$weight))

(I'm was guessing that weighted_mean was from the Hmisc package (but  
its similar function has a different name), but at any rate, it is  
better practice to indicate what package holds non-core functions. I  
also think it is better practice to use named arguments in function  
calls and to not use teh name "data" for objects, since it is also a  
function name.)

?data