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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: DiveMaster
> ### Title: DiveMaster
> ### Aliases: DiveMaster print.DiveMaster summary.DiveMaster
> ###   print.summary.DiveMaster
> ### Keywords: diversity
> 
> ### ** Examples
> 
> require(DivE)
> data(Bact1)
> data(ModelSet)
> data(ParamSeeds)
> data(ParamRanges)
> 
> testmodels <- list()
> testmeta <- list()
> paramranges <- list()
> 
> # Choose a single model 
> testmodels <- c(testmodels, ModelSet[1])
> #testmeta[[1]] <- (ParamSeeds[[1]]) # Commented out for sake of brevity)
> testmeta[[1]] <- matrix(c(0.9451638, 0.007428265, 0.9938149, 1.0147441, 0.009543598, 0.9870419),
+                         nrow=2, byrow=TRUE, dimnames=list(c(), c("a1", "a2", "a3"))) # Example seeds
> paramranges[[1]] <- ParamRanges[[1]]
> 
> 
> # Create DivSubsamples object (NB: For quick illustration only -- not default parameters)
> dss_1 <- DivSubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=40, NResamples=5)
> dss_2 <- DivSubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=65, NResamples=5)
> dss <- list(dss_2, dss_1)
> 
> # Implement the function (NB: For quick illustration only -- not default parameters)
> out <- DiveMaster(models=testmodels, init.params=testmeta, param.ranges=paramranges,
+                   main.samp=Bact1, subsizes=c(65, 40), NResamples=5, fitloops=1,
+                   dssamp=dss, numit=2, varleft=10)
Loading predefined subsamples 
Fitting model 1 of 1 (Est. time remaining: tbd mins) 
Fitting loop 1 
Performing fitting routine for sample  1 
Choosing optimal initial parameters for global fit 
Performing global fit 
Performing local fit 
Performing fitting routine for sample  2 
Choosing optimal initial parameters for global fit 
Performing global fit 
Performing local fit 
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
DivE
 --- call from context --- 
FitAllSubs(SS, model.list, init.param, param.range, dSS, numit, 
    varleft, tot.pop, v1, minplaus)
 --- call from argument --- 
if ((class(sim.local.mat.tmp) != "try-error") & (class(sim.global.mat.tmp) != 
    "try-error")) {
    sim.local.mat <- sim.local.mat.tmp
    sim.global.mat <- sim.global.mat.tmp
}
 --- R stacktrace ---
where 1: FitAllSubs(SS, model.list, init.param, param.range, dSS, numit, 
    varleft, tot.pop, v1, minplaus)
where 2: FitSingleMod(model.list = models[i], init.param = init.params[[i]], 
    param.range = param.ranges[[i]], main.samp, data.default = FALSE, 
    tot.pop = tot.pop, numit = numit, varleft = varleft, subsizes = mas.SS, 
    dssamps = mas.dss, nrf = nrf, minrarefac = minrarefac, NResamples = NResamples, 
    minplaus = minplaus, fitloops = fitloops)
where 3: MultipleScoring(models, init.params, param.ranges, main.samp, 
    tot.pop, numit, varleft, subsizes, dssamps, nrf, minrarefac, 
    NResamples, minplaus, precision.lv, plaus.pen, crit.wts, 
    fitloops, numpred)
where 4: DiveMaster(models = testmodels, init.params = testmeta, param.ranges = paramranges, 
    main.samp = Bact1, subsizes = c(65, 40), NResamples = 5, 
    fitloops = 1, dssamp = dss, numit = 2, varleft = 10)

 --- value of length: 2 type: logical ---
[1] TRUE TRUE
 --- function from context --- 
