Skip to content

Commit

Permalink
Merge branch 'issue-#299-kludge'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jari Oksanen committed Jan 4, 2019
2 parents b978b03 + 114b319 commit 0e7b8be
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/ordiParseFormula.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ function (formula, data, xlev = NULL, na.action = na.fail,
}
## Get na.action attribute, remove NA and drop unused levels
if (NROW(mf) > 0) {
mf <- model.frame(formula(mf), mf, xlev = xlev,
na.action = na.action, drop.unused.levels = TRUE)
## We need to re-construct model.frame and its formula, and
## for this names with functions must be back-quoted
## (`poly(A1, 2)`, e.g.) with the curren scoping to find the
## variable (A1) later. This happened with formula(mf) in R <
## 3.6.0, but now we must be explicit.
mf <- model.frame(as.formula(paste("~",
paste(sapply(names(mf), "as.name"), collapse="+"))),
mf, xlev = xlev,
na.action = na.action, drop.unused.levels = TRUE)
nas <- attr(mf, "na.action")
## Check if there are one-level factors after subset and na.action
for (i in 1:ncol(mf))
Expand Down

0 comments on commit 0e7b8be

Please sign in to comment.