R/expand_matrix.R

Defines functions expand_matrix

## File Name: expand_matrix.R
## File Version: 0.03

expand_matrix <- function(x)
{
    NR <- nrow(x)
    NC <- ncol(x)
    NY <- max(NR,NC)
    y <- x
    if (NR!=NC){
        y <- matrix(0,nrow=NY,ncol=NY)
        if (NR < NC){
            y[ 1:NR, ] <- x
        }
        if (NR > NC){
            y[, 1:NC ] <- x
        }
    }
    return(y)
}

Try the CDM package in your browser

Any scripts or data that you put into this service are public.

CDM documentation built on Aug. 25, 2022, 5:08 p.m.