to.matrix: Conversion to a matrix.

to.matrixR Documentation

Conversion to a matrix.

Description

to.matrix attempts to convert any data to a row matrix. In particular, data frames are converted by as.matrix, (numeric) vectors are converted to a single row/column matrix, according to the rowMatrix argument.

Usage

to.matrix(x, rowMatrix = TRUE)

Arguments

x

data to convert to a matrix

rowMatrix

if TRUE, numeric vectors are converted to a single row matrix, if FALSE, they get converted to a single column matrix

Value

matrix

Author(s)

Tomas Sieger

Examples

to.matrix(1:3)
to.matrix(1:3,rowMatrix=FALSE)
to.matrix(iris[1:3,1:4])
to.matrix(matrix(1:4,2))

tsieger/tsiMisc documentation built on Oct. 10, 2023, 10:24 p.m.