toMatrix | R Documentation |
This function converts an array into a matrix. This is useful to counter the implicit casting of matrices into arrays when only one row is selected. If a matrix is passed to the function, the matrix is returned, if an array is passed, a matrix with one row is returned.
toMatrix(data)
data |
An array or a matrix |
A matrix
Gunnar Libsieller
data <- matrix(1:9, nrow=3) colnames(data) <- c("a","b","c") x <- data[1,] is.matrix(x) x <- toMatrix(x) is.matrix(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.