This functions works very similar to well-known base `cbind` or `rbind` function. However, there is one big difference between these functions. If you pass a vector, each value will be get individually.

col_bind(...)

row_bind(...)

Arguments

...

single values, vectors, matrices or data.frames

Value

a matrix being a product of matrix/vector/values binding

Examples

# `col_bind` vs `cbind` cbind(1,2,3,4,5)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 3 4 5
col_bind(1,2,3,4,5)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 3 4 5
cbind(1:5)
#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3 #> [4,] 4 #> [5,] 5
col_bind(1:5)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 3 4 5
cbind(matrix(3, 3, 3), 0.33, 4:7)
#> Warning: number of rows of result is not a multiple of vector length (arg 3)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 3 3 3 0.33 4 #> [2,] 3 3 3 0.33 5 #> [3,] 3 3 3 0.33 6
col_bind(matrix(3, 3, 3), 0.33, 4:7)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] #> [1,] 3 3 3 0.33 4 5 6 7 #> [2,] 3 3 3 0.33 4 5 6 7 #> [3,] 3 3 3 0.33 4 5 6 7
# `row_bind` vs `rbind` rbind(1,2,3,4,5)
#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3 #> [4,] 4 #> [5,] 5
row_bind(1,2,3,4,5)
#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3 #> [4,] 4 #> [5,] 5
rbind(1:5)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 3 4 5
row_bind(1:5)
#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3 #> [4,] 4 #> [5,] 5
rbind(matrix(3, 3, 3), 0.33, 4:7)
#> Warning: number of columns of result is not a multiple of vector length (arg 3)
#> [,1] [,2] [,3] #> [1,] 3.00 3.00 3.00 #> [2,] 3.00 3.00 3.00 #> [3,] 3.00 3.00 3.00 #> [4,] 0.33 0.33 0.33 #> [5,] 4.00 5.00 6.00
row_bind(matrix(3, 3, 3), 0.33, 4:7)
#> [,1] [,2] [,3] #> [1,] 3.00 3.00 3.00 #> [2,] 3.00 3.00 3.00 #> [3,] 3.00 3.00 3.00 #> [4,] 0.33 0.33 0.33 #> [5,] 4.00 4.00 4.00 #> [6,] 5.00 5.00 5.00 #> [7,] 6.00 6.00 6.00 #> [8,] 7.00 7.00 7.00