mrmaxent/maxnet

when NAs in parameter "data", mysterious error

jamiemkass opened this issue · 1 comments

When there are rows with NA in the data frame for parameter "data", the user gets the error:
Error in m[p == 1, ] : (subscript) logical subscript too long
Which is confusing to say the least. I had to track down the problem line for line to realize I had NAs in my table. The issue is do to model.matrix(), which automatically (and quietly) removes rows with NA from the matrix. When maxnet.default.regularization() tries to pull out all the rows from "data" with presences, we get this error.
It would be helpful to add an error catch with something informative like "Error: there are rows with NA values in your data table. Please remove them and rerun." If I have the time, I'll add this and do a PR.

Thanks, I've added a check for NA with an error reported if there are any.