abind works well for this example.
a1 <- array(1:18, dim=c(3,3,2))
a2 <- array(101:150, dim=c(5,5,2))
a1b <- abind(a1, array(400, dim=c(2,3,2)), along=1)
a1c <- abind(a1b, array(500, dim=c(5,2,2)), along=2)
dim(a1c)
a1
a2
a1c
On Mon, Mar 7, 2011 at 6:54 AM, Usman Munir
<usman.munir06@googlemail.com>wrote:
> Hi,
>
> I have two 3 D arrays. Both are of this form
>
> array_1<- array[n,n,k]
> array_2<-array[m,m,k]
>
> Lets say n=83 and m=80
> Since n>m. I would like to add rows and columns to array_2 to make them
> equal. I want to keep the size of the third dimension fixed i.e.. k.
>
> i.e.
> if (nrow(array_1)>nrow(array_2))
> {
> array_2[m:n,m:n,]<- 10^6
>
> }
>
> But this doesn't work. I tried abind and rbind but it didn't work
either.
> Any help/tips will be appreciated!
>
> Thanks,
> Usman
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
>
http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]