problem accumulating array within a function over loops
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 "local variable", ie a variable local to testf(). They are not the same. As far as I remember, to assign a global variable from inside a function you have to use the <-- operator. (By the way, for 2dim arrays, there is also matrix().) hih Vincent