[R] superimpose histogram on biplot

From: Jennie Lavine <jennie.lavine_at_gmail.com>
Date: Tue, 01 Apr 2008 11:59:36 -0400


Hi all,

I've been trying to figure out how to superimpose a histogram on a biplot that shows the relative contribution of each axis. I have been using the NIPALS function (http://biomserv.univ-lyon1.fr/~dray/ files/softwares/nipals.R) to run principal component analyses. Here is a toy example.

source("http://biomserv.univ-lyon1.fr/~dray/files/softwares/nipals.R") mat=matrix(runif(100,0,1), ncol=10, nrow=10) nipmat=nipals(mat, nf=9)
scatter(nipmat)

In the plot generated by the above "scatter" command, there is a histogram in the upper left corner. I want to know how to superimpose that histogram on a similar plot, such as the following:

groups = as.factor(c(rep(1,2), rep(2,4), rep(3,4))) s.arrow(dfxy=nipmat$co[,1:2]*8, sub="Day 10", possub="bottomleft", csub=3)
s.class(dfxy=nipmat$li[,1:2], fac=groups, cellipse=2, axesell=F, cstar=0 , col=c(2:3), add.plot=T)

I can create the histogram using:

plot(nipmat$eig/sum(nipmat$eig), type='h')

but I don't know how to superimpose it on the above graph.

Thanks for any help!

Best,
Jennie

Jennie Lavine
PhD Candidate
Center for Infectious Disease Dynamics
Penn State University
505 ASI Building
(814)863-1815

        [[alternative HTML version deleted]]



R-help_at_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. Received on Tue 01 Apr 2008 - 16:59:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Apr 2008 - 17:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive