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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: modEsti
> ### Title: Get a model-based estimate of mean of a sampled area
> ### Aliases: modEsti
> ### Keywords: misc
> 
> ### ** Examples
> 
> #set up design parameters
> #taken from the example in alterInclProbs()
> #big plane today
> set.seed(747)
> #the number of potential sampling locations
> N <- 50^2
> #number of samples
> n <- 27
> #number of legacy sites
> nLegacy <- 3
> #the grid
> X <- as.matrix( expand.grid( 1:sqrt( N), 1:sqrt(N)) / sqrt(N) - 1/(2*sqrt(N)))
> #the inclusion probabiltiies with gradient according to non-linear function of X[,1]
> p <- 1-exp(-X[,1])
> #standardise to get n samples
> p <- n * p / sum( p)
> #randomly choose legacy sites
> legacySites <- sample( 1:N, nLegacy, prob=p)
> #alter inclusion probabilities for legacy sites
> p2 <- alterInclProbs( legacy.sites=X[legacySites,], potential.sites=X, inclusion.probs=p)
> #get the sample
> samp <- quasiSamp( n=n, dimension=2, potential.sites=X, inclusion.probs=p2)
No study.area defined. Using an interval/rectangle/hyper-rectangle based on the extreme locations in potential.sites
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
MBHdesign
 --- call from context --- 
setDesignParams(dimension, study.area, potential.sites, inclusion.probs)
 --- call from argument --- 
if (!class(potential.sites) %in% c("matrix", "data.frame")) potential.sites <- as.matrix(potential.sites)
 --- R stacktrace ---
where 1: setDesignParams(dimension, study.area, potential.sites, inclusion.probs)
where 2: quasiSamp(n = n, dimension = 2, potential.sites = X, inclusion.probs = p2)

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (dimension, study.area, potential.sites, inclusion.probs) 
{
    if (is.null(study.area)) {
        if (is.null(potential.sites)) {
            message("No study.area defined and no potential.sites given. Using unit interval/square/cube/hyper-cube (as dimension dictates)")
            N <- 100
            potential.sites <- as.matrix(expand.grid(as.data.frame(matrix(rep(1:N, 
                times = dimension), ncol = dimension)))/N - 1/(2 * 
                N))
            study.area <- as.matrix(expand.grid(as.data.frame(matrix(c(rep(0, 
                dimension), rep(1, dimension)), nrow = 2, byrow = TRUE))))
            colnames(potential.sites) <- colnames(study.area) <- paste0("dimension", 
                1:dimension)
        }
        else {
            message("No study.area defined. Using an interval/rectangle/hyper-rectangle based on the extreme locations in potential.sites")
            if (!class(potential.sites) %in% c("matrix", "data.frame")) 
                potential.sites <- as.matrix(potential.sites)
            if (is.null(colnames(potential.sites))) 
                colnames(potential.sites) <- paste0("dimension", 
                  1:dimension)
            study.area <- as.matrix(expand.grid(as.data.frame(apply(potential.sites, 
                -1, range))))
            colnames(study.area) <- colnames(potential.sites)
        }
        if (dimension == 2) 
            study.area <- study.area[c(1, 3, 4, 2), ]
    }
    if (!class(study.area) %in% c("matrix", "data.frame")) 
        study.area <- as.matrix(study.area)
    if (is.null(colnames(study.area))) 
        colnames(study.area) <- paste0("dimension", 1:dimension)
    if (is.null(potential.sites)) {
        message("Sampling from a 100x100 grid (max -- will be cropped) within the study area (well hyper-rectangle if dimension>2)")
        N <- 100
        potential.sites <- as.matrix(expand.grid(as.data.frame(matrix(rep(1:N, 
            times = dimension), ncol = dimension)))/N - 1/(2 * 
            N))
        colnames(potential.sites) <- paste0("dimension", 1:dimension)
        myRange <- apply(study.area, -1, range)
        for (ii in 1:dimension) {
            potential.sites[, ii] <- myRange[1, ii] + (myRange[2, 
                ii] - myRange[1, ii]) * potential.sites[, ii]
        }
        if (dimension == 2) {
            tmp <- mgcv::in.out(study.area, potential.sites)
            potential.sites <- potential.sites[tmp, ]
        }
        if (dimension > 2) 
            message("Sampling grid not checked for interior of study area (please do so yourself)")
    }
    N <- nrow(potential.sites)
    if (dimension != ncol(potential.sites)) 
        stop("The dimension supplied does not match the dimension that the potential.sites implies")
    if (is.null(inclusion.probs)) {
        message("No inclusion.probs supplied, assuming uniform")
        inclusion.probs <- rep(1/N, N)
    }
    inclusion.probs1 <- inclusion.probs/max(inclusion.probs, 
        na.rm = TRUE)
    ret <- list(dimension = dimension, study.area = study.area, 
        potential.sites = potential.sites, inclusion.probs = inclusion.probs, 
        inclusion.probs1 = inclusion.probs1, N = N)
    return(ret)
}
<bytecode: 0x55ca09a1f3a8>
<environment: namespace:MBHdesign>
 --- function search by body ---
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1