[R-sig-Geo] R 2.6 spdep broken caused by changes in methods

Roger Bivand Roger.Bivand at nhh.no
Sun Feb 24 11:36:35 CET 2008


(was Creating nb object with cell2nb)

Users report problems with as.logical(), as.integer(), and other coercion 
methods in R 2.6 - these are not problems with spdep, but with stale parts 
of the users' installations.

It has come up several times, both on and off list, and is related to 
NEWS for the 2.6.* release:

     o   Making functions primitive changes the semantics of S4
         dispatch: these no longer dispatch on classes based on types
         but do dispatch whenever the function in the base name space is
         called.

         This applies to as.complex(), as.integer(), as.logical(),
         as.numeric(), as.raw(), expm1(), log(), log1p(), log2(),
         log10(), gamma(), lgamma(), digamma() and trigamma(), as
         well as the Math2 and Summary groups.

         Because all members of the group generics are now primitive,
         they are all S4 generic and setting an S4 group generic does
         at last apply to all members and not just those already made
         S4 generic.

         as.double() and as.real() are identical to as.numeric(), and
         now remain so even if S4 methods are set on any of them.
         Since 'as.numeric' is the traditional name used in S4,
         currently methods must be exported from a NAMESPACE for
         'as.numeric' only.

It is also mentioned in "Breaking news" on http://www.R-project.org/Rgeo/, 
point 3. In fact, it can stem from a stale Matrix package in a library in 
.libPaths() - where R looks for packages - or from a stale methods package 
in the same search path. If you say library(), I guess you will see 
something stale in a library, or two copies of methods, one in the 
installation library, one in your own library. You may also have followed 
the (bad) advice in the R for Windows FAQ to "copy across" packages from a 
library for an earlier R installation on upgrading.

It is far safer to allow base and recommended R packages to live in the 
default library, and create your own library in a separate directory, 
using the R_LIBS environment variable (or .libPaths()) to add it to the 
library search path. When an incompatible upgrade of the R engine happens, 
you just fire up the new R, say:

update.packages(checkBuilt=TRUE, ask=FALSE)

If any packages need freshening, this will be taken care of automatically.

This was covered fully in Prof. Brian Ripley's posting of October 4, 
2007, when R 2.6.0 was released:

https://stat.ethz.ch/pipermail/r-help/2007-October/142367.html

Roger


-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list