Hi Robin,

Before someone gives a better solution, you can try this :

x1<-array(1:10,c(2,5))
x2<-array(1:9,c(3,3))

ArrayAdd<-function(array1,array2)    {

x<-array(0,c(max(nrow(array1),nrow(array2)),max(ncol(array1),ncol(array2))))

x[1:nrow(array1),1:ncol(array1)]<-x[1:nrow(array1),1:ncol(array1)]+array1

x[1:nrow(array2),1:ncol(array2)]<-x[1:nrow(array2),1:ncol(array2)]+array2

    return(x)
}

> x1
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10

> x2
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

> ArrayAdd(x1,x2)
     [,1] [,2] [,3] [,4] [,5]
[1,]    2    7   12    7    9
[2,]    4    9   14    8   10
[3,]    3    6    9    0    0

Nael

	[[alternative HTML version deleted]]

