[R] panel.cor NA's
Emma Gerald Boyer
emma.gerald at gmail.com
Tue Aug 26 02:51:33 CEST 2014
I am running the code below and receiving NA's in many of the boxes that
are supposed to contain r values. Could anyone tell me what that means?
and possibly how to fix it?
Thanks,
EGB
panel.cor <- function(x, y, digits=2, prefix="", cex.cor, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor * r)
}
panel.hist <- function(x, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(usr[1:2], 0, 1.5) )
h <- hist(x, plot = FALSE)
breaks <- h$breaks; nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col="cyan", ...)
}
panel.diagonalLine <- function (x, y, col = par("col"), bg = NA, pch =
par("pch"),
cex = 1, col.diagLine = "red", ...)
{
points(x, y, pch = pch, col = col, bg = bg, cex = cex)
ok <- is.finite(x) & is.finite(y)
if (any(ok))
abline(a=0, b=1, col=col.diagLine)
}
panel.lmLine <- function (x, y, col = par("col"), bg = NA, pch =
par("pch"),
cex = 1, col.diagLine = "red", ...)
{
points(x, y, pch = pch, col = col, bg = bg, cex = cex)
ok <- is.finite(x) & is.finite(y)
if (any(ok))
g <- lm(y~x)
abline(g, col=col.diagLine)
}
[[alternative HTML version deleted]]
More information about the R-help
mailing list