Diary And Notes For: Jari Oksanen
I feel the R move under my feet: vegan 1.13-1 ahead
Posted on 2008-06-03 07:32
In the next day after vegan 1.13-0 appearing in CRAN, I found a bug touching several functions for ordination graphics. Basically the problem was that R changed (yes, I was warned ahead, but I didn't react). The ultimate and distant reason for these problems is that correspondence analysis (in different flavours) is so central in vegan, and CA is a weighted ordination technique. Because of this, vegan always uses weighted fitting, weighted centroids etc with CA graphics. For this, I have weights() functions in vegan that can extract the weights of "decorana" and "cca" objects in vegan. On the other hand, I have tried to make vegan to work also with non-vegan ordination objects, and some of these even do not have a class, such as results of cmdscale and isoMDS. Function weights() is generic in R, and weights.default is used for thse and many other objects that do not have weights. In R 2.6.2 weights.default returned NULL if the object had not weights, and vegan knew these and regarded the result as an unweighted ordination. In R 2.7.0 weights.default stops with error with many unweighted objects. The reason seems to be that weights.default really is not intended for a default method for any object, but as a specific method to "lm" objects (the other cases in the base R are weights.glm and weights.nls), and if applied to other objects it simply fails. The function is implemented like this: stats:::weights.default function (object, ...) naresid(object$na.action, object$weights) And this fails with many simple results objects: > x <- cmdscale(dist(matrix(runif(100), nrow=10))) > weights(x) Error in object$na.action : $ operator is invalid for atomic vectors So this works only for lists, and would work with data.frames but fails with matrices. The workaround was to embed weights.default returning NULL in the functions that needed this. This looks like such a significant problem with vegan in R 2.7.0 that I'll have a bugfix release 1.13-1 later this week. Other changes for this version are: - together with embedding weights.default, I also corrected some functions that only worked with the results of constrained ordination, but never checked that their input. - Gavin corrected an error that could result in wrong results in pairwise comparisons of betadisper in some cases. - lines.spantree did not take extra graphical parameters because "..." was forgotten in ordiArgAbsorber. - taxa2dist did not have method name (or then this is such a small change that I'll let this be). - mso updates: the mso function was very hastily added for 1.13-0 just before release, and it has improved a lot since Helene Wagner (its main author) joined the vegan team, and these upgrades are better incorporated so that too many persons won't get used to an API that will soon disappear and already disappeared in R-Forge. - mite.xy data will go in. Not really a bug fix, but an example data set that is needed in mso() and also in sedarVegan.
