-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R: new formula & vegan breaks #299
Comments
The proximal issue of the error is in mf <- model.frame(formula(mf), mf, xlev = xlev,
na.action = na.action, drop.unused.levels = TRUE) and in R-patched > formula(mf)
Management ~ `poly(A1, 2)` + spno whereas in R-devel it returns > formula(mf)
~Management + poly(A1, 2) + spno The current behaviour seems wrong — why is > str(mf)
'data.frame': 13 obs. of 3 variables:
$ Management : Factor w/ 4 levels "BF","HF","NM",..: 1 4 4 NA 2 2 1 4 4 3 ...
$ poly(A1, 2): num [1:13, 1:2] -0.1421 -0.0579 -0.0684 0.1526 -0.0579 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr "1" "2"
.... instead of re-evaluating the formula — we don't store |
There is a plenty of cruft (and nothing's plenty for me) in About the ## R 3.5.x
formula(terms(mf)) but |
R 3.6.0 changed the behaviour of stats:::formula.data.frame, but provided a compatibility function DF2formula. We use this function in R 3.6.0, but R CMD check will issue a NOTE for this function missing in R version where we do not use it. Now we define this function when it is never used to keep R happy (and it exists when it is used and we need to do nothing). Together with the previous commit, this provides a quick & dirty fix to github.com/vegandeves/vegan issue #299. ordiParseFormula is cruft upon cruft, and this adds still one layer. The real solution is to completely re-write formula interpretation in constrained ordination, but that will not be quick.
For scoping, variable names with functions must be quoted in the formula (for instance, `poly(A1, 2)`, `log(A1)`) so that the variable (A1) is later found. stats:::formula.data.frame() did this in R < 3.6.0, but now it returns unquoted formula and we must be explicit. This is a fix to github.com/vegandevs/vegan issue #299, and a bit cleaner than the previous version. Now we explitly re-construct the formula with back-quotes when needed, instead of using different stats functions in R < 3.6.0 (stats:::formula.data.frame) and R >= 3.6.0 (stats::DF2formula), and need no code dependent on R version.
This really seems to be an issue with changes in The changes are in branch https://github.com/vegandevs/vegan/tree/issue-%23299-kludge This is yet another kludge in a kludgy function and the real solution is to re-write (or scrap) |
This looks good @jarioksa I mean ideally we'd rewrite it but that is a longer-term project and if this maintains current behaviour then that's good. |
This closes issue #299 with a (temporary) kludge. The issue was caused by changes in R-devel rev 75891 (maechler Sun, 23 Dec 2018) which changed the behaviour of stats:::formula.data.frame() with model.frames.
Closed with commit 0e7b8be. This is a kluge, and in long term, whole |
R 3.6.0 changed the behaviour of stats:::formula.data.frame, but provided a compatibility function DF2formula. We use this function in R 3.6.0, but R CMD check will issue a NOTE for this function missing in R version where we do not use it. Now we define this function when it is never used to keep R happy (and it exists when it is used and we need to do nothing). Together with the previous commit, this provides a quick & dirty fix to github.com/vegandeves/vegan issue #299. ordiParseFormula is cruft upon cruft, and this adds still one layer. The real solution is to completely re-write formula interpretation in constrained ordination, but that will not be quick. (cherry picked from commit ef5cdfe)
For scoping, variable names with functions must be quoted in the formula (for instance, `poly(A1, 2)`, `log(A1)`) so that the variable (A1) is later found. stats:::formula.data.frame() did this in R < 3.6.0, but now it returns unquoted formula and we must be explicit. This is a fix to github.com/vegandevs/vegan issue #299, and a bit cleaner than the previous version. Now we explitly re-construct the formula with back-quotes when needed, instead of using different stats functions in R < 3.6.0 (stats:::formula.data.frame) and R >= 3.6.0 (stats::DF2formula), and need no code dependent on R version. (cherry picked from commit 114b319)
This is triggered by github.com/vegandevs/vegan issue #299. The purpose is to have much simpler, clearly faster and more robust version of ordiParseFormula. The work starts from the scratch and implements first only a part of the original functionality thus breaking vegan, but we try to gain the original functionality with time.
I just got the following email message from Martin Maechler:
This may mean that we have to do something with the formula. Most likely this concerns
cca.formula
and its ilk. Other functions have more usual handling offormula
, although we do have matrix-like right-hand-side in most functions.The text was updated successfully, but these errors were encountered: