Your verification ID is: guDlT7MCuIOFFHSbB3jPFN5QLaQ Big Computing: panel plot r
Showing posts with label panel plot r. Show all posts
Showing posts with label panel plot r. Show all posts

Friday, October 10, 2014

Using the Pairs Plot Function in Base R

The pairs plot is used to compare all the data in the selected range with all the other columns on a one to one basis. It is a great first pass to see if a relationship between two variables jumps out at you. In order to show this I will create four variable. The first is a random uniform. The second variable depends on the first variable in a linear relationship. The third variable has a squared relationship with the first variable. Finally the fourth variable has a cubic relationship with the first variable.
indep<-runif(300,-25,25)
linear<-2*indep+rnorm(300,0,3)
exp2<-.05*indep^2+rnorm(300,0,2)
exp3<-indep^3/1000+rnorm(300,0,1)
samples<-as.data.frame(cbind(indep,linear,exp2,exp3))
Now plot them using pairs and see what it produces
pairs(~indep+linear+exp2+exp3,data=samples)
plot of chunk unnamed-chunk-2
The plots in this case do a preety good job of showing us what is going on. As an interesting aside if we just call the plot function on the data.frame sample R does a sample plot for us.
plot(samples)
plot of chunk unnamed-chunk-3