R/rcm.R

Defines functions rcm

Documented in rcm

rcm <-
function(nrow=NULL, ncol=NULL) {


if (!is.null(nrow) & !is.null(ncol)) {
  stop("Either nrow or ncol must be specified")
}
if (is.null(nrow)) {
  if (is.null(ncol)) {
    stop("Either nrow or ncol must be specified")
  } else {
    nrow <- ncol
  }
}

if (!is.numeric(nrow) | length(nrow)!=1) {
  stop("nrow or ncol must be a single numeric value")
}

mat <- rmvnorm(nrow,rep(0,nrow),diag(nrow))
for (i in 1:nrow) {
  mat[i,] <- mat[i,]/as.numeric(sqrt(t(mat[i,])%*%mat[i,]))
}
return(mat%*%t(mat))


}

Try the SimComp package in your browser

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

SimComp documentation built on Aug. 26, 2019, 5:03 p.m.