Peter Ehlers wrote: > Nikos, > > I think you can just replace the line > > pc <- princomp(x[,1:2], scores=TRUE, na.action=na.fail) > > with > > 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 "automatic"!. 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 printed. Any ideas? > 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 process. ] > Anyway, as you've discovered, when you want to modify code, look > at the sources. Thank you Peter. Kindest regards, Nikos ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.