"pairs" has two methods, as you can see in the help message (?pairs). According to your code, pairs is supposed to invoke "Default S3 method".
> methods(pairs) [1] pairs.default pairs.formula* Non-visible functions are asteriskedTherefore, you should check the code of the function "pairs.default" to see how error occurs. Just type "pairs.default" at the R command prompt and enter, you can get the source code of "pairs.default".
On 2010-9-2 15:15, Shi, Tao wrote:
Hi Dejian, You're right on this! Do you know how to pass those two argument into lower.panel? Thanks! ...Tao ________________________________ From: Dejian Zhao<zha...@ioz.ac.cn> To:r-help@r-project.org Sent: Tue, August 31, 2010 6:10:16 PM Subject: Re: [R] "pairs" with same xlim and ylim scale I think you have successfully passed the "xlim" and "ylim" into the function pairs1. Compare the two graphs produced by the codes you provided, you can find the xlim and ylim in the second graph have been reset to the assigned value. It seems that the program halted in producing the second plot after adding xlim and ylim. According to the error message, the two added parameters were not used in lower.panel, or the customized function f.xy. On 2010-9-1 2:26, Shi, Tao wrote:Hi list, I have a function which basically is a wrapper of pairs with some useful panel functions. However, I'm having trouble to pass the "xlim" and "ylim" into the function so the x and y axes are in the same scale and 45 degree lines are exactly diagonal. I've looked at some old posts, they didn't help much. I[[elided Yahoo spam]]Thanks! ...Tao pairs1<- function(x, ...) { f.xy<- function(x, y, ...) { points(x, y, ...) abline(0, 1, col = 2) } 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, method="p", use="pairwise.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 * 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", ...) } pairs(x, lower.panel=f.xy, upper.panel=panel.cor, diag.panel=panel.hist, ...) }x<- rnorm(100, sd=0.2) x<- cbind(x=x-0.1, y=x+0.1) pairs1(x) pairs1(x, xlim=c(-1,1), ylim=c(-1,1))Error in lower.panel(...) : unused argument(s) (xlim = c(-1, 1), ylim = c(-1, 1)) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@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.