search for: meanrotation

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

2009 Mar 27
1
add variable in for loop
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[i,3]-data[i,2])+abs(data[i,4]-data[i,2])+abs(data[i,5]-data[i,2])+abs(data[i,6]-data[i,2]))/4 cat(i,meanrotation,"\n") #total+=meanrotation } #print (total/80) } In perl there's an assignment operator variable+=variable2. Is there anything like this in R to do as i...