toMatrix: Converts an array into a matrix

View source: R/utils.R

toMatrixR Documentation

Converts an array into a matrix

Description

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.

Usage

	toMatrix(data)

Arguments

data

An array or a matrix

Value

A matrix

Author(s)

Gunnar Libsieller

Examples

	data <- matrix(1:9, nrow=3)
	colnames(data) <- c("a","b","c")
	x <- data[1,]
	is.matrix(x)
	x <- toMatrix(x)
	is.matrix(x)

rietho/IPO documentation built on Dec. 6, 2022, 8:17 a.m.