[R] Feeding a sequence to a function

Frank Black fb572 at hotmail.com
Sat Apr 22 01:15:38 CEST 2006


Dear all,

I have written a function that takes two arguments, and I would like to feed 
it all pairs of values from -10 to 10.  The following code works for all 
pairs of values between 1 and 10, but given R's indexing, I can't extend it 
back to cover the zeros and the negative values.  I'd appreciate any 
suggestions for a work-around.

Thanks!  Fred

Tau <- matrix(0,10,10)
S2 <- matrix(0,10,10)
R2w <- matrix(0,10,10)

for (i in 1:10) {
     for (j in 1:10) {
          out <- function(i,j)
          Tau[i,j] <- out at Tau
          S2[i,j] <- out at Sigma2
          R2w[i,j] <-out at R2w
     }
}




More information about the R-help mailing list