list of methods

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

list of methods

R devel mailing list
I recently got a request to add head() and tail() methods for Surv objects, which is quite
reasonable, but not unlike other requests for logLik,  vcov, extractAIC, ...   What they
all have in common is that are methods added since creation of the survival package, and
that I didn't know they existed.

To try and get ahead of the curve, is there a way to list names of all of the default
methods?   There are functions to get all the instances of a method by name, e.g.
methods("extractAIC") or find all the methods already implemented for a class, but I don't
see something give me a list of the ones that I haven't created yet.

Terry T.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: list of methods

Michael Lawrence-3
While it's easy to conceive of a utility that found all generics for
which there is no non-default method for a given class vector, it's
not clear it would be useful, because it depends on the nature of the
object. Surv objects are vector-like, so they need to implement the
"vector API", which is not formally defined. You could look at the
S4Vectors package or the date/time classes for reference. But Surv
gets a lot less for free since length() returns twice their logical
length, an unfortunate inconsistency.

Michael



On Tue, Jun 26, 2018 at 11:24 AM, Therneau, Terry M., Ph.D. via
R-devel <[hidden email]> wrote:

> I recently got a request to add head() and tail() methods for Surv objects, which is quite
> reasonable, but not unlike other requests for logLik,  vcov, extractAIC, ...   What they
> all have in common is that are methods added since creation of the survival package, and
> that I didn't know they existed.
>
> To try and get ahead of the curve, is there a way to list names of all of the default
> methods?   There are functions to get all the instances of a method by name, e.g.
> methods("extractAIC") or find all the methods already implemented for a class, but I don't
> see something give me a list of the ones that I haven't created yet.
>
> Terry T.
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: list of methods

R devel mailing list
In a Surv object length() returns number of survival times contained in the object, which
is the logical thing to do.  The fact that a survival time needs 2 or 3 values to
represent is simply a nuisance.   Thus length(unclass(x)) = amount of memory consumed is
not going to map to sensible operations.

Yes, I'll have to go through the list by hand.  Some methods will only apply to transform
functions (makepredictcall.pspline), others to model fits (extractAIC.survreg) and others
to vectors (head.Surv).   I just need to slog through it.

Looking at Date is a good idea, but it wouldn't have revealed head  or tail.  It did point
out addition of c() and rep() methods.

Terry

On 06/26/2018 01:40 PM, Michael Lawrence wrote:

> While it's easy to conceive of a utility that found all generics for
> which there is no non-default method for a given class vector, it's
> not clear it would be useful, because it depends on the nature of the
> object. Surv objects are vector-like, so they need to implement the
> "vector API", which is not formally defined. You could look at the
> S4Vectors package or the date/time classes for reference. But Surv
> gets a lot less for free since length() returns twice their logical
> length, an unfortunate inconsistency.
>
> Michael
>
>
>
> On Tue, Jun 26, 2018 at 11:24 AM, Therneau, Terry M., Ph.D. via
> R-devel <[hidden email]> wrote:
>> I recently got a request to add head() and tail() methods for Surv objects, which is quite
>> reasonable, but not unlike other requests for logLik,  vcov, extractAIC, ...   What they
>> all have in common is that are methods added since creation of the survival package, and
>> that I didn't know they existed.
>>
>> To try and get ahead of the curve, is there a way to list names of all of the default
>> methods?   There are functions to get all the instances of a method by name, e.g.
>> methods("extractAIC") or find all the methods already implemented for a class, but I don't
>> see something give me a list of the ones that I haven't created yet.
>>
>> Terry T.
>>
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: list of methods

Duncan Murdoch-2
In reply to this post by R devel mailing list
On 26/06/2018 2:24 PM, Therneau, Terry M., Ph.D. via R-devel wrote:
> I recently got a request to add head() and tail() methods for Surv objects, which is quite
> reasonable, but not unlike other requests for logLik,  vcov, extractAIC, ...   What they
> all have in common is that are methods added since creation of the survival package, and
> that I didn't know they existed.
>
> To try and get ahead of the curve, is there a way to list names of all of the default
> methods?   There are functions to get all the instances of a method by name, e.g.
> methods("extractAIC") or find all the methods already implemented for a class, but I don't
> see something give me a list of the ones that I haven't created yet.

There are a lot of default methods; most of them are probably irrelevant
to you.  But if you want to see them, here's one way:

   basepkgs <- rownames(subset(as.data.frame(installed.packages()),
                               Priority == "base"))
   for (pkg in basepkgs) {
     print(ls(getNamespace(pkg), pattern = ".default$"))
   }

This only shows the ones in base packages.  If you expand to 'Priority
== "recommended"' or something even less restrictive, you'll get more.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel