[R] body of non-visible function
Liaw, Andy
andy_liaw at merck.com
Thu May 5 17:24:02 CEST 2005
> From: Anna Oganyan
>
> 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) doesn't show it.
You may want to learn about getAnywhere() and getS3method().
> In particular, I guess I have a very naïve question...
> I'd 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.
Variables are centered and scaled, so you want to do
scale(data.matrix) %*% loadings(princomp(data.matrix))
Andy
> Thanks.
> Anna
>
> ______________________________________________
> R-help at 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
>
>
>
More information about the R-help
mailing list