align_matrices {cmapR} | R Documentation

## Align the rows and columns of two (or more) matrices

### Description

Align the rows and columns of two (or more) matrices

### Usage

    align_matrices(m1, m2, ..., L = NULL, na.pad = TRUE, as.3D = TRUE)

### Arguments

`m1` | a matrix with unique row and column names
`m2` | a matrix with unique row and column names
`...` | additional matrices with unique row and column names
`L` | a list of matrix objects. If this is given, m1, m2, and ... are ignored
`na.pad` | boolean indicating whether to pad the combined matrix with NAs for rows/columns that are not shared by m1 and m2.
`as.3D` | boolean indicating whether to return the result as a 3D array. If FALSE, will return a list.

### Value

an object containing the aligned matrices. Will either be a list or a 3D array

### Examples

    # construct some example matrices
    m1 <- matrix(rnorm(20), nrow=4)
    rownames(m1) <- letters[1:4]
    colnames(m1) <- LETTERS[1:5]
    m2 <- matrix(rnorm(20), nrow=5)
    rownames(m2) <- letters[1:5]
    colnames(m2) <- LETTERS[1:4]
    m1
    m2

    # align them, padding with NA and returning a 3D array
    align_matrices(m1, m2)

    # align them, not padding and retuning a list
    align_matrices(m1, m2, na.pad=FALSE, as.3D=FALSE)

[Package cmapR version 1.6.0 Index]