[R] type converters not being saved to workspace

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Apr 9 11:40:44 CEST 2006


It is recommended that you use a package for this sort of thing.

When a package is loaded, the S4 methods it contains are merged into the 
metadata.  When the global environment is loaded, they are not.  Call 
'cacheMetaData(1)' to do so.

[This looks like a bug: cacheMetaData is called on .GlobalEnv in the 
startup code for package methods, but seems not to work when called from 
there.  I think this is because package methods is not at that point on 
the search path (the call is from .onLoad) and hence the coerce() generic 
is not visible to cacheMetaData.  If you have S4 code in a package, it 
will ensure that package methods is attached before your package is 
loaded.]

On Sun, 9 Apr 2006, Joseph Wang wrote:

> Any one can explain why this happens or any work arounds?
>
>> setClass('foo')
> [1] "foo"
>> setAs('foo', 'character', function(from) from)
>> showMethods('coerce')
>
> Function "coerce":
> from = "ANY", to = "array"
> from = "ANY", to = "call"
> from = "ANY", to = "character"
> from = "ANY", to = "complex"
> from = "ANY", to = "environment"
> from = "ANY", to = "expression"
> from = "ANY", to = "function"
> from = "ANY", to = "integer"
> from = "ANY", to = "list"
> from = "ANY", to = "logical"
> from = "ANY", to = "matrix"
> from = "ANY", to = "name"
> from = "ANY", to = "numeric"
> from = "ANY", to = "single"
> from = "ANY", to = "ts"
> from = "ANY", to = "vector"
> from = "ANY", to = "NULL"
> from = "foo", to = "character"
>> q()
> Save workspace image? [y/n/c]: y
>
>
> (restart)
>
>> showMethods('coerce')
>
> Function "coerce":
> from = "ANY", to = "array"
> from = "ANY", to = "call"
> from = "ANY", to = "character"
> from = "ANY", to = "complex"
> from = "ANY", to = "environment"
> from = "ANY", to = "expression"
> from = "ANY", to = "function"
> from = "ANY", to = "integer"
> from = "ANY", to = "list"
> from = "ANY", to = "logical"
> from = "ANY", to = "matrix"
> from = "ANY", to = "name"
> from = "ANY", to = "numeric"
> from = "ANY", to = "single"
> from = "ANY", to = "ts"
> from = "ANY", to = "vector"
> from = "ANY", to = "NULL"
> from = "NULL", to = "OptionalFunction"
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list