square: Create a Square Matrix

Description Usage Arguments Value Examples

View source: R/square.R

Description

This simple convenience function creates a square matrix from elements passed via .... It will throw an error if the number of elements passed to ... is not a perfect square.

Usage

1
square(..., byrow = FALSE)

Arguments

...

Elements of the matrix as vectors whose total number of elements is a perfect square. Elements of differing types are automatically coerced using c.

byrow

Argument passed along to matrix. Defaults to FALSE.

Value

An n x n matrix, where n is equal to the length of ... after concatenation.

Examples

1
2
3
square(1, 5, 6, 7, 8, 9, 1, 2, -1)
# Also works with vectors of differing length
square(-10:0, 5, 2, 3, 0, 9)

ryan-heslin/matador documentation built on Dec. 22, 2021, 8:17 p.m.