[R] problem accumulating array within a function over loops

2005-10-05 Thread Jonathan Williams
Dear R helpers, I am having trouble with an array inside a loop. I wish to accumulate the results of a function in an array within the function, over several loops of a program outside the function. The problem is that the array seems to re-set at every entry to the function. Here is an

Re: [R] problem accumulating array within a function over loops

2005-10-05 Thread Dimitris Rizopoulos
Subject: [R] problem accumulating array within a function over loops Dear R helpers, I am having trouble with an array inside a loop. I wish to accumulate the results of a function in an array within the function, over several loops of a program outside the function. The problem

Re: [R] problem accumulating array within a function over loops

2005-10-05 Thread vincent
Jonathan Williams a écrit : maxrun=3; a=array(NA, c(3,5)); run=0 testf=function(x,y){ print(paste('Run:',run)) #check that the function knows about run a[run,1:3]=runif(3); a[run,4]=x; a[run,5]=y #collect numbers into array a } a outside testf is a global variable. a inside testf is a