Re: [R] add variable in for loop

2009-03-28 Thread Stephan Kolassa
Hi Paul, you do *not* want to do this, it takes too long and may lead to rounding errors. Vectorize everything, e.g., use sum(meanrotation). And look into ?apply, and google for the "R Inferno". And no, there is no "+="... Good luck! Stephan pgseye schrieb: Hi, I'm learning to write some

[R] add variable in for loop

2009-03-28 Thread pgseye
Hi, I'm learning to write some basic functions in R. For some data I have I'd like to be able to add a variable to itself after each iteration in a for loop to obtain a grandtotal for that variable so I can calculate a mean. test<-function(data){ for (i in 1:80){ meanrotation<-(abs(data