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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: crossCorrelation
> ### Title: Spatial cross correlation
> ### Aliases: crossCorrelation
> 
> ### ** Examples
> 
>   library(sp)
>   library(spdep)
Loading required package: spData
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source')`

Attaching package: ‘spData’

The following object is masked from ‘package:spatialEco’:

    elev

Loading required package: sf
Linking to GEOS 3.8.0, GDAL 2.4.3, PROJ 6.2.1
>    
>   data(meuse)
>     coordinates(meuse) <- ~x+y  
>  
>   #### Providing a neighbor contiguity spatial weights matrix
>   all.linked <- max(unlist(nbdists(knn2nb(knearneigh(coordinates(meuse))), 
+                     coordinates(meuse))))  
>   nb <- nb2listw(dnearneigh(meuse, 0, all.linked), style = "B", zero.policy = TRUE)  
>     Wij <- as.matrix( as(nb, "symmetricMatrix") ) 	
>    ( I <- crossCorrelation(meuse$zinc, meuse$copper, w = Wij, 
+                            clust=TRUE, k=99) )
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
spatialEco
 --- call from context --- 
crossCorrelation(meuse$zinc, meuse$copper, w = Wij, clust = TRUE, 
    k = 99)
 --- call from argument --- 
if (!class(w) == "matrix") stop("Spatial weights must be in matrix form")
 --- R stacktrace ---
where 1: crossCorrelation(meuse$zinc, meuse$copper, w = Wij, clust = TRUE, 
    k = 99)

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (x, y = NULL, coords = NULL, w = NULL, type = c("LSCI", 
    "GSCI"), k = 1000, dist.function = "inv.power", scale.xy = TRUE, 
    scale.partial = FALSE, scale.matrix = FALSE, alpha = 0.05, 
    clust = FALSE, return.sims = FALSE) 
{
    if (missing(x)) 
        stop("x must be specified")
    if (is.null(y)) 
        y = x
    if (length(y) != length(x)) 
        stop("[X,Y] are not equal")
    if (length(which(is.na(x))) != 0 | length(which(is.na(y))) != 
        0) 
        stop("NA's not permitted in [X,Y]")
    if (k == 0) 
        warning("Permutation is not being run, estimated p will be based on observed")
    if (scale.xy == FALSE) 
        warning("It is assumed that x,v vectors are already scaled")
    type = type[1]
    n <- length(x)
    if (is.null(w)) {
        if (is.null(coords)) 
            stop("If no Wij matrix is provided, a coordinates matrix is required")
        w <- sp::spDists(coords)
        if (dist.function == "inv.power") {
            message("Calculating spatial weights matrix using inverse power function")
            w <- 1/w
            diag(w) <- 0
            w <- w/sum(w)
        }
        else if (dist.function == "neg.exponent") {
            message("Calculating spatial weights matrix using negative exponent")
            diag(w) <- NA
            mu <- mean(w, na.rm = TRUE)
            for (i in 1:nrow(w)) {
                for (j in 1:nrow(w)) {
                  w[i, j] <- round(exp((-2 * w[i, j])/mu), 6)
                }
            }
            diag(w) <- 0
        }
        else {
            stop("Not a valid matrix option")
        }
    }
    else {
        if (!class(w) == "matrix") 
            stop("Spatial weights must be in matrix form")
        if (ncol(w) != length(x) | nrow(w) != length(x)) 
            stop("Spatial weights matrix must be symmetrical and match x")
        w[which(is.na(w))] <- 0
        if (scale.matrix) {
            if (sum(w) > 0) {
                w <- as.matrix(w/sum(w))
            }
        }
    }
    if (scale.xy) {
        x <- (x - mean(x))/(stats::sd(x) * sqrt((length(x) - 
            1)/length(x)))
        y <- (y - mean(y))/(stats::sd(y) * sqrt((length(y) - 
            1)/length(y)))
    }
    SCI <- function(x, y, W, type.cc, scale.cc) {
        if (type.cc == "LSCI") {
            lsci.xy = as.numeric(x * y %*% W)
            lsci.yx = as.numeric(y * x %*% W)
            if (scale.cc) {
                lsci.xy <- (lsci.xy - min(lsci.xy)) * (1 - -1)/(max(lsci.xy) - 
                  min(lsci.xy)) + -1
                lsci.yx <- (lsci.yx - min(lsci.yx)) * (1 - -1)/(max(lsci.yx) - 
                  min(lsci.yx)) + -1
            }
            sci = data.frame(lsci.xy = lsci.xy, lsci.yx = lsci.yx)
        }
        if (type.cc == "GSCI") {
            gsci.xy = as.numeric(x * W %*% y)/(length(x) - 1)
            gsci.yx = as.numeric(y * W %*% x)/(length(x) - 1)
            if (scale.cc) {
                gsci.xy <- (gsci.xy - min(gsci.xy)) * (1 - -1)/(max(gsci.xy) - 
                  min(gsci.xy)) + -1
                gsci.yx <- (gsci.yx - min(gsci.yx)) * (1 - -1)/(max(gsci.yx) - 
                  min(gsci.yx)) + -1
            }
            sci = data.frame(gsci.xy = gsci.xy, gsci.yx = gsci.yx)
        }
        return(sci)
    }
    global.i <- as.numeric(x %*% w %*% y)/(length(x) - 1)
    if (type == "LSCI") {
        tstat = "lsci.xy"
    }
    else {
        tstat = "gsci.xy"
    }
    sci.results <- SCI(x = x, y = y, W = w, type.cc = type, scale.cc = scale.partial)
    if (clust) {
        lisa.clust <- as.character(interaction(x > 0, w %*% y > 
            0))
        lisa.clust <- gsub("TRUE", "High", lisa.clust)
        lisa.clust <- gsub("FALSE", "Low", lisa.clust)
    }
    probs <- c(alpha/2, 1 - alpha/2)
    if (k > 0) {
        cat("\n ( Computing Permutation Distribution )\n")
        y.sim <- matrix(y[sample(1:n, size = n * k, replace = TRUE)], 
            nrow = n, ncol = k)
        isim <- apply(y.sim, MARGIN = 2, function(j) t(x[sample(1:length(x))]) %*% 
            w %*% j/(length(x) - 1))
        (global.p <- sum(abs(isim) > abs(global.i))/length(isim))
        y.sim <- matrix(y[sample(1:n, size = n * k, replace = TRUE)], 
            nrow = n, ncol = k)
        isim <- apply(y.sim, MARGIN = 2, function(j) {
            SCI(as.numeric(t(x[sample(1:length(x))])), j, W = w, 
                type.cc = type, scale.cc = scale.partial)[, tstat]
        })
        ttest.p <- round(apply(isim, 2, function(j) stats::t.test(sci.results[, 
            tstat], y = j, alternative = "two.sided", paired = TRUE, 
            conf.level = 1 - alpha)$p.value), 6)
        p <- length(ttest.p[ttest.p > alpha])/length(ttest.p)
        p1 <- 2 * min(length(ttest.p[ttest.p > alpha])/k, length(ttest.p[ttest.p < 
            alpha])/k)
        results <- list(I = global.i, SCI = sci.results, nsim = k, 
            global.p = global.p, local.p = p, range.p = p1)
        if (clust) {
            results$clusters <- lisa.clust
        }
        if (return.sims) {
            results$simulated.I <- isim
        }
        class(results) <- c("cross.cor", "list")
    }
    else {
        ttest.p <- round(stats::t.test(sci.results[, tstat], 
            conf.level = 1 - alpha)$p.value, 6)
        ci <- stats::quantile(sci.results[, tstat], probs = probs)
        tstat <- sci.results[, tstat]
        p <- 2 * min(length(tstat[tstat >= ci[2]])/length(tstat), 
            length(tstat[tstat <= ci[1]])/length(tstat))
        results <- list(I = global.i, SCI = sci.results, nsim = NULL, 
            p = p, t.test = ttest.p)
        if (clust) {
            results$clusters <- lisa.clust
        }
        class(results) <- c("cross.cor", "list")
    }
    return(invisible(results))
}
<bytecode: 0x5599a5341200>
<environment: namespace:spatialEco>
 --- function search by body ---
Function crossCorrelation in namespace spatialEco has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1