[R] array problem

Z P nusbj at hotmail.com
Sun Jan 4 14:42:55 CET 2004


Dear all,

I define , for n=5 or any integer greater than 0.

A<-array((1/2)^n , c(rep(2,n)))

then for any i not equal to j, and 1<=i,j<=n,

B<-apply(a,c(i,j),sum)

now B is a 2 by 2 matrix, I also define another costant 2 by 2 matrix G,

How can I change the values of each elements of array A, according the rule 
that,

for example, i=3,j=5,

A[i1,i2,m,i4,l]<-A[i1,i2,m,i4,l]*G[m,l]/B[m,l]  , where m,l=1,2 and 
i1,i2,i4=1,2

I can control this given any i and j, however, I must do the iteration

for i in 1:(n-1) {
    for j in (i,n)
          {B<-apply(a,c(i,j),sum)
           here change the value of every elements of A according to my rule
            }
                     }

Is there any easy way to change the value of A in the iteration? Thank you.

_________________________________________________________________
Find love on MSN Personals http://personals.msn.com.sg/




More information about the R-help mailing list