Running examples in 'ber-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: ber
> ### Title: Batch Effects Removal
> ### Aliases: ber
> 
> ### ** Examples
> 
> Y<-matrix(rnorm(6000),nrow=12)
> class<-gl(2,6,labels=c("Control","Treat"))
> class<-data.frame(class)
> batch<-rep(gl(2,3,labels=c("Batch1","Batch2")),2)
> YEadj<-ber(Y,batch,class)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
ber
 --- call from context --- 
ber(Y, batch, class)
 --- call from argument --- 
if (class(Y) != "matrix") {
    stop("'Y' must be of class 'matrix'\n")
}
 --- R stacktrace ---
where 1: ber(Y, batch, class)

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (Y, b, covariates = NULL) 
{
    if (missing(Y)) {
        stop("Argument 'Y' missing, with no default\n")
    }
    if (missing(b)) {
        stop("Argument 'b' missing, with no default\n")
    }
    if (class(Y) != "matrix") {
        stop("'Y' must be of class 'matrix'\n")
    }
    if (class(b) != "factor") {
        stop("'b' must be of class 'factor'\n")
    }
    if (any(is.na(Y))) {
        stop("NA values are not allowed in 'Y'\n")
    }
    if (any(is.na(b))) {
        stop("NA values are not allowed in 'b'\n")
    }
    if (length(b) != nrow(Y)) {
        stop("length(b) is different from nrow(Y)\n")
    }
    if (any(apply(Y, 2, mode) != "numeric")) {
        stop("Array expression columns contain non-numeric values!\n")
    }
    if (!is.null(covariates)) {
        if (class(covariates) != "data.frame") {
            stop("'covariates' must be of class 'data.frame'\n")
        }
        col.cov <- ncol(covariates)
        for (i in 1:col.cov) {
            if (class(covariates[, i]) != "numeric" & class(covariates[, 
                i]) != "factor") {
                stop("column ", i, " of 'covariates' must be of class 'factor' or 'numeric'\n")
            }
        }
        if (any(is.na(covariates))) {
            stop("NA values are not allowed in 'covariates'\n")
        }
    }
    cnames <- colnames(Y)
    rnames <- rownames(Y)
    if (is.null(covariates)) {
        library(MASS)
        n <- dim(Y)[1]
        g <- dim(Y)[2]
        m <- nlevels(b)
        X <- model.matrix(~b - 1)
        Xinv <- ginv(X)
        B <- Xinv %*% Y
        XB_hat <- X %*% B
        adjY <- Y - XB_hat
        res_squared <- adjY^2
        genes_mean <- apply(XB_hat, 2, mean)
        genes_mean_matrix <- matrix(rep(genes_mean, n), byrow = TRUE, 
            nrow = n)
        Bdouble <- Xinv %*% res_squared
        XD_hat <- X %*% Bdouble
        genes_var <- apply(XD_hat, 2, mean)
        genes_var_matrix <- matrix(rep(genes_var, n), byrow = TRUE, 
            nrow = n)
        ScaleFactors <- sqrt(genes_var_matrix/(XD_hat))
        adjYdouble <- ScaleFactors * adjY
        adjYdouble <- ScaleFactors * adjY + genes_mean_matrix
        colnames(adjYdouble) <- cnames
        rownames(adjYdouble) <- rnames
        return(adjYdouble)
    }
    else {
        library(MASS)
        n <- dim(Y)[1]
        g <- dim(Y)[2]
        m1 <- nlevels(b)
        X1 <- model.matrix(~b - 1)
        colnames(covariates) <- paste("col", 1:ncol(covariates), 
            sep = "")
        fmla <- as.formula(paste("~", paste(colnames(covariates), 
            collapse = "+")))
        X2 <- model.matrix(fmla, covariates)
        X2 <- as.matrix(X2[, -1])
        m2 <- dim(X2)[2]
        X <- cbind(X1, X2)
        Xinv <- ginv(X)
        B <- Xinv %*% Y
        B1 <- B[1:m1, ]
        B2 <- B[(m1 + 1):(m1 + m2), ]
        XB_hat <- X %*% B
        adjY <- Y - XB_hat
        res_squared <- adjY^2
        genes_mean <- apply(X1 %*% B1, 2, mean)
        genes_mean_matrix <- matrix(rep(genes_mean, n), byrow = TRUE, 
            nrow = n)
        X1inv <- ginv(X1)
        Bdouble1 <- X1inv %*% res_squared
        X1D1_hat <- X1 %*% Bdouble1
        genes_var <- apply(X1D1_hat, 2, mean)
        genes_var_matrix <- matrix(rep(genes_var, n), byrow = TRUE, 
            nrow = n)
        ScaleFactors <- sqrt(genes_var_matrix/(X1D1_hat))
        adjYdouble <- ScaleFactors * adjY
        adjYdouble <- adjYdouble + genes_mean_matrix + X2 %*% 
            B2
        colnames(adjYdouble) <- cnames
        rownames(adjYdouble) <- rnames
        return(adjYdouble)
    }
}
<bytecode: 0x1ed71e8>
<environment: namespace:ber>
 --- function search by body ---
Function ber in namespace ber has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if (class(Y) != "matrix") { : the condition has length > 1
Calls: ber
Execution halted