Re: [R] Combining two matrices

From: Huntsinger, Reid <reid_huntsinger_at_merck.com>
Date: Thu 21 Jul 2005 - 03:27:21 EST


If 16063 were an integer multiple of 217 you could do this in two steps; first construct the left half with rep() or

L <- kronecker(rep(1,16063/217),A)

and then use cbind(L,B).

However, 16063 is not a multiple of 217, so I don't know what you want to do with the leftover 5 rows you need in L. If you want to recycle rows, you could use ceiling(16063/217) in the call to rep and then use cbind(L[1:16063,],B).

Reid Huntsinger

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of mark salsburg Sent: Wednesday, July 20, 2005 1:03 PM
To: R-help@stat.math.ethz.ch
Subject: [R] Combining two matrices

Can someone please refer me to a function or method that resolves this structuring issue:

I have two matrices with identical colnames (89), but varying number of observations:

matrix A                                matrix B

217 x 89                              16063 x 89

I want to creat one matrix C that has both matrices adjacent to one another, where matrix A is duplicated many times to create the same row number for matrix B, i.e. 16063.

matrixA matrix B
matrixA
matrixA

so matrix C will be 16063 x 178

I've tried cbind() and merge() with no success..



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

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 Thu Jul 21 03:42:19 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:53 EST