From sven.templer at gmail.com  Tue Oct  7 11:01:24 2014
From: sven.templer at gmail.com (Sven E. Templer)
Date: Tue, 7 Oct 2014 11:01:24 +0200
Subject: [Rd] S4 Method Dispatch for Class Defined as Attribute
In-Reply-To: <1412672663198.7327@uni.sydney.edu.au>
References: <1412672663198.7327@uni.sydney.edu.au>
Message-ID: <CAHuTOvqsQPODLQ+JKoN-_dH4nzLgXk7_up2yR1vAPkun+AjfPg@mail.gmail.com>

Is setOldClass the solution?

e.g.

x <- list()
class(x) <- "foo"
setGeneric("bar", function(x) "bar generic")
setOldClass("foo")
setMethod("bar", "foo", function(x) "bar foo")
bar(x)

On 7 October 2014 10:00, Dario Strbenac <dstr7320 at uni.sydney.edu.au> wrote:
> Hello,
>
> I am writing an interface to some functions from the CRAN package pamr, which is poorly written.
>
> I have a S4 method I declared with setMethod. I'd like to provide a signature of "pamrtrained" which is the class of object that training creates. The last two lines of code of pamr.train are :
>
>     class(junk) = "pamrtrained"
>     junk
>
> How can I dispatch on these kinds of objects, other than making the signature be "ANY" and checking the class inside the S4 method ? Might these kinds of class assignments be deprecated in a future version of R ?
>
> --------------------------------------
> Dario Strbenac
> PhD Student
> University of Sydney
> Camperdown NSW 2050
> Australia
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] S4 Method Dispatch for Class Defined as Attribute
Sven E. Templer