Displays all values of a matrix of vectors by “unrolling” the object vertically or horizontally.
unroll(x, bycol = FALSE, drop = TRUE)
a list of vectors with a dim
attribute of
length 0, 1 or 2.
logical; whether to unroll horizontally
(FALSE
) or vertically (TRUE
).
logical; if TRUE
, the result is coerced to the
lowest possible dimension.
A vector or matrix.
unroll
returns a matrix where elements of x
are concatenated (“unrolled”) by row (bycol = FALSE
) or
by column (bycol = TRUE
). NA
is used to make
rows/columns of equal length.
Vectors and one dimensional arrays are coerced to row matrices.
This function was originally written for use in
severity.portfolio
.
# NOT RUN {
x <- list(c(1:3), c(1:8), c(1:4), c(1:3))
(mat <- matrix(x, 2, 2))
unroll(mat)
unroll(mat, bycol = TRUE)
unroll(mat[1, ])
unroll(mat[1, ], drop = FALSE)
# }
Run the code above in your browser using DataLab