to.matrix.Rd
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.
to.matrix(x, rowMatrix = TRUE)
x | data to convert to a matrix |
---|---|
rowMatrix | if |
matrix
to.matrix(1:3)#> [,1] [,2] [,3] #> [1,] 1 2 3to.matrix(1:3,rowMatrix=FALSE)#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3to.matrix(iris[1:3,1:4])#> Sepal.Length Sepal.Width Petal.Length Petal.Width #> 1 5.1 3.5 1.4 0.2 #> 2 4.9 3.0 1.4 0.2 #> 3 4.7 3.2 1.3 0.2#> [,1] [,2] #> [1,] 1 3 #> [2,] 2 4