mergeMatrixList: Merge Multiple Matrices from List

View source: R/mergeMatrices.R

mergeMatrixListR Documentation

Merge Multiple Matrices from List

Description

This function allows merging of multiple matrix-like objects from an initial list. The matix-rownames will be used to align common elements, either be returning all common elements mode='intersect' or containg all elements mode='union' (the result may contains additional NAs).

Usage

mergeMatrixList(
  matLst,
  mode = "intersect",
  useColumn = 1,
  na.rm = TRUE,
  extrRowNames = FALSE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

matLst

(list containing matrices or data.frames) main input (multiple matrix or data.frame objects)

mode

(character) allows choosing restricting to all common elements (mode='intersect') or union (mode='union')

useColumn

(integer, character or list) the column(s) to consider, may be 'all' to use all, integer to select specific indexes or list of indexes or colnames for cutom-selection per matrix

na.rm

(logical) suppress NAs

extrRowNames

(logical) decide whether columns with all values different (ie no replicates or max divergency) should be excluded

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Details

Custom column-names can be given by entering matrices like named arguments (see examples below). The choice of columns tu use may be adopted to each matrix entered, in this case the argument useColumn may be a list with matrix-names to use or a list of indexes (see examples below).

Note, that matrices may contain repeated rownames (see examples, mat3). In this case only the first of repeated rownames will be considered (and lines of repeated names ignored).

Value

This function returns a matrix containing all selected columns of the input matrices to fuse

See Also

merge, mergeMatrices for separate entries

Examples

mat1 <- matrix(11:18, ncol=2, dimnames=list(letters[3:6],LETTERS[1:2]))
mat2 <- matrix(21:28, ncol=2, dimnames=list(letters[2:5],LETTERS[3:4]))
mat3 <- matrix(31:38, ncol=2, dimnames=list(letters[c(1,3:4,3)],LETTERS[4:5]))

mergeMatrixList(list(mat1, mat2))

mergeMatrixList(list(m1=mat1, m2=mat2, mat3), mode="union", useCol=2)

wrMisc documentation built on Sept. 11, 2024, 6:10 p.m.