| cvec | R Documentation |
Convert between matrix and vector representations
cvec(A, d = NULL, sparse = FALSE)
rvec(A, d = NULL, sparse = FALSE)
A |
A matrix or a vector |
d |
The number of matrix columns |
sparse |
logical; If |
If A is a matrix, cvec returns the columnwise vectorisation of A.
and rvec returns the rowwise vectorisation of A.
If A is a vector, cvec and rvec return a matrix with d columns,
filled columnwise for cvec and rowwise for rvec.
if (interactive()) {
Ac <- cvec(1:6, 2) # As matrix(1:6, 3, 2, byrow = FALSE)
Ar <- rvec(1:6, 2) # As matrix(1:6, 3, 2, byrow = TRUE)
cvec(Ac) # As as.vector(Ac)
rvec(Ar) # As as.vector(t(Ar))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.