Description Usage Arguments Value Examples
Convert between matrix and vector representations
1 2 3 |
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
.
1 2 3 4 5 6 | 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.