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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: BIC based forward selection
> ### Title: Variable selection in regression models with forward selection
> ###   using BIC
> ### Aliases: bic.fsreg
> ### Keywords: Markov Blanket Variable Selection
> 
> ### ** Examples
> 
> set.seed(123)
> dataset <- matrix( runif(500 * 20, 1, 100), ncol = 20 )
> target <- 3 * dataset[, 10] + 2 * dataset[, 15] + 3 * dataset[, 20] + rnorm(500, 0, 5)
> 
> a1 <- bic.fsreg(target, dataset, tol = 4, ncores = 1, test = "testIndReg" ) 
> a3 <- MMPC(target, dataset, ncores = 1)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
MXM
 --- call from context --- 
MMPC(target, dataset, ncores = 1)
 --- call from argument --- 
if (class(dataset) == "matrix") {
    test <- "testIndFisher"
} else if (class(dataset) == "data.frame") {
    if (length(Rfast::which.is(dataset)) > 0) {
        test <- "testIndReg"
    }
    else test <- "testIndFisher"
}
 --- R stacktrace ---
where 1: MMPC(target, dataset, ncores = 1)

 --- value of length: 2 type: logical ---
[1]  TRUE FALSE
 --- function from context --- 
function (target, dataset, max_k = 3, threshold = 0.05, test = NULL, 
    ini = NULL, wei = NULL, user_test = NULL, hash = FALSE, hashObject = NULL, 
    ncores = 1, backward = FALSE) 
{
    runtime <- proc.time()
    stat_hash <- NULL
    pvalue_hash <- NULL
    if (hash) {
        if (is.null(hashObject)) {
            stat_hash <- Rfast::Hash()
            pvalue_hash <- Rfast::Hash()
        }
        else if (class(hashObject) == "list") {
            stat_hash <- hashObject$stat_hash
            pvalue_hash <- hashObject$pvalue_hash
        }
        else stop("hashObject must be a list of two hash objects (stat_hash, pvalue_hash)")
    }
    if (!is.null(dataset)) {
        if (sum(class(target) == "matrix") == 1) {
            if (sum(class(target) == "Surv") == 1) 
                stop("Invalid dataset class. For survival analysis provide a dataframe-class dataset")
        }
    }
    if (is.null(dataset) || is.null(target)) {
        stop("invalid dataset or target (class feature) arguments.")
    }
    else target <- target
    if (any(is.na(dataset))) {
        warning("The dataset contains missing values (NA) and they were replaced automatically by the variable (column) median (for numeric) or by the most frequent level (mode) if the variable is factor")
        if (is.matrix(dataset)) {
            dataset <- apply(dataset, 2, function(x) {
                x[which(is.na(x))] = median(x, na.rm = TRUE)
                return(x)
            })
        }
        else {
            poia <- unique(which(is.na(dataset), arr.ind = TRUE)[, 
                2])
            for (i in poia) {
                xi <- dataset[, i]
                if (is.numeric(xi)) {
                  xi[which(is.na(xi))] <- median(xi, na.rm = TRUE)
                }
                else if (is.factor(xi)) {
                  xi[which(is.na(xi))] <- levels(xi)[which.max(as.vector(table(xi)))]
                }
                dataset[, i] <- xi
            }
        }
    }
    targetID <- -1
    if (is.character(target) & length(target) == 1) {
        findingTarget <- target == colnames(dataset)
        if (!sum(findingTarget) == 1) {
            warning("Target name not in colnames or it appears multiple times")
            return(NULL)
        }
        targetID <- which(findingTarget)
        target <- dataset[, targetID]
    }
    if (is.numeric(target) & length(target) == 1) {
        if (targetID > dim(dataset)[2]) {
            warning("Target index larger than the number of variables")
            return(NULL)
        }
        targetID <- target
        target <- dataset[, targetID]
    }
    if (sum(class(target) == "matrix") == 1) {
        if (ncol(target) >= 2 & class(target) != "Surv") {
            if ((is.null(test) || test == "auto") & (is.null(user_test))) {
                test <- "testIndMVreg"
            }
        }
    }
    la <- length(unique(as.numeric(target)))
    if (typeof(user_test) == "closure") {
        test <- user_test
    }
    else {
        if (is.null(test) || test == "auto") {
            if (la == 2) 
                target <- as.factor(target)
            if (sum(class(target) == "matrix") == 1) 
                test = "testIndMVreg"
            if ("factor" %in% class(target)) {
                if (is.ordered(target) & length(unique(target)) > 
                  2) {
                  test <- "testIndOrdinal"
                }
                else if (!is.ordered(target) & length(unique(target)) > 
                  2) {
                  test <- "testIndMultinom"
                }
                else test <- "testIndLogistic"
            }
            else if ((is.numeric(target) || is.integer(target)) & 
                survival::is.Surv(target) == FALSE) {
                if (sum(floor(target) - target) == 0 & la > 2) {
                  test <- "testIndQPois"
                }
                else {
                  if (class(dataset) == "matrix") {
                    test <- "testIndFisher"
                  }
                  else if (class(dataset) == "data.frame") {
                    if (length(Rfast::which.is(dataset)) > 0) {
                      test <- "testIndReg"
                    }
                    else test <- "testIndFisher"
                  }
                }
            }
            else if (survival::is.Surv(target)) {
                test <- "censIndCR"
            }
            else stop("Target must be a factor, vector, matrix with at least 2 columns column or a Surv object")
        }
        av_tests <- c("testIndFisher", "testIndSpearman", "testIndReg", 
            "testIndRQ", "testIndBeta", "censIndCR", "censIndWR", 
            "censIndER", "censIndLLR", "testIndClogit", "testIndLogistic", 
            "testIndPois", "testIndNB", "testIndBinom", "gSquare", 
            "auto", "testIndZIP", "testIndMVreg", "testIndIGreg", 
            "testIndGamma", "testIndNormLog", "testIndTobit", 
            "testIndQPois", "testdIndQBinom", "testIndMMReg", 
            "testIndMMFisher", "testIndMultinom", "testIndOrdinal", 
            "testIndSPML", NULL)
        ci_test <- test
        if (length(test) == 1) {
            test <- match.arg(test, av_tests, TRUE)
            if (test == "testIndFisher") {
                test <- testIndFisher
            }
            else if (test == "testIndMMFisher") {
                test <- testIndMMFisher
            }
            else if (test == "testIndMMReg") {
                test <- testIndMMReg
            }
            else if (test == "testIndSpearman") {
                target <- rank(target)
                dataset <- Rfast::colRanks(dataset)
                test <- testIndSpearman
            }
            else if (test == "testIndReg") {
                test <- testIndReg
            }
            else if (test == "testIndMVreg") {
                if (min(target) > 0 & sd(Rfast::rowsums(target)) == 
                  0) 
                  target = log(target[, -1]/target[, 1])
                test <- testIndMVreg
            }
            else if (test == "testIndBeta") {
                test <- testIndBeta
            }
            else if (test == "testIndRQ") {
                test <- testIndRQ
            }
            else if (test == "testIndIGreg") {
                test <- testIndIGreg
            }
            else if (test == "testIndPois") {
                test <- testIndPois
            }
            else if (test == "testIndNB") {
                test <- testIndNB
            }
            else if (test == "testIndGamma") {
                test <- testIndGamma
            }
            else if (test == "testIndNormLog") {
                test <- testIndNormLog
            }
            else if (test == "testIndZIP") {
                test <- testIndZIP
            }
            else if (test == "testIndTobit") {
                test <- testIndTobit
            }
            else if (test == "censIndCR") {
                test <- censIndCR
            }
            else if (test == "censIndWR") {
                test <- censIndWR
            }
            else if (test == "censIndER") {
                test <- censIndER
            }
            else if (test == "censIndLLR") {
                test <- censIndLLR
            }
            else if (test == "testIndClogit") {
                test <- testIndClogit
            }
            else if (test == "testIndBinom") {
                test <- testIndBinom
            }
            else if (test == "testIndLogistic") {
                test <- testIndLogistic
            }
            else if (test == "testIndMultinom") {
                test <- testIndMultinom
            }
            else if (test == "testIndOrdinal") {
                test <- testIndOrdinal
            }
            else if (test == "testIndQBinom") {
                test <- testIndQBinom
            }
            else if (test == "testIndQPois") {
                test <- testIndQPois
            }
            else if (test == "gSquare") {
                test <- gSquare
            }
            else if (test == "testIndSPML") {
                test <- testIndSPML
                if (!is.matrix(target)) 
                  target <- cbind(cos(target), sin(target))
            }
        }
        else {
            stop("invalid test option")
        }
    }
    max_k <- floor(max_k)
    varsize <- ncol(dataset)
    if ((typeof(max_k) != "double") || max_k < 1) 
        stop("invalid max_k option")
    if (max_k > varsize) 
        max_k = varsize
    if ((typeof(threshold) != "double") || threshold < 0 || threshold >= 
        1) 
        stop("invalid threshold option")
    if (!is.null(user_test)) 
        ci_test <- "user_test"
    if (identical(ci_test, "testIndFisher")) {
        oop <- options(warn = -1)
        on.exit(options(oop))
        if (!is.matrix(dataset)) 
            dataset <- as.matrix(dataset)
        if (!is.null(hashObject) & length(hashObject) == 0) 
            hashObject <- NULL
        if (targetID != -1) {
            a <- as.vector(cor(target, dataset))
            dof <- dim(dataset)[1] - 3
            wa <- 0.5 * log((1 + a)/(1 - a)) * sqrt(dof)
            id <- which(is.na(a))
            if (length(id) > 0) 
                wa[id] <- 0
            wa[targetID] <- 0
            ini <- list()
            ini$stat <- wa
            ini$pvalue <- log(2) + pt(abs(wa), dof, lower.tail = FALSE, 
                log.p = TRUE)
        }
        results <- Rfast2::mmpc(target, dataset, max_k = max_k, 
            alpha = threshold, method = "pearson", ini = ini, 
            hash = hash, hashobject = hashObject)
        results$selectedVarsOrder <- results$selected
        results$selectedVars <- sort(results$selected)
        results$selected <- NULL
        lista <- as.list.environment(results$hashobject$pvalue_hash)
        results$hashObject <- list()
        if (length(lista) > 0) {
            results$hashObject$stat_hash <- results$hashobject$stat_hash
            results$hashobject$stat_hash <- NULL
            results$hashObject$pvalue_hash <- results$hashobject$pvalue_hash
            results$hashobject$pvalue_hash <- NULL
            results$hashobject <- NULL
        }
        else {
            results$hashobject <- NULL
            results$hashObject$stat_hash <- NULL
            results$hashObject$pvalue_hash <- NULL
        }
        results$threshold <- results$alpha
        results$alpha <- NULL
    }
    else {
        results <- InternalMMPC(target, dataset, max_k, log(threshold), 
            test, ini, wei, user_test, hash, varsize, stat_hash, 
            pvalue_hash, targetID, ncores = ncores)
    }
    varsToIterate <- results$selectedVarsOrder
    if (backward & length(varsToIterate) > 0) {
        varsOrder <- results$selectedVarsOrder
        bc <- MXM::mmpcbackphase(target, dataset[, varsToIterate, 
            drop = FALSE], test = test, wei = wei, max_k = max_k, 
            threshold = threshold)
        met <- bc$met
        results$selectedVars <- varsOrder[met]
        results$selectedVarsOrder <- varsOrder[met]
        results$pvalues[varsToIterate] <- bc$pvalues
        results$n.tests <- results$n.tests + bc$counter
    }
    runtime <- proc.time() - runtime
    MMPCoutput <- new("MMPCoutput", selectedVars = results$selectedVars, 
        selectedVarsOrder = results$selectedVarsOrder, hashObject = results$hashObject, 
        pvalues = results$pvalues, stats = results$stats, univ = results$univ, 
        max_k = results$max_k, threshold = results$threshold, 
        n.tests = results$n.tests, runtime = runtime, test = ci_test)
    return(MMPCoutput)
}
<bytecode: 0xa7fb950>
<environment: namespace:MXM>
 --- function search by body ---
Function MMPC in namespace MXM has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1