Skip to content
Prev 29831 / 63424 Next

S4 coercion

Hi Paul -- does this make the problem more explicit?
[1] "A"
[1] "B"
[1] "C"
numeric(0)
Warning message:
Ambiguous method selection for "coerce", target "C#numeric" (the first
of the signatures shown will be used)
    A#numeric
    B#numeric

The solution is to define a method to resolve the conflict, e.g.,

setAs("C", "numeric", function(from) {
    ## avoid breaking the class abstraction
    as(as(from, "A"), "numeric") *
            as(as(from, "B"), "numeric")
})

I don't know how you want to break your particular tie; that has to do
with the classes you're extending.

Martin            

Paul Gilbert <pgilbert at bank-banque-canada.ca> writes: