Returns a 1-column matrix, stacking the columns of x
, a matrix or vector.
Also supports comma-separated inputs similar to the concatenation
function c
.
vec(x, ...)
A matrix or vector
(optional) additional objects to be stacked
A one-column matrix containing the elements of x
and ...
in column order
vec(1:3)
#> [,1]
#> [1,] 1
#> [2,] 2
#> [3,] 3
vec(matrix(1:6, 2, 3))
#> [,1]
#> [1,] 1
#> [2,] 2
#> [3,] 3
#> [4,] 4
#> [5,] 5
#> [6,] 6
vec(c("hello", "world"))
#> [,1]
#> [1,] "hello"
#> [2,] "world"
vec("hello", "world")
#> [,1]
#> [1,] "hello"
#> [2,] "world"
vec(1:3, "hello", "world")
#> [,1]
#> [1,] "1"
#> [2,] "2"
#> [3,] "3"
#> [4,] "hello"
#> [5,] "world"