Error : unused arguments in pairs()
Dear Prof. Ripley, thanks for your reply. Unfortunately I still was not able to solve the problem. I tried it with the Iris data and you can find the code below:
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)
}
pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)],
lower.panel=panel.cor )
What I would ideally like to have is that the upper panel shows the plot
with the iris$Species color coded and the lower panel showing the
correlation coefficients for the total data in the plot, but also for the
each iris$Species with the same color code as in the upper panels.
So the lower panel should therefore actually show 4 correlation coefficients
in each panel (color coded); It does not need to be sized according to the
value of the correlation coefficient as shown in the example above.
Any help with this would be appreciated a lot,
Kind regards,
Herwig
Prof Brian Ripley wrote:
Your panel function should have a ... argument: see the help page for pairs(). Since your example is not 'self-contained' I cannot test this out .... On Sun, 4 Jan 2009, herwig wrote:
Hi there, I am just starting in R and this might be a very basic question. I applied one on the examples of pairs() to my own data. The examples shows scatter plots on one side of the matrix and the correlation coefficients on the other which works well. I then modified it slightly because I want different colors in the plots. Now i am getting the error of unused arguments, because the color arguments are not used when the corellation coefficient is printed. I would be very greatful if anyone could help me to get rid of this error. Here my code:
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)
+ }
pairs(pep[9:18],cex.labels = 0.6, pch = 21, bg = c("red", "blue",
"green",
"yellow","brown")[unclass(pep$taxonomic.position)],
lower.panel=panel.cor)
thanks, Herwig -- View this message in context: http://www.nabble.com/Error-%3A-unused-arguments-in---pairs%28%29-tp21283398p21283398.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org 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.
-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________ R-help at r-project.org 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.
View this message in context: http://www.nabble.com/Error-%3A-unused-arguments-in---pairs%28%29-tp21283398p21300856.html Sent from the R help mailing list archive at Nabble.com.