Hello,
I'm trying to pull off a certain graph using splom, and can't quite get my
panel functions right.
Basically, the equivalent using pairs would be something like this (using iris
data set as an example):
panel.corval <- function(x, y, digits=2, prefix="", cex.cor,col,pch)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y,use="complete.obs"))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex )
}
pairs(iris[,1:4], lower.panel=panel.smooth,
upper.panel=panel.corval,col=rainbow(nlevels(iris$Species))[iris$Species],pch=19)
My goals are:
1) to have in one panel (above or below the diagonal) the points themselves
with a smoothing line over all the points and in the other the (absolute) value
of the correlation coefficient, so as to get an overall idea of my correlations
2) to be able to identify points depending on levels of one or more factors
(hence the groups argument that is giving me a hard time in writing a
succesfull panel function)
3) I want to do this in splom as I want to build several scatterplot matrices
subsetting my data over the levels of another factor...
Could anyone please help me out with this ?
Also, while trying to set up an example, I landed upon this behavior I couldn't
quite make sense of:
panel.corval <- 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,use="complete.obs"))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex )
}
pairs(iris[,1:4], lower.panel=panel.smooth,
upper.panel=panel.corval,col=rainbow(nlevels(iris$Species))[iris$Species],pch=19)
Erreur dans lower.panel(...) : unused argument(s) (col = c("#FF0000",
"#FF0000", "#FF0000",
I can't understand why not specifying col and pch arguments in the function I
use for upper.panel (which dosen't at all need them in this case) is a problem.
It's all the more confusing that the error message says the problem is with
lower.panel... If anyone has a clue as to what's happening, please tell.
R version 2.4.0 (2006-10-03)
i386-pc-mingw32
locale:
LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252
attached base packages:
[1] "grid" "methods" "stats" "graphics" "grDevices" "utils"
[7] "datasets" "base"
other attached packages:
RColorBrewer lattice
"0.2-3" "0.14-17"
Thanks in advance for your help.
David Gouache
Arvalis - Institut du Végétal
Station de La Minière
78280 Guyancourt
Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
______________________________________________
[email protected] 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.