[R] pairs(X,Y) analog of cor(X,Y)?

Michael Friendly friendly at yorku.ca
Fri Mar 29 19:16:04 CET 2013


With a data frame containing some X & Y variables I can get the between 
set correlations
with cor(X,Y):

 > cor(NLSY[,1:2], NLSY[3:6])
           antisoc    hyperact     income      educ
math  0.043381307 -0.07581733 0.25487753 0.2876875
read -0.003735785 -0.07555683 0.09114299 0.1884101

Is there somewhere an analog of pairs(X,Y) that will produce the pairwise
plots of each X against each Y?
The formula method for pairs() is for a one-sided formula.  As a 
formula, I'm looking
for something like

pairs(math + read ~ antisoc +hyperact + income +  educ, data=NLSY)

lattice::xyplot has an extended formula interface, but interprets '+' to 
mean
superposition.

-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list