function (SS, model.list, init.param, param.range, dSS, numit, 
    varleft, tot.pop, v1, minsampsize) 
{
    model <- model.list[[1]]
    model.name <- names(model.list)
    lower.bd <- param.range[1, ]
    upper.bd <- param.range[2, ]
    param.mat <- matrix(nrow = length(SS), ncol = ncol(init.param))
    rownames(param.mat) <- as.character(SS)
    colnames(param.mat) <- names(init.param[1, ])
    ssr.mat <- matrix(nrow = length(SS), ncol = 1)
    rownames(ssr.mat) <- as.character(SS)
    colnames(ssr.mat) <- c("Sum_of_squares")
    ms.mat <- matrix(nrow = length(SS), ncol = 1)
    rownames(ms.mat) <- as.character(SS)
    colnames(ms.mat) <- c("Mean_squared_residual")
    discrep.mat <- matrix(nrow = length(SS), ncol = 1)
    rownames(discrep.mat) <- as.character(SS)
    colnames(discrep.mat) <- c("Mean_absolute_error")
    local.mat <- matrix(nrow = length(SS), ncol = 1)
    rownames(local.mat) <- as.character(SS)
    colnames(local.mat) <- c("Predicted_local_diversity")
    global.mat <- matrix(nrow = length(SS), ncol = 1)
    rownames(global.mat) <- as.character(SS)
    colnames(global.mat) <- c("Predicted_global_diversity")
    AccuracyToObserved.mat <- matrix(nrow = length(SS), ncol = 1)
    rownames(AccuracyToObserved.mat) <- as.character(SS)
    colnames(AccuracyToObserved.mat) <- c("Accuracy_to_observed_dataset_diversity")
    sim.local.mat <- matrix(rep(0, length(SS) * length(SS)), 
        nrow = length(SS), ncol = length(SS))
    rownames(sim.local.mat) <- as.character(SS)
    colnames(sim.local.mat) <- as.character(SS)
    sim.global.mat <- matrix(rep(0, length(SS) * length(SS)), 
        nrow = length(SS), ncol = length(SS))
    rownames(sim.global.mat) <- as.character(SS)
    colnames(sim.global.mat) <- as.character(SS)
    msr.curve.mat <- matrix(nrow = 2, ncol = 1)
    rownames(msr.curve.mat) <- c("local", "global")
    colnames(msr.curve.mat) <- c("MSR_between_subsample_curves")
    sim.local.ref <- matrix(nrow = length(SS) - 1, ncol = 1)
    rownames(sim.local.ref) <- as.character(SS[2:length(SS)])
    colnames(sim.local.ref) <- c("Distance_from_local_reference_curve")
    sim.global.ref <- matrix(nrow = length(SS) - 1, ncol = 1)
    rownames(sim.global.ref) <- as.character(SS[2:length(SS)])
    colnames(sim.global.ref) <- c("Distance_from_global_reference_curve")
    monotonic.local.mat <- matrix(nrow = length(SS), ncol = 1)
    monotonic.global.mat <- matrix(nrow = length(SS), ncol = 1)
    slowing.local.mat <- matrix(nrow = length(SS), ncol = 1)
    slowing.global.mat <- matrix(nrow = length(SS), ncol = 1)
    plausibility.mat <- matrix(nrow = length(SS), ncol = 3)
    rownames(monotonic.local.mat) <- as.character(SS)
    rownames(monotonic.global.mat) <- as.character(SS)
    rownames(slowing.local.mat) <- as.character(SS)
    rownames(slowing.global.mat) <- as.character(SS)
    rownames(plausibility.mat) <- as.character(SS)
    colnames(monotonic.local.mat) <- c("Is monotonic (local)")
    colnames(monotonic.global.mat) <- c("Is monotonic (global)")
    colnames(slowing.local.mat) <- c("Has_decreasing_2nd_derivative (local)")
    colnames(slowing.global.mat) <- c("Has_decreasing_2nd_derivative (global)")
    colnames(plausibility.mat) <- c("Is plausible", "Monotonically increasing", 
        "Slowing")
    for (b in 1:length(SS)) {
        cat("Performing fitting routine for sample ", b, "\n")
        if (b > 1) {
            rbind(init.param, fit$par)
        }
        fit <- try(FitSample(model, init.param, lower.bd, upper.bd, 
            dSS[[b]], numit, varleft), silent = TRUE)
        if (class(fit) == "try-error") {
            next
        }
        param.mat[b, ] <- fit$par
        ssr.mat[b, ] <- fit$ssr
        ms.mat[b, ] <- fit$ms
        discrep.mat[b, ] <- ModelCostAbs(model, fit$par, dSS[[b]])
        local.mat[b, ] <- model(length(v1), fit$par)
        global.mat[b, ] <- model(tot.pop, fit$par)
        AccuracyToObserved.mat[b, ] <- (model(length(v1), fit$par) - 
            length(unique(v1)))/length(unique(v1))
        monotonic.local.mat[b, ] <- IsMonotonic(model, fit$par, 
            min.samp = minsampsize, max.samp = length(v1), tot.length = length(v1) - 
                minsampsize + 1)
        monotonic.global.mat[b, ] <- IsMonotonic(model, fit$par, 
            min.samp = minsampsize, max.samp = tot.pop, tot.length = min(tot.pop - 
                minsampsize + 1, 2000))
        slowing.local.mat[b, ] <- IsSlowing(model, fit$par, min.samp = minsampsize, 
            max.samp = length(v1), tot.length = length(v1) - 
                minsampsize + 1)
        slowing.global.mat[b, ] <- IsSlowing(model, fit$par, 
            min.samp = minsampsize, max.samp = tot.pop, tot.length = min(tot.pop - 
                minsampsize + 1, 2000))
        plausibility.mat[b, 2] <- ((monotonic.local.mat[b, ]) * 
            (monotonic.global.mat[b, ])) == 1
        plausibility.mat[b, 3] <- (slowing.global.mat[b, ]) == 
            1
        plausibility.mat[b, 1] <- (plausibility.mat[b, 2] * plausibility.mat[b, 
            3]) == 1
    }
    norm.fac.local <- try(RefArea(model, param.mat[1, ], minsampsize, 
        length(v1)), silent = TRUE)
    norm.fac.global <- try(RefArea(model, param.mat[1, ], minsampsize, 
        tot.pop), silent = TRUE)
    for (b in 1:length(SS)) {
        for (c in (b:length(SS))) {
            if (b == c) {
                sim.local.mat[b, c] <- 0
                sim.global.mat[b, c] <- 0
            }
            else {
                local.tmp.mat <- try(Simm(model, param.mat[b, 
                  ], param.mat[c, ], lowerlimit = minsampsize, 
                  upperlimit = length(v1), tot.length = length(v1) - 
                    minsampsize + 1), silent = TRUE)
                global.tmp.mat <- try(Simm(model, param.mat[b, 
                  ], param.mat[c, ], lowerlimit = minsampsize, 
                  upperlimit = tot.pop, tot.length = tot.pop - 
                    minsampsize + 1), silent = TRUE)
                if ((class(local.tmp.mat) != "try-error") & (class(global.tmp.mat) != 
                  "try-error")) {
                  sim.local.mat[b, c] <- local.tmp.mat
                  sim.global.mat[b, c] <- global.tmp.mat
                }
            }
        }
    }
    sim.local.mat <- sim.local.mat + t(sim.local.mat)
    sim.global.mat <- sim.global.mat + t(sim.global.mat)
    sim.local.mat.tmp <- try(sim.local.mat/norm.fac.local, silent = TRUE)
    sim.global.mat.tmp <- try(sim.global.mat/norm.fac.global, 
        silent = TRUE)
    if ((class(sim.local.mat.tmp) != "try-error") & (class(sim.global.mat.tmp) != 
        "try-error")) {
        sim.local.mat <- sim.local.mat.tmp
        sim.global.mat <- sim.global.mat.tmp
    }
    for (b in 2:length(SS)) {
        sim.local.ref[b - 1, ] <- sim.local.mat[b, 1]
        sim.global.ref[b - 1, ] <- sim.global.mat[b, 1]
    }
    msr.curve.mat[1, 1] <- MSRcurves(sim.local.mat)
    msr.curve.mat[2, 1] <- MSRcurves(sim.global.mat)
    list(param = param.mat, ssr = ssr.mat, ms = ms.mat, discrep = discrep.mat, 
        local = local.mat, global = global.mat, AccuracyToObserved = AccuracyToObserved.mat, 
        subsamplesizes = SS, datapoints = dSS, modelname = names(model.list), 
        numparam = ncol(param.mat), sampvar = msr.curve.mat, 
        mono.local = monotonic.local.mat, mono.global = monotonic.global.mat, 
        slowing.local = slowing.local.mat, slowing.global = slowing.global.mat, 
        plausibility = plausibility.mat, dist.local = sim.local.mat, 
        dist.global = sim.global.mat, local.ref.dist = sim.local.ref, 
        global.ref.dist = sim.global.ref, popsize = tot.pop, 
        themodel = model)
}
<bytecode: 0x351b860>
<environment: namespace:DivE>
 --- function search by body ---
Function FitAllSubs in namespace DivE has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if ((class(sim.local.mat.tmp) != "try-error") & (class(sim.global.mat.tmp) !=  : 
  the condition has length > 1
Calls: DiveMaster -> MultipleScoring -> FitSingleMod -> FitAllSubs
Execution halted