[R] How to view the code of a method?

Stefano Calza stef at biostatistics.it
Tue Oct 2 17:05:54 CEST 2007


For S3 methods I'd try something like

methods(predict)

 [1] predict.ar*                predict.Arima*             predict.arima0*            predict.glm               
 [5] predict.HoltWinters*       predict.lm                 predict.loess*             predict.mlm               
 [9] predict.nls*               predict.poly               predict.ppr*               predict.prcomp*           
[13] predict.princomp*          predict.smooth.spline*     predict.smooth.spline.fit* predict.StructTS*         

   Non-visible functions are asterisked


and then e.g.

predict.lm

or

getAnywhere(predict.ar)

for those Non-visible


HIH

Stef



On Tue, Oct 02, 2007 at 11:52:34PM +0900, Strong wrote:
<Strong>Dear All 
<Strong>
<Strong>I am a biginner of R.
<Strong>
<Strong>I have difficulty with reading the code of a method.   
<Strong>
<Strong>I am using the vars package to estimate a VAR model and I want to view the code of "predict" method for objects with class attribute "varest". 
<Strong>
<Strong>I thougt I could just type the name "predict" without anything to display the code of the method as I often do with generic function. However, I got the following messages:
<Strong>
<Strong>function (object, ...) 
<Strong>UseMethod("predict")
<Strong><environment: namespace:stats>
<Strong>
<Strong>I cannot figure out the meaning that the above message want to deliver to me and thus cannot find a way to view the code of the predict method with class varest. 
<Strong>
<Strong>Can anyone help me out?
<Strong>
<Strong>Thanks in advance.  
<Strong>
<Strong>
<Strong>Strong Chen
<Strong>
<Strong>______________________________________________
<Strong>R-help a r-project.org mailing list
<Strong>https://stat.ethz.ch/mailman/listinfo/r-help
<Strong>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
<Strong>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list