[R] dots in function names

Thomas Lumley tlumley at u.washington.edu
Wed Mar 24 01:29:07 CET 2004


On Tue, 23 Mar 2004, Robert W. Baer, Ph.D. wrote:

>
> There has been mention of S3 objects on the list.  Is this relevant here?
> Is 'plot.default' a method (or perhaps a type-dependent object
> instantiation?) of the "plot function" object, or is 'plot.default' just a
> second function object that shares a part of a name and uses a "convenience"
> dot for readability?  Does R have standard naming conventions in this
> regard?  I'm guessing that 'plot.default' is a method? of 'plot'.

Yes. It is an S3 method and there is a naming convention. plot.something()
is the plot method for objects of class "something".  Typing
  methods("plot")
will give a list of available methods.  plot.default() is the method used
when there is no specific method available for a given object.

Unfortunately the dot is also used for readability, so we have
list.files(), which is not a method for list(), and t.test(), which is not
a method for t().


>  Assuming
> that other 'plot.something' functions are methods or instantiations of a
> main 'plot' function object,

They aren't part of any `plot' object. They are separate functions.

>				 how do I learn more about such a "main"
> object's subparts short of studying code?  The ?plot help document does not
> have a "see also" for plot.default or (many) other 'plot.something'
> functions.

This would be difficult to make comprehensive, since users can freely add
new plot() methods.  Dynamic help of this sort is on the wishlist, but it
may be a while off.

>		  Is there a simple way to troll for such things when trying to
> expand your horizons?

methods("plot") is probably the best way.  You can also look for methods
for a class: eg methods(class="lm") to see all the things you can do to lm
objects.


> Any general hints on  how one should approach the self-education process in
> this type of situation?

There are some excellent books on R and S out there.

	-thomas




More information about the R-help mailing list