Skip to content

maxnet() obscure error when only one predictor #27

@AMBarbosa

Description

@AMBarbosa

With the latest CRAN version of maxnet, when the data matrix provided to maxnet() has only one column, a cryptic error message is produced:

library(maxnet)
data(bradypus)
p <- bradypus$presence
data <- bradypus[, 2, drop = FALSE]
mod <- maxnet(p, data)

# Error in apply(pdata, 1, function(rr) !any(apply(ndata, 1, function(r) identical(r,  : 
#   dim(X) must have a positive length

This can be quite hard to debug, especially in scripts which include previous elimination of variables (e.g. due to collinearity) where the user is not aware of how many variables actually reach the model. I think this is fixed by the instances of drop=FALSE in the GitHub version of maxnet, but it would be very useful to get it on CRAN as well. Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions