R/rbind-fill-matrix.r
rbind.fill.matrix.RdThe matrices are bound together using their column names or the column
indices (in that order of precedence.) Numeric columns may be converted to
character beforehand, e.g. using format. If a matrix doesn't have
colnames, the column number is used. Note that this means that a
column with name "1" is merged with the first column of a matrix
without name and so on. The returned matrix will always have column names.
rbind.fill.matrix(...)a matrix with column names
Vectors are converted to 1-column matrices.
Matrices of factors are not supported. (They are anyways quite inconvenient.) You may convert them first to either numeric or character matrices. If a matrices of different types are merged, then normal covnersion precendence will apply.
Row names are ignored.
Other binding functions:
rbind.fill()
A <- matrix (1:4, 2)
B <- matrix (6:11, 2)
A
#> [,1] [,2]
#> [1,] 1 3
#> [2,] 2 4
B
#> [,1] [,2] [,3]
#> [1,] 6 8 10
#> [2,] 7 9 11
rbind.fill.matrix (A, B)
#> 1 2 3
#> [1,] 1 3 NA
#> [2,] 2 4 NA
#> [3,] 6 8 10
#> [4,] 7 9 11
colnames (A) <- c (3, 1)
A
#> 3 1
#> [1,] 1 3
#> [2,] 2 4
rbind.fill.matrix (A, B)
#> 3 1 2
#> [1,] 1 3 NA
#> [2,] 2 4 NA
#> [3,] 6 8 10
#> [4,] 7 9 11
rbind.fill.matrix (A, 99)
#> 3 1
#> [1,] 1 3
#> [2,] 2 4
#> [3,] 99 NA