Re: [R] Generalised rbind/cbind

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Sat 22 Oct 2005 - 09:16:00 EST

On Fri, 2005-10-21 at 17:42 -0500, hadley wickham wrote:
> Dear list,
>
> Is there a generalised form of rbind/cbind for combining
> matrices/arrays into higher-D structures? ie. if I have:
>
> a <- matrix(2,2,2)
> b <- matrix(3,2,2)
>
> how can I get
>
> array(rep(c(3,2), each=4), c(2,2,2))
>
> ?
>
> It seems like this would be the job of a generalised abind function:
> abind(a,b, along=1) == rbind(a,b)
> abind(a,b, along=2) == cbind(a,b)
> abind(a,b, along=3) ==array(rep(c(3,2), each=4), c(2,2,2))
>
> Thanks,
>
> Hadley

Hadley,

You just described the abind() function in the 'abind' package by Tony Plate and Richard Heiberger.

HTH, Marc Schwartz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Oct 22 09:20:09 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:17:32 EST