Skip to content
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

Scoping issues in anova.ccaby* methods #101

Merged
merged 7 commits into from
Feb 25, 2015

Conversation

jarioksa
Copy link
Contributor

There were too almost simultaneous reports on scoping issues. Benedicte Bachelot reported that anova.ccabyterm failed when the community data had a name of a function. She had all, and the test case has

data(dune, dune.env)
cca <- dune
m <- cca(cca ~ ., dune.env)
anova(m, by="margin") # fails

A couple of days later, Richard Telford tweeted about problems in embedding anova.ccabymargin in lapply, and @gavinsimpson raised this as issue #100. When testing this, I noticed that the fix made for the Bachelot case also corrected this issue.

I am not quite sure that this PR is completely safe: environments are a pain. However, all old test cases pass and some that failed earlier also work now. Some scoping issues still remain, but the reported bad cases were corrected. Better make this public for review, though.

Jari Oksanen added 7 commits February 23, 2015 13:28
This fails:

data(dune, dune.env)
cca <- dune
m <- cca(cca ~ ., dune.env)
anova(m, by="term")

... and ordiParseFormula finds function cca() instead of data "cca"
Benedicte Bachelot reported that anova.cca(..., by=) cases fail
if community data had the same name as some function. She called
her community data 'all' (which is a primitive), but any other
function name was found before data. Changes in scope fix the
reported case, but there are still other cases where the same
confusion occurs.

The initial report was emailed to me on 21/2/2015.
Fixes some (but not all) scoping issues
There are still a couple of cases that fail, but these are now
more clearly marked as FIXME
Embed rda in a function used in lapply(). This tests failed
yesterday, but it worked when I got it: some fix in scoping
issue automatically fixed this, too.
envdepth argument was kluge released in vegan 1.15-0 (Sep 30, 2008)
to handle some problems with capscale. This never really worked,
and the ChangeLog of the kluge put it:
"(The environment() drives me crazy, says J.O.)"
@gavinsimpson
Copy link
Contributor

@jarioksa This looks good and the fix (evaluating in the environment of the formula) is mentioned as a fix to the "bug" in update(), which evaluates in the parent.frame(), that Hadley mentions in his Advanced R book section on capturing calls.

I'm going to merge this...

@gavinsimpson gavinsimpson reopened this Feb 25, 2015
gavinsimpson added a commit that referenced this pull request Feb 25, 2015
Scoping issues in anova.ccaby* methods
@gavinsimpson gavinsimpson merged commit 071b5ed into vegandevs:master Feb 25, 2015
@jarioksa jarioksa added this to the v2.2-2 milestone Mar 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants