R/fold.R

Defines functions fold

Documented in fold

fold <-
function(X,lower=TRUE) {
  nr <- nrow(X)
  nc <- ncol(X)
  if(nr!=nc) {
    stop("X is not square.")
  } else {
    lo <- X[lower.tri(X, diag = FALSE)]
    Xt <- t(X)
    up <- Xt[lower.tri(Xt, diag = FALSE)]
    X[lower.tri(X, diag = FALSE)] <- lo+up
    X[upper.tri(X, diag = FALSE)] <- 0
  }
  if(!lower) X <- t(X) 
  return(X)
}

Try the HardyWeinberg package in your browser

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

HardyWeinberg documentation built on May 7, 2022, 5:05 p.m.