Cbind | R Documentation |
Take a sequence of matrix-like objects and combine the column-wise matching the rows on the common row names.
Cbind(...)
... |
matrices, vectors or data.frames that are to be combined. These are converted to data frames before merging. |
All the supplied objects have to have row names defined, i.e. calling
rownames
on the should return character vector.
All the objects are converted to data frames prior combining.
The result will have the number of columns equal to the sum of the numbers of columns in the supplied objects. The number of rows will be equal to the number of unique row names in all the arguments.
Data frame consisting of merged objects.
cbind
, rownames
# two matrices
m1 <- m2 <- matrix(1:4, 2, 2)
colnames(m1) <- colnames(m2) <- 1:2
rownames(m1) <- c("a", "b")
rownames(m2) <- c("b", "c")
Cbind(m1, m2)
# matrices and a data frame
l <- list( m1 = m1,
m2 = m2,
d1 = data.frame( x=1:4, y=2:5,
row.names=letters[1:4])
)
do.call("Cbind", l)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.