concat: Combine rows of two input matrices

Description Usage Arguments Details Value Author(s) Examples

View source: R/concat.R

Description

Internal function, generally not called by users.

Usage

1
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

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).

Value

A matrix.

Author(s)

Lucia Tamburino

Examples

1
2
3
4
5
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) 

Example output

     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    2    4    6
     [,1] [,2]
[1,]    0    1
[2,]    0    0
[3,]    0    1
[4,]    1    1
 [,1] [,2] [,3] [,4] [,5]
    1    3    5    0    1
    1    3    5    0    0
    1    3    5    0    1
    1    3    5    1    1
    2    4    6    0    1
    2    4    6    0    0
    2    4    6    0    1
    2    4    6    1    1

frt documentation built on May 2, 2019, 6:34 a.m.

Related to concat in frt...