squaretize: Makes a data frame or a matrix square

View source: R/squaretize.R

squaretizeR Documentation

Makes a data frame or a matrix square

Description

Add missing rows or columns based on names and Duplicates rows and columns of a given a data frame.

Usage

squaretize(x, fill = 0, reorder = TRUE)

Arguments

x

an object to be coerced into matrix.

fill

character string used to fill the additional rows and/or columns.

reorder

a logical. Should names must be used to order rows and columns?

Value

A square matrix.

Examples

mat <- matrix(1:12, 3, 4)
mat2 <- squaretize(mat)
matb <- matrix(1:12, 4, 3)
colnames(matb) <- LETTERS[1:3]
mat2b <- squaretize(matb)

letiR/letiRmisc documentation built on Sept. 11, 2022, 12:43 a.m.