[R] predict function

Gabor Grothendieck ggrothendieck at myway.com
Sat Feb 14 19:29:20 CET 2004



Other things one might want to ask:

- what is the S3 generic corresponding to predict.loess?

  answer: predict

- what are the other methods associated with that S3 generic?

  answer: methods(predict)

- what are all the methods for a given S3 class?

  answer: apropos("[.]loess$") may find some of them but its 
  not guaranteed to find all of them.  In fact, in this case it 
  does not find any.  

Date:   Sat, 14 Feb 2004 11:27:11 -0500 
From:   Duncan Murdoch <dmurdoch at pair.com>
To:   Liaw, Andy <andy_liaw at merck.com> 
Cc:   <r-help at stat.math.ethz.ch>, <ligges at statistik.uni-dortmund.de>,'Rolf Turner' <rolf at math.unb.ca> 
Subject:   Re: [R] predict function 

 
On Sat, 14 Feb 2004 10:41:41 -0500, you wrote:

>If you know what you're looking for, you can always get to non-exported
>function by using :::, e.g., modreg:::predict.loess will give you the
>function. 

Or

getAnywhere('predict.loess')

or

getS3method('predict','loess')

(which are both good to know, because predict.loess won't be in modreg
in 1.9, it's in the new "stats" package).

Rolf said:
>Why are the developers ***DOING*** these things to us?
>
>It used to be so simple and straightforward! If I wanted to look
>at an object, including a function object, I typed its name. Now
>I get hand-cuffed by this ``namespace'' business!

Things weren't so simple in the old days in cases where two packages
both defined their own predict.loess functions, or when a user created
a function named "c" or "t", or in lots of other situations of name
collisions. When two things had the same name, problems were really
likely to arise.

The point of namespaces is to protect the code in packages from
accidental name collisions. Packages with namespaces can safely use
c() and t() and know what is going to happen.

The decision not to export the name "predict.loess" follows from the
general principle that you shouldn't export things unless you need to.
You should be calling "predict". If you really need to call
"predict.loess" and "predict" won't get you there, you need to jump
through extra hoops to get it.

Duncan Murdoch

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list