Dear R- helpers

Following a draft structure of the R script for which I am facing problem

Step 1
x <-   of type array with original values
y <-   of type array  with original values


Step 2

for (ctr in 1:10) {

# my problem here the both x and y still show the original values from step 1
# in spite of making changes to the old values of the arrays x and y in the function
   function (x,y)  ???

    }


step3


output < - function(parX,parY){

          Variables for New X and Y
	newx <- array(parX, dim=c(1,length(parX)))
	newy <- array(parY, dim=c(1,length(parY)))

                # make some calculation and updated some arrays element in the newX and   # #newY


                       # finally assign the global  original values x and y with newX and newY
                        
                       x<- newx
	           y<- newy
                      # if print here I can see the new values
                  
                       # but when the function gets called the second time  the original values of 
           #  x and y get called hence failing my motive of passing update values of                  #the arrays to the function each time   ???
}
I believe there something to deal with env or new.env.... but never could get the concept of the variable scope.....where the fact with the function the x and y get updated but while calling from the main loop the x and y are pointing to old values

  also I am keen to know as to is there a way to clear the array of old values and reasign new values..or the <- operator take care of it by overwriting

regards
Kunal


