Folks,
I have the following example where I use lattice for a scatterplot of (random) data. What I am trying to do is paste three variables, in a new line each. The problem is found with the third variable which needs to have a subscript.
The code found below will generate the same problem as described:
library(lattice)
library(grid)
set.seed(20)
a <- data.frame(par1=runif(10, min=1, max=100),par2=runif(10, min=1, max=100))
print(xyplot( par1 ~ par2,
data=a,
panel = function(x,y){
n <- length(x)
r <- round(cor(x, y, use="pairwise.complete.obs"), 2)
rc <- 1
panel.abline(a=0, b=1, lty=2, col="grey59", lwd=1.5)
panel.xyplot(x,y, type = c("p", "g"), col="grey29", cex=0.75)
panel.abline(lm(y ~ x), col = "red", lwd=1.5)
grid.text(paste("n=",length(x), "\n", "r=", r, "\n", expression(paste(r[c])), "=", rc, sep=""), 0.60, .90, gp=gpar(col="black", fontsize=11), just="left")
}
))