Dear all,

I have a script (please see below) that gives a scatter plot matrix on 
the upper panel, and the spearman rho and probability values on the 
lower panel. It also gives the density function of each variable in the 
diagonal, adds a smoother and a linear regression line to each scatter 
plot, and puts significant spearman coefficient values in red.
Now I would like to add to the lower panel information, the value of 
n=number of observations used to calculate the spearman correlation 
coefficient. Does anyone know I could I add that parameter to my 
function panel.cor?

Thank you!

Kind regards,

Dulce

################

panel.cor <- function (x, y,method="spearman",digits=2,...)
{
         points(x,y,type="n");
         usr <- par("usr"); on.exit(par(usr))
         par(usr = c(0, 1, 0, 1));
         correl <- cor.test(x, y,method=method);
         r=correl$estimate;
         pval=correl$p.value;
         color="black";
         if (pval<0.05) color="red";
         txt <- format(r,digits=2)
         pval <- format(pval,digits=2)
         txt <- paste("rho=", txt, "\np=",pval,sep="")
         text(0.5, 0.5, txt,col=color)
}

scatterplot.matrix (~ var1 + var2 + var3 , data=mydata,
                                 main="Mydata", smooth=TRUE, 
lower.panel=panel.cor, pch=20, cex=0.5, 
col=c("red","black"),cex.labels=1, font.labels=2, lwd=0.5)





	[[alternative HTML version deleted]]

