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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: DF_to_ARRAY
> ### Title: Convert a biomod2 data.frame (or list) into array
> ### Aliases: DF_to_ARRAY LIST_to_ARRAY
> ### Keywords: models, formula, options
> 
> ### ** Examples
> 
> 
> # species occurrences
> DataSpecies <- read.csv(system.file("external/species/mammals_table.csv",
+                                     package="biomod2"), row.names = 1)
> head(DataSpecies)
  X_WGS84  Y_WGS84 ConnochaetesGnou GuloGulo PantheraOnca PteropusGiganteus
1   -94.5 82.00001                0        0            0                 0
2   -91.5 82.00001                0        1            0                 0
3   -88.5 82.00001                0        1            0                 0
4   -85.5 82.00001                0        1            0                 0
5   -82.5 82.00001                0        1            0                 0
6   -79.5 82.00001                0        1            0                 0
  TenrecEcaudatus VulpesVulpes
1               0            0
2               0            0
3               0            0
4               0            0
5               0            0
6               0            0
> 
> # the name of studied species
> myRespName <- 'GuloGulo'
> 
> # the presence/absences data for our species 
> myResp <- as.numeric(DataSpecies[,myRespName])
> 
> # the XY coordinates of species data
> myRespXY <- DataSpecies[,c("X_WGS84","Y_WGS84")]
> 
> 
> # Environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12)
> myExpl = stack( system.file( "external/bioclim/current/bio3.grd", 
+                      package="biomod2"),
+                 system.file( "external/bioclim/current/bio4.grd", 
+                              package="biomod2"), 
+                 system.file( "external/bioclim/current/bio7.grd", 
+                              package="biomod2"),  
+                 system.file( "external/bioclim/current/bio11.grd", 
+                              package="biomod2"), 
+                 system.file( "external/bioclim/current/bio12.grd", 
+                              package="biomod2"))
>                              
> # Keep only points where we have info                       
> myExpl <- extract(myExpl, myRespXY)
> 
> # 1. Formatting Data
> myBiomodData <- BIOMOD_FormatingData(resp.var = myResp,
+                                      expl.var = myExpl,
+                                      resp.xy = myRespXY,
+                                      resp.name = myRespName)

-=-=-=-=-=-=-=-=-=-=-=-=-=-= GuloGulo Data Formating -=-=-=-=-=-=-=-=-=-=-=-=-=-=
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
biomod2
 --- call from context --- 
.BIOMOD_FormatingData.check.args(resp.var, expl.var, resp.xy, 
    resp.name, eval.resp.var, eval.expl.var, eval.resp.xy, PA.nb.rep, 
    PA.nb.absences, PA.strategy, PA.dist.min, PA.dist.max, PA.sre.quant, 
    PA.table)
 --- call from argument --- 
if (!(class(expl.var) %in% available.types[-which(available.types == 
    "SpatialPoints")])) {
    stop(paste("Explanatory variable must be one of ", toString(available.types), 
        sep = ""))
}
 --- R stacktrace ---
where 1: .BIOMOD_FormatingData.check.args(resp.var, expl.var, resp.xy, 
    resp.name, eval.resp.var, eval.expl.var, eval.resp.xy, PA.nb.rep, 
    PA.nb.absences, PA.strategy, PA.dist.min, PA.dist.max, PA.sre.quant, 
    PA.table)
where 2: BIOMOD_FormatingData(resp.var = myResp, expl.var = myExpl, resp.xy = myRespXY, 
    resp.name = myRespName)

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (resp.var, expl.var, resp.xy, resp.name, eval.resp.var, 
    eval.expl.var, eval.resp.xy, PA.nb.rep, PA.nb.absences, PA.strategy, 
    PA.dist.min, PA.dist.max, PA.sre.quant, PA.table) 
{
    if (grepl("_", resp.name) | grepl(" ", resp.name)) {
        resp.name <- paste(unlist(strsplit(resp.name, "_")), 
            collapse = ".")
        resp.name <- paste(unlist(strsplit(resp.name, " ")), 
            collapse = ".")
        cat("\n Response variable name was converted into", resp.name)
    }
    available.types <- c("numeric", "data.frame", "matrix", "RasterLayer", 
        "RasterStack", "SpatialPointsDataFrame", "SpatialPoints")
    if (!(class(resp.var) %in% available.types)) {
        stop(paste("Response variable must be one of ", toString(available.types), 
            sep = ""))
    }
    if (inherits(resp.var, "Raster")) {
        stop("Raster response variable not supported yet ! \nPlease extract your Presences and your absences by yourself")
    }
    if (!(class(expl.var) %in% available.types[-which(available.types == 
        "SpatialPoints")])) {
        stop(paste("Explanatory variable must be one of ", toString(available.types), 
            sep = ""))
    }
    if (inherits(resp.var, "SpatialPoints")) {
        if (!is.null(resp.xy)) {
            cat("\n      ! XY coordinates of response variable will be ignored because spatial response object is given.")
        }
        resp.xy <- data.matrix(sp::coordinates(resp.var))
        if (class(resp.var) == "SpatialPointsDataFrame") {
            resp.var <- resp.var@data
        }
        else {
            cat("\n      ! Response variable is considered as a only presences one... Is it really what you want?")
            resp.var <- rep(1, nrow(resp.xy))
        }
    }
    if (is.matrix(resp.var) | is.data.frame(resp.var)) {
        if (ncol(resp.var) > 1) {
            stop("You must give a monospecific response variable (1D object)")
        }
        else {
            resp.var <- as.numeric(resp.var[, 1])
        }
    }
    if (is.matrix(expl.var) | is.numeric(expl.var)) {
        expl.var <- as.data.frame(expl.var)
    }
    if (inherits(expl.var, "Raster")) {
        expl.var <- raster::stack(expl.var, RAT = FALSE)
    }
    if (inherits(expl.var, "SpatialPoints")) {
        expl.var <- as.data.frame(expl.var@data)
    }
    if (!is.null(resp.xy)) {
        if (ncol(resp.xy) != 2) {
            stop("if given, resp.xy must be a 2 column matrix or data.frame")
        }
        if (nrow(resp.xy) != length(resp.var)) {
            stop("Response variable and its coordinates don't match")
        }
        resp.xy <- as.data.frame(resp.xy)
    }
    resp.var[which(resp.var > 0)] <- 1
    resp.var[which(resp.var <= 0)] <- 0
    if (is.data.frame(expl.var)) {
        if (nrow(expl.var) != length(resp.var)) {
            stop("If explanatory variable is not a raster then dimentions of response variable and explanatory variable must match!")
        }
    }
    if (is.null(PA.table) & PA.nb.rep < 1) {
        cat("\n> No pseudo absences selection !")
        PA.strategy <- "none"
        PA.nb.rep <- 0
    }
    if (is.null(PA.strategy) & PA.nb.rep > 0) {
        cat("\n> Pseudo absences will be selected randomly !")
        PA.strategy <- "random"
    }
    if (!is.null(PA.table)) {
        cat("\n> Pseudo absences used will be user defined ones !")
        PA.strategy <- "user.defined"
        PA.nb.rep <- 0
    }
    if (PA.strategy == "user.defined") {
        if (!(is.matrix(PA.table) | is.data.frame(PA.table))) 
            stop("\n PA.table must be a matrix or a data.frame")
        if (nrow(PA.table) != length(resp.var)) 
            stop("\n PA.table must have as many row than the number \n           of observation of your response variable")
        colnames(PA.table) <- paste("PA", 1:ncol(PA.table), sep = "")
    }
    if (!is.null(eval.resp.var)) {
        if (!(class(eval.resp.var) %in% available.types)) {
            stop(paste("Response variable must be one of ", toString(available.types), 
                sep = ""))
        }
        if (inherits(eval.resp.var, "Raster")) {
            stop("Raster response variable not supported yet ! \nPlease extract your Presences and your absences by yourself")
        }
        if (!is.null(eval.expl.var)) {
            if (!(class(eval.expl.var) %in% available.types[-which(available.types == 
                "SpatialPoints")])) {
                stop(paste("Explanatory variable must be one of ", 
                  toString(available.types), sep = ""))
            }
        }
        else {
            if (!(inherits(expl.var, "Raster"))) {
                stop("If explanatory variable is not a raster and you want to consider evaluation response variable, you have to give evaluation explanatory variables")
            }
        }
        if (inherits(eval.resp.var, "SpatialPoints")) {
            if (!is.null(eval.resp.xy)) {
                cat("\n      ! XY coordinates of response variable will be ignored because spatial response object is given.")
            }
            eval.resp.xy <- data.matrix(sp::coordinates(eval.resp.var))
            if (class(eval.resp.var) == "SpatialPointsDataFrame") {
                eval.resp.var <- eval.resp.var@data
            }
            else {
                cat("\n      ! Response variable is considered as a only presences one... Is it really what you want?")
                eval.resp.var <- rep(1, nrow(eval.resp.xy))
            }
        }
        if (is.matrix(eval.resp.var) | is.data.frame(eval.resp.var)) {
            if (ncol(eval.resp.var) > 1) {
                stop("You must give a monospecific response variable (1D object)")
            }
            else {
                eval.resp.var <- as.numeric(eval.resp.var[, 1])
            }
        }
        if (is.matrix(eval.expl.var) | is.numeric(eval.expl.var)) {
            eval.expl.var <- as.data.frame(eval.expl.var)
        }
        if (inherits(eval.expl.var, "Raster")) {
            eval.expl.var <- raster::stack(eval.expl.var)
        }
        if (inherits(eval.expl.var, "SpatialPoints")) {
            eval.expl.var <- as.data.frame(eval.expl.var@data)
        }
        if (!is.null(eval.resp.xy)) {
            if (ncol(eval.resp.xy) != 2) {
                stop("if given, resp.xy must be a 2 column matrix or data.frame")
            }
            if (nrow(eval.resp.xy) != length(eval.resp.var)) {
                stop("Response variable and its coordinates don't match")
            }
            eval.resp.xy <- as.data.frame(eval.resp.xy)
        }
        if (is.data.frame(eval.expl.var)) {
            if (nrow(eval.expl.var) != length(eval.resp.var)) {
                stop("If explanatory variable is not a raster then dimentions of response variable and explanatory variable must match!")
            }
        }
        if (sum(is.na(eval.resp.var)) > 0) {
            cat("\n      ! NAs have been automaticly removed from Evaluation data")
            if (!is.null(eval.resp.xy)) {
                eval.resp.xy <- eval.resp.xy[-which(is.na(eval.resp.var)), 
                  ]
            }
            eval.resp.var <- na.omit(eval.resp.var)
        }
        eval.resp.var[which(eval.resp.var > 0)] <- 1
        eval.resp.var[which(eval.resp.var <= 0)] <- 0
        if (sum(eval.resp.var == 1) < 1 | sum(eval.resp.var == 
            0) < 1) {
            stop("Evaluation response data must have both presences and absences")
        }
    }
    else {
        cat("\n      ! No data has been set aside for modeling evaluation")
        eval.expl.var <- eval.resp.xy <- NULL
    }
    return(list(resp.var = resp.var, expl.var = expl.var, resp.xy = resp.xy, 
        resp.name = resp.name, eval.resp.var = eval.resp.var, 
        eval.expl.var = eval.expl.var, eval.resp.xy = eval.resp.xy, 
        PA.nb.rep = PA.nb.rep, PA.nb.absences = PA.nb.absences, 
        PA.strategy = PA.strategy, PA.dist.min = PA.dist.min, 
        PA.dist.max = PA.dist.max, PA.sre.quant = PA.sre.quant, 
        PA.table = PA.table))
}
<bytecode: 0x5652158d35e8>
<environment: namespace:biomod2>
 --- function search by body ---
Function .BIOMOD_FormatingData.check.args in namespace biomod2 has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if (!(class(expl.var) %in% available.types[-which(available.types ==  : 
  the condition has length > 1
Calls: BIOMOD_FormatingData -> .BIOMOD_FormatingData.check.args
Execution halted