[R] composed matrices

Chuck Cleland ccleland at optonline.net
Thu Mar 29 13:17:01 CEST 2007


Eva Ubl wrote:
> I have just started programming in R and so my question might be basic but
> I cant find it in the manual
> I have four matrices A,B,C and D and want them to compose in a big matrix X
> with A in the upper left corner, B in the right upper corner, c below A
> and D below B.

A <- matrix(1:4, ncol=2)
B <- matrix(5:8, ncol=2)
C <- matrix(9:12, ncol=2)
D <- matrix(13:16, ncol=2)

rbind(cbind(A,B), cbind(C,D))
     [,1] [,2] [,3] [,4]
[1,]    1    3    5    7
[2,]    2    4    6    8
[3,]    9   11   13   15
[4,]   10   12   14   16

?rbind
?cbind

> Thanks for your help
> eva
> 
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list