R/odiag.R

Defines functions `odiag`

`odiag` <-
function(A,at=0){
    if (is.matrix(A)) {
      y <- A[row(A) == col(A)-at]
      return(y)
    }
    else{
      len <- length(A)
      B <- matrix(0,nrow=len+abs(at), ncol=len+abs(at))
      B[row(B)==col(B)-at] <- A
      return(B)
    }
  }

Try the demogR package in your browser

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

demogR documentation built on May 1, 2019, 10:56 p.m.