Closed jarioksa closed 1 day ago
The error really seems crop out on line 81 of plot.cca
:
dots <- match.call(expand.dots = FALSE)$...
which was added in ff75668 to handle dot arguments. However, this seems not work:
plot.cca
arguments that are not ordiplot
arguments will cause an error with rda
, dbrda
& capscale
(but not in cca
): scaling
, const
, hill
, correlation
.ordiplot
arguments that are not plot.cca
arguments are ignored in plot.cca
also in cca
but do not give an error: arrows
, optimize
. Seems to need re-thinking.
Shouldn't ordiplot
have scaling
, hill
, correlation
, and const
? Right now it doesn't seem like you can change what scores get plotted except on which axes, and what types of scores, and ...
is not being passed on to scores()
in ordiplot()
. (I appreciate that this is not really the source of the problem here, but still.)
I don't think so: scaling
, hill
, correlation
and const
only make sense with cca
methods which are a marginal case for ordiplot
and in most cases these arguments would be ignored. With "cca"
and "decorana"
classes we short-cut to plot.cca
and plot.decorana
and skip most of ordiplot
, but for ordiplot
proper and most ordination methods those arguments make sense.
Ignore the above I missed the second part of the conditional
if (inherits(ord, "decorana") || inherits(ord, "cca")) {
I have pushed an alternative fix to issue-685 branch as discussed in cafdc03 - I need to test this though - was there a specific test you were running to check this @jarioksa? I'm not 100% clear on how the new code all works for the piping behaviour. I think optimize
worked where I passed it through ordiplot()
on the example that failed from BiodiversityR, but it would be good to get a second opinion on that.
I used only ordiplot(rda(dune ~ Management, dune.env), scaling = 1)
in git bisect (found later that rda(dune)
is sufficient). I found the problems with optimize
and arrows
later and incidentally and didn't test or serch them. However, if you run R CMD check
you should get tests for most cases with pipes and configurable plots.
I checked the use of NextMethod
in vegan and it seems that everyone of them incorrectly uses ...
. They should be fixed.
$ grep -n NextMethod R/*R
R/add1.cca.R:12: out <- suppressMessages(NextMethod("add1", object, test = "none", ...))
R/anova.prc.R:22: NextMethod("anova", object, ...)
R/biplot.rda.R:12: NextMethod("biplot", x, ...)
R/drop1.cca.R:11: out <- suppressMessages(NextMethod("drop1", object, test = "none", ...))
R/goodness.metaMDS.R:5: return(NextMethod("goodness", object, ...))
R/plot.cca.R:147: NextMethod("plot", x, ...)
R/print.cca.R:118: NextMethod("print", x, ...)
R/print.mso.R:4: NextMethod("print", x, digits = digits, ...)
Some checking suggests that optimize
passing from ordiplot()
-> plot.cca()
currently is not happening with NextMethod()
.
Rereading ?NextMethod
suggests that my description in the commit comment is not quite correct and what you are doing should work, but the evidence is to the contrary and scaling
etc are getting duplicated. I'll need to look into this further when I get back from the UK after the weekend.
The logics and arguments of ordiplot
and plot.cca
are non-concordant. If plot.rda
is changed so that dots are removed in NextMethod("plot", x)
then in the following command
ordiplot(rda(dune), scaling=2, type="t", bg="white", optimize=TRUE)
scaling
, type
and bg
are passed to plot.cca
, but optimize
is not. However, in
ordiplot(rda(dune), scaling=2, type="t", bg="white", spe.par=list(optimize=TRUE))
optimize
is passed to species in plot.cca
. The arguments differ in the following ways:
type
is an argument of both ordiplot
and plot.cca
and it is passed.optimize
is an argument of ordiplot
but not of plot.cca
and it is not passed.spe.par
is not an argument of ordiplot
but it is an argument of plot.cca
and passed.ordiplot
nor plot.cca
have argument bg
and it is passed as a dot argument. It is an argument of text.ordiplot
and will be available there.Inspect the following command:
ordiplot(rda(dune), scaling=2, type="t", bg="white", spe.par=list(optimize=T), arrows = TRUE)
This will be passed to plot.cca
as:
### with NextMethod("plot", x) or empty NextMethod() match.call()
plot.cca(x = ord, choices = choices, scaling = 2, type = type,
xlim = xlim, ylim = ylim, spe.par = ..3, ... = pairlist(bg = "white"))
### with NextMethod("plot", x, ...) sys.call()
### match.call() fails with multiple definitions, args after ... are dot args
plot.cca(ord, choices = choices, type = type, xlim = xlim, ylim = ylim,
..., scaling = 2, bg = "white", spe.par = list(optimize = TRUE))
argument | ordiplot | plot.cca | NextMethod no dots | NextMethod w/dots |
---|---|---|---|---|
choices, type, xlim, ylim | yes | yes | pass | pass |
scaling, spe.par | no | yes | pass | pass as dot arg with conflict |
bg | no | no | pass as a dot argument | pass as a dot argument |
arrows/optimize | yes | no | do not pass | do not pass |
The minimum nuisance strategy is to add optimize
and arrows
among arguments of plot.cca
and have NextMethod
without dots
I focussed on plot.rda
with NextMethod
, but ordiplot(cca(dune), ...)
works like NextMethod("plot", x)
. That is, it works OK but does not pass optimize
and arrows
which are not among formal arguments of plot.cca
.
@gavinsimpson do you want to finish this, or should I have a look at the issue? This breaks BiodiversityR, and should be fixed.
@jarioksa realistically, I'm unlikely to have time to focus on this until I am finished teaching for this semester (last day is Dec 6). I can take a look then, but feel free to tackle this in the meantime.
The problem was found in reverse depedency tests for BiodiversityR examples:
A short example is:
The bug does not occur in the release branch cran-2.6-6. It does not influence
cca
but it influencesdbrda
andcapscale
.The problem was bisected to commit ff7566809 but fix may be needed in a file that was not touched in that commit.