Takes a vector and converts it into a square matrix

Share:

Description

sq_matrix takes a vector and converts it into a square matrix.

Usage

1
  sq_matrix(data, byrow = TRUE)

Arguments

data

Object (probably vector) to be turned into square matrix

byrow

Whether to fill in the matrix by row or by column

Value

A matrix with the same number of columns and rows

See Also

link{matrix}

Examples

1
2
3
sq_matrix(1:4)
sq_matrix(1:4, FALSE)
matrix(1:4, nrow=2)