Re: [R] looping through numbered variables

2012-08-27 Thread Daniel Caro
Thank you, character indexing (?"[") is what I was looking for: sapply(paste('var', 1:100, sep=''), function(x) weighted.mean(data[[x]], data$weight)) Daniel On Mon, Aug 27, 2012 at 6:26 PM, Bert Gunter wrote: > Have you read "An Introduction to R". If not, please do so before > osting and pay

Re: [R] looping through numbered variables

2012-08-27 Thread David Winsemius
On Aug 27, 2012, at 7:11 AM, Daniel Caro wrote: Hello, This is a beginner question. You should read the Posting Guide. (As well as following Bert's suggestion to work through "Intro to R". I am trying to loop through numbered variables with "apply" to calculate weighted means. My data i

Re: [R] looping through numbered variables

2012-08-27 Thread Bert Gunter
Have you read "An Introduction to R". If not, please do so before osting and pay particular attention to the section on indexing. If so, re-read the sections on indexing. For a terser exposition, ?"[" -- Bert On Mon, Aug 27, 2012 at 7:11 AM, Daniel Caro wrote: > Hello, > > This is a beginner qu