View source: R/mergeMatrices.R
mergeMatrices | R Documentation |
This function allows merging of multiple matrix-like objects.
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 NA
s).
mergeMatrices(
...,
mode = "intersect",
useColumn = 1,
na.rm = TRUE,
extrRowNames = FALSE,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
... |
(matrix or data.frame) multiple matrix or data.frame objects may be entered |
mode |
(character) allows choosing restricting to all common elements ( |
useColumn |
(integer, character or list) the column(s) to consider, may be |
na.rm |
(logical) suppress |
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 |
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).
This function returns a matrix containing all selected columns of the input matrices to fuse
merge
, mergeMatrixList
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]))
mergeMatrices(mat1, mat2)
mergeMatrices(mat1, mat2, mat3, mode="union", useCol=2)
## custom names for matrix-origin
mergeMatrices(m1=mat1, m2=mat2, mat3, mode="union", useCol=2)
## flexible/custom selection of columns
mergeMatrices(m1=mat1, m2=mat2, mat3, mode="union", useCol=list(1,1:2,2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.