Running examples in ‘blockForest-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: blockfor
> ### Title: Random Forest variants for block-structured covariate data
> ### Aliases: blockfor
> 
> ### ** Examples
> 
> # NOTE: There is no association between covariates and response for the
> # simulated data below.
> # Moreover, the input parameters of blockfor() are highly unrealistic
> # (e.g., nsets = 10 is specified much too small).
> # The purpose of the shown examples is merely to illustrate the
> # application of blockfor().
> 
> 
> # Generate data:
> ################
> 
> set.seed(1234)
> 
> # Covariate matrix:
> X <- cbind(matrix(nrow=40, ncol=5, data=rnorm(40*5)), 
+            matrix(nrow=40, ncol=30, data=rnorm(40*30, mean=1, sd=2)),
+            matrix(nrow=40, ncol=100, data=rnorm(40*100, mean=2, sd=3)))
> 
> # Block variable (list):
> blocks <- rep(1:3, times=c(5, 30, 100))
> blocks <- lapply(1:3, function(x) which(blocks==x))
> 
> # Binary outcome:
> ybin <- factor(sample(c(0,1), size=40, replace=TRUE), levels=c(0,1))
> 
> # Survival outcome:
> ysurv <- cbind(rnorm(40), sample(c(0,1), size=40, replace=TRUE))
> 
> # Application to binary outcome:
> ################################
> 
> blockforobj <- blockfor(X, ybin, num.trees = 100, replace = TRUE, blocks=blocks,
+                         nsets = 10, num.trees.pre = 50, splitrule="extratrees", 
+                         block.method = "BlockForest")
> # Tuning parameter estimates (see Hornung & Wright (2019)):
> blockforobj$paramvalues
[1] 0.5601925 0.6284451 1.0000000
> 
> # Application to survival outcome:
> ##################################
> 
> blockforobj <- blockfor(X, ysurv, num.trees = 100, replace = TRUE, blocks=blocks,
+                         nsets = 10, num.trees.pre = 50, splitrule="extratrees", 
+                         block.method = "BlockForest")
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
blockForest
 --- call from context --- 
blockfor(X, ysurv, num.trees = 100, replace = TRUE, blocks = blocks, 
    nsets = 10, num.trees.pre = 50, splitrule = "extratrees", 
    block.method = "BlockForest")
 --- call from argument --- 
if (class(y) == "matrix") {
    if (ncol(y) == 2) {
        y <- Surv(time = y[, 1], event = y[, 2])
        model.data <- data.frame(y, X)
    }
} else model.data <- data.frame(y, X)
 --- R stacktrace ---
where 1: blockfor(X, ysurv, num.trees = 100, replace = TRUE, blocks = blocks, 
    nsets = 10, num.trees.pre = 50, splitrule = "extratrees", 
    block.method = "BlockForest")

 --- value of length: 2 type: logical ---
[1]  TRUE FALSE
 --- function from context --- 
function (X, y, blocks, block.method = "BlockForest", num.trees = 2000, 
    mtry = NULL, nsets = 300, num.trees.pre = 1500, splitrule = "extratrees", 
    always.select.block = 0, ...) 
{
    if (class(y) == "matrix") {
        if (ncol(y) == 2) {
            y <- Surv(time = y[, 1], event = y[, 2])
            model.data <- data.frame(y, X)
        }
    }
    else model.data <- data.frame(y, X)
    if (class(model.data[, 1]) == "factor") {
        treetype <- "Classification"
    }
    else if (class(model.data[, 1]) == "numeric") {
        treetype <- "Regression"
    }
    else if (class(model.data[, 1]) == "Surv") {
        treetype <- "Survival"
    }
    else {
        stop("Unkown response type.")
    }
    if (missing(blocks)) 
        stop("Argument 'blocks' must be provided.")
    if (is.null(mtry)) {
        if (block.method %in% c("SplitWeights", "VarProb")) 
            mtry <- sum(sqrt(sapply(blocks, length)))
        else mtry <- sapply(blocks, function(x) sqrt(length(x)))
    }
    model.data[, -1] <- sapply(model.data[, -1], as.numeric)
    if (always.select.block > 0 & block.method %in% c("SplitWeights", 
        "RandomBlock")) {
        always.split.variables <- colnames(model.data[, -1])[blocks[[always.select.block]]]
    }
    else {
        always.split.variables <- NULL
    }
    if (always.select.block > 0 & block.method %in% c("BlockVarSel", 
        "BlockForest")) {
        mtry[always.select.block] <- length(blocks[[always.select.block]])
    }
    if (treetype == "Survival") {
        model.data <- data.frame(time = model.data[, 1][, 1], 
            status = model.data[, 1][, 2], model.data[, -1])
    }
    if (treetype == "Classification") {
        cvalueoptim <- CvalueOptimizerClassification$new(nsets = as.integer(nsets), 
            num.trees.pre = as.integer(num.trees.pre), mtry = as.integer(mtry), 
            data = model.data, response_levels = levels(model.data[, 
                1]), blocks = blocks, block.method = block.method, 
            splitrule = splitrule, always.select.block = as.integer(always.select.block))
        paramvalues <- cvalueoptim$optimizeCvalues(always.split.variables = always.split.variables, 
            ...)
        if (block.method != "VarProb") 
            forest <- blockForest(dependent.variable.name = "y", 
                data = model.data, num.trees = num.trees, blocks = blocks, 
                block.weights = paramvalues, mtry = mtry, keep.inbag = TRUE, 
                block.method = block.method, splitrule = splitrule, 
                always.split.variables = always.split.variables, 
                ...)
        else {
            pm <- sapply(blocks, length)
            splitweights <- rep(NA, sum(pm))
            for (blocki in seq(along = blocks)) splitweights[blocks[[blocki]]] <- paramvalues[blocki]
            forest <- blockForest(dependent.variable.name = "y", 
                data = model.data, num.trees = num.trees, split.select.weights = splitweights, 
                mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                splitrule = splitrule, ...)
        }
    }
    else if (treetype == "Regression") {
        cvalueoptim <- CvalueOptimizerRegression$new(nsets = as.integer(nsets), 
            num.trees.pre = as.integer(num.trees.pre), mtry = as.integer(mtry), 
            data = model.data, blocks = blocks, block.method = block.method, 
            splitrule = splitrule, always.select.block = as.integer(always.select.block))
        paramvalues <- cvalueoptim$optimizeCvalues(always.split.variables = always.split.variables, 
            ...)
        if (block.method != "VarProb") 
            forest <- blockForest(dependent.variable.name = "y", 
                data = model.data, num.trees = num.trees, blocks = blocks, 
                block.weights = paramvalues, mtry = mtry, keep.inbag = TRUE, 
                block.method = block.method, splitrule = splitrule, 
                always.split.variables = always.split.variables, 
                ...)
        else {
            pm <- sapply(blocks, length)
            splitweights <- rep(NA, sum(pm))
            for (blocki in seq(along = blocks)) splitweights[blocks[[blocki]]] <- paramvalues[blocki]
            forest <- blockForest(dependent.variable.name = "y", 
                data = model.data, num.trees = num.trees, split.select.weights = splitweights, 
                mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                splitrule = splitrule, ...)
        }
    }
    else if (treetype == "Survival") {
        cvalueoptim <- CvalueOptimizerSurvival$new(nsets = as.integer(nsets), 
            num.trees.pre = as.integer(num.trees.pre), mtry = as.integer(mtry), 
            data = model.data, blocks = blocks, block.method = block.method, 
            splitrule = splitrule, always.select.block = as.integer(always.select.block))
        paramvalues <- cvalueoptim$optimizeCvalues(always.split.variables = always.split.variables, 
            ...)
        if (block.method != "VarProb") 
            forest <- blockForest(dependent.variable.name = "time", 
                status.variable.name = "status", data = model.data, 
                num.trees = num.trees, blocks = blocks, block.weights = paramvalues, 
                mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                splitrule = splitrule, always.split.variables = always.split.variables, 
                ...)
        else {
            pm <- sapply(blocks, length)
            splitweights <- rep(NA, sum(pm))
            for (blocki in seq(along = blocks)) splitweights[blocks[[blocki]]] <- paramvalues[blocki]
            forest <- blockForest(dependent.variable.name = "time", 
                status.variable.name = "status", data = model.data, 
                num.trees = num.trees, split.select.weights = splitweights, 
                mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                splitrule = splitrule, ...)
        }
    }
    else {
        stop("Unkown tree type.")
    }
    res <- list(forest = forest, paramvalues = paramvalues, biased_oob_error_donotuse = forest$prediction.error)
    return(res)
}
<bytecode: 0x55adaaf90f38>
<environment: namespace:blockForest>
 --- function search by body ---
Function blockfor in namespace blockForest has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1