search for: grandtot

Displaying 2 results from an estimated 2 matches for "grandtot".

Did you mean: gradtol
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...
2012 Oct 26
3
summation sign
Hi all, I have a very quick question on how to use the summation sign in R for the function. Here?s a basic example: the function is sum(i=1 to 5)log(1-xi^2) Id be grateful if someone knows how to do this without writing it out 5 times - I am looking sth along the lines of the following: computeR <- function(x) { return (-sum(log(1-x^2)) }^ thank you vm in advance! -- View this