toMatrix: Converts an array into a matrix

Description Usage Arguments Value Author(s) Examples

View source: R/utils.R

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

1

Arguments

data

An array or a matrix

Value

A matrix

Author(s)

Gunnar Libsieller

Examples

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

IPO documentation built on Nov. 8, 2020, 8:31 p.m.