Learn R Programming

mefa4 (version 0.2-4)

mbind: Combine R Objects by Rows and Columns

Description

Combine R objects by rows and columns

Usage

mbind(x, y, fill, ...)

Arguments

x, y
objects to combine, see Details.
fill
numeric value or NA (default) to fill up outer set (not part of union) of dimnames.
...
other argument, not used.

Value

  • An object similar to the input one.

Details

x and y are combined in a left join manner, meaning that all the elements in x are retained, and only non-overlapping elements in y are used. Elements of the returning object that are not part of x and y (outer set) are filled up with fill. If relational table in x is NULL, corresponding values from same table of y are used.

See Also

rbind, cbind rBind, cBind for sparse matrices in Matrix package

Examples

Run this code
x=matrix(1:4,2,2)
rownames(x) <- c("a","b")
colnames(x) <- c("A","B")
y=matrix(11:14,2,2)
rownames(y) <- c("b","c")
colnames(y) <- c("B","C")

sampx <- data.frame(x1=1:2, x2=2:1)
rownames(sampx) <- rownames(x)
sampy <- data.frame(x1=3:4, x3=10:11)
rownames(sampy) <- rownames(y)
taxay <- data.frame(x1=1:2, x2=2:1)
rownames(taxay) <- colnames(y)
taxax <- NULL

mbind(x,y)
mbind(as(x,"sparseMatrix"),as(y,"sparseMatrix"))
unclass(mbind(Mefa(x,sampx),Mefa(y,sampy,taxay)))

Run the code above in your browser using DataLab