R/recol.R

Defines functions recol

recol <-
function(x)
{
  xattr <- attributes(x)
  xattrn <- names(xattr)
  rn <- rownames(x)
  ok <- FALSE
  if(any(id <- grepl("10%", colnames(x)))) {
    ok <- TRUE
    cn <- colnames(x)
    cn <- cn[!id]
    x <- x[,!id]
    if(!is.matrix(x)) {
      x <- matrix(x, nrow = 1L)
      rownames(x) <- rn
      colnames(x) <- cn
    }
  }
  if(any(id <- grepl("90%", colnames(x)))) {
    ok <- TRUE
    cn <- colnames(x)
    cn <- cn[!id]
    x <- x[,!id]
    if(!is.matrix(x)) {
      x <- matrix(x, nrow = 1L)
      rownames(x) <- rn
      colnames(x) <- cn
    }
  }
  if(ok)
    for(i in 1L:length(xattrn))
      if(xattrn[i] != "dim" && xattrn[i] != "dimnames")
        attr(x, xattrn[i]) <- xattr[[i]]

  return(x)
}

Try the R2BayesX package in your browser

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

R2BayesX documentation built on Oct. 20, 2023, 9:11 a.m.