Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upbug in rda formula vegan 2.4-1 #200
Comments
|
I can't replicate this locally:
Suggestions are to retry in a clean session, and I assume you have already loaded the package via |
|
I have tried several ways of abusing |
|
OK. Now I can reproduce this problem: library(vegan)
data(dune, dune.env)
notadataframe <- data.matrix(dune.env) # change from data.frame to matrix
rda(dune ~ A1 + Moisture, notadataframe) # data *must* be a data.frame
# Error in formula.default(object, env = baseenv()) : invalid formulaIs your The rda(dune ~ notadataframe)but then all variables are used and will be interpreted as continuous (which would be a mistake in this case, as some obviously are factors). Interestingly, lm(A1 ~ Moisture, notadataframe)
#Error in model.frame.default(formula = A1 ~ Moisture, data = notadataframe, :
# 'data' must be a data.frame, not a matrix or an array@gavinsimpson , probably we need to do something to this. |
|
Giving OK:
Bad:
Bad:
Dubious: Looks like a
|
|
works super! thank you so much. |
|
The original problem was a user error, but very easy to be made since it is impossible to see from surface whether a matrix-like object is a Currently all bad error messages are of the same type: we try to evaluate the left-hand-side of a formula with eval(formula[[2]], data)In all these cases LHS should be an independent matrix-like object or they should be dissimilarities that are not in eval(formula[[2]], environment(formula), enclos = .GlobalEnv) # or enclos = parent.frame()which really looks for the LHS where it should be. However, a side effect of the original evaluation is that the formula works when the LHS is a univariate response in I already changed |
|
This was a user error, and the vegan problem was that the error message was unclear. The real underlying problem was that handling of formula was inconsistent and sometimes sloppy in vegan. The formula handling was improved in pull requests #202 and #204 and as the side effect, the message on the user error was fixed and is now informative: |
|
Again thank you for the response, it was more my error. |
|
No worries: it is an easy error to make (and we all have made it several times). The error message was not helpful, and that was our problem. |
Hi,
I have a problems with running the rda function (vegan version 2.4-1),
Help will be much appreciated.
Thanks.
Gugu