[R] Expression in panel.text

David Orme d.orme at imperial.ac.uk
Fri Apr 22 17:12:34 CEST 2005


Hi,

I've got a lattice xyplot and I want to superimpose correlation 
coefficients and p values on each panel. I've been trying to get this 
to work using something of the form:

x <- rnorm(400)
y <- rnorm(400)
a <- gl(4, 100)

xyplot(y~x | a,
		panel=function(x,y, ...){
			panel.xyplot(x,y, ...)
	        curr.cor <- cor.test(x,y)
	        crho <- round(curr.cor$estimate,2)
	        cpv <- format.pval(curr.cor$p.value, eps = 0.01, digits=2)
	        exprrho <- substitute(rho == crho, list(crho=crho))
	        exprpv <- substitute(italic(p) == cpv, list(cpv=cpv))
	        panel.text(-2, 2, label=exprrho)
     	        panel.text(2, 2, label=exprpv)
	        })

The two expressions (expprho and exprpv) plot as expected on a normal 
text() call  but in the panels, all that appears at the coordinates is 
"==". This is the first element in exprrho; other than that,  I can't 
figure out what is going wrong.

Any suggestions?

Thanks in advance.
David

 > version
          _
platform powerpc-apple-darwin6.8
arch     powerpc
os       darwin6.8
system   powerpc, darwin6.8
status
major    2
minor    0.0
year     2004
month    10
day      04
language R




More information about the R-help mailing list