[R] the predict.lda function

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Mar 2 10:08:00 CET 2010


On Mon, 2010-03-01 at 16:55 -0500, Diana Connett wrote:
> Hello.
> I just downloaded R onto a new computer, and after entering library(MASS), I
> still get the message "Error: could not find function "predict.lda"" when I try
> to use the predict.lda function (even just "predict.lda()")
> 
> Can anyone help me out?

Stop calling it directly, use the generic predict() instead. The reason
predict.lda can't be found is that it is hidden in a package NAMESPACE:

> require("MASS")
Loading required package: MASS
> predict.lda()
Error: could not find function "predict.lda"
> methods(predict)
 [1] predict.ar*                predict.Arima*            
 [3] predict.arima0*            predict.glm               
 [5] predict.glmmPQL*           predict.HoltWinters*      
 [7] predict.lda*               predict.lm                
 [9] predict.loess*             predict.lqs*              
[11] predict.mca*               predict.mlm               
[13] predict.nls*               predict.polr*             
[15] predict.poly               predict.ppr*              
[17] predict.prcomp*            predict.princomp*         
[19] predict.qda*               predict.rlm*              
[21] predict.smooth.spline*     predict.smooth.spline.fit*
[23] predict.StructTS*         

   Non-visible functions are asterisked

By calling things directly you aren't really using R the way the
developers want you to. You should not need to know that there are all
those predict methods and what their names are etc. You should just need
to check that there is a method for the object/code you are using and
then call the generic function whilst R takes care of everything else.

If you *must* call it directly:

MASS:::predict.lda()

See ?`:::`

HTH

G

> Thank you!
> 
> Diana Connett
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list