[R] Attempt to customise the "plotpc()" function
nikos.alexandris at felis.uni-freiburg.de
Sun May 16 20:37:53 CEST 2010
Peter Ehlers wrote:
> I think you can just replace the line
> pc <- princomp(x[,1:2], scores=TRUE, na.action=na.fail)
> pc <- prcomp(x[,1:2], retx=TRUE, center=pc.center,
> scale.=pc.scale, na.action=na.fail)
> and rename the components of pc
> names(pc) <- c('sdev', 'loadings', 'center', 'scale', 'scores')
Right. Υet, it is still not enough. I had to change the definition of the
limits that feed viewport mainly because of the huge difference of an unscaled
vs. scaled dataset before the pc-analysis takes place.
Because I want to give (me) the option to have really informative plots, I've
added an extra grid.points() in case the data are transformed (centered and/or
scaled) to print both the original and the transformed (with another pch
and/or color) point cloud.
> and then use the rest of the plotpc() code as is (except for
> maybe having to use flip1=TRUE, etc).
Hmm... I am _now_ working on it to understand how I could make this
If I give flip1, flip2 (=TRUE) the histograms are located where they should
(optically) be printed but the text (rotation angle) that accompanies the
histogram is I think not correct. It is quite the opposite angle that is being
> As to why other functions used in plotpc() are not printed
> when you ask R to print plotpc(): why should they be? Can you
> imagine the mess that would result if you got the printouts of
> is.na(), pushViewport, popViewport, ...? Egad!
Thank you Peter. I understand it now. [ Ignorant me but if you don't know
something you will probably do mistakes (which is after all the learning
> Anyway, as you've discovered, when you want to modify code, look
> at the sources.
Thank you Peter. Kindest regards, Nikos
More information about the R-help