[R] predict function

Duncan Murdoch dmurdoch at pair.com
Sat Feb 14 17:27:11 CET 2004


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




More information about the R-help mailing list