Learn R Programming

frt (version 0.1)

concat: Combine rows of two input matrices

Description

Internal function, generally not called by users.

Usage

concat(x1, x2)

Arguments

x1
A matrix. It can have any numbers of columns and rows, but cannot be empty
x2
A matrix. It can have any numbers of columns and rows, but cannot be empty

Value

Details

This function takes as input two matrices and builds a matrix with all the possible combinations of the rows of the first input matrix, with the rows of the second one. If $r1$ and $c1$ (resp. $r2$ and $c2$) are the row and the column number of the matrix x1 (resp. x2), then the output matrix will have $c1 + c2$ columns and $r1 * r2$ rows. Therefore, each row of the output matrix is composed by any of the rows of x1 (in the first $c1$ columns) and any of the rows of x2 (in the column from $c1 + 1$ to $c1 + c2$).

Examples

Run this code
m1 <- matrix(1:6, nrow=2, ncol=3)
print(m1)
m2 <- matrix(c(0,0,0,1,1,0,1,1), nrow=4, ncol=2)
print(m2)
concat(m1,m2) 

Run the code above in your browser using DataLab