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. Thanks for your help eva
try this: A1 <- matrix(1:20, 5, 4) B1 <- matrix(1:15, 5, 3) A2 <- matrix(1:8, 2, 4) B2 <- matrix(1:6, 2, 3) ##################### rbind(cbind(A1, B1), cbind(A2, B2)) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Eva Ubl" <eva.ubl at univie.ac.at> To: <r-help at stat.math.ethz.ch> Sent: Thursday, March 29, 2007 1:10 PM Subject: [R] composed matrices>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. > 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. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
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