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

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)