[R] Attempt to customise the "plotpc()" function

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Sun May 16 20:05:34 CEST 2010


Nikos Alexandris:
> Among the (R-)tools, I've seen on the net, for (bivariate) Principal
> Component scatter plots (+histograms), "plotpc" [1] is the one I like
> most.
 
[...]

> I started the modification by attempting first to get a "prcomp" version of
> "plotpc()" (named it "plotpc.svd()") by altering the following:
 
[...]
 
> I am bit lost now about where I should continue looking for required
> modifications in the code. Any hints?

Once again I am replying to myself ;-)

I've spend many-many hours of searching in manuals, on the net and trying 
crazy things to understand where this mystical (to me) function "un()" could 
be sourced from. Eventually I decided to change all of its occurrences with 
"unit()" as I am sure this was the function meant to be used but I hit another 
wall, another unknown function my.plot.something(). I was then sure that they 
are "sourced" from somewhere.

At some point I was enlightened and had a look in the source "plotpc.R" where 
I just found what I was expecting to found ;-). It may look silly but to the 
unexperienced useR it is not. I was only looking at the print-out of "plotpc" 
(without the parentheses) and was puzzled that the "un()" function is nowhere.

  - Question: why isn't the whole source of plotpc.R printed out with 
"plotpc"? Or why isn't any clue given where this "un()" function is coming 
from? "methods()" and "getAnywhere()" say anything about it.

  * Note to self: look at the Source.R

Anyhow, it was a long learning-night-session and I am good to go. In fact, I 
am very close to what I want to do. I've added the option to use either 
"prcomp" or "princomp" as well as if the input dataset should be centered 
and/or scaled. I have still some strange issue with respect to how the plotted 
histograms (of PC1 and PC2) along with their text are flipped. Hopefully I'll 
fix this too.

I will be contacting soon the author to post him my modifications as 
enhancement wishes. If anybody is interested to know or help please post here.

Regards, Nikos



More information about the R-help mailing list