Re: [R] body of non-visible function

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 06 May 2005 - 01:28:40 EST

getS3method("princomp", "default").
getAnywhere("princomp.default")

The first of these is in the See Also of ?methods.

On Thu, 5 May 2005, Anna Oganyan wrote:

> Hello,
> Is there any possibility in R to see the body of the non-visible
> function, for
> example princomp?
> If I do :
>
>> methods(princomp)
>
> so, I get that princomp.default and princomp.formula are non-visible
> functions and
> body(princomp.default) doesnt show it.
>
> In particular, I guess I have a very na´ve question&
> Id like to see how scores calculation is implemented in the function
> princomp. Because when I multiply my data matrix on the matrix of loadings
>> data.matrix %*% princomp(data.matrix, scores=T)$loadings
>
> I get different result than just doing
>
>> princomp(data.matrix, scores=T)$scores.

You have forgotten to centre your data. It may be more helpful to look at the predict method.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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

Received on Fri May 06 01:54:18 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:36 EST