M <- matrix(c(4, 5, 6, 7, 8, 9), nrow = 3)
M
vec(M)
if (!requireNamespace("matrixcalc", quietly = TRUE)) {
# Compare vec from \pkg{matrixcalc} and new function.
matrixcalc::vec(M)
# The names are rownames(M):colnames(M) in that order.
# Very similar to matrixcalc but dimension names are different.
} else {
message("you need to install the package matrixcalc to compare this example.")
}
Run the code above in your browser using DataLab