Comparing Many Variables in R with Plots — Part 3 in a Series

This is post #03 in a running series about plotting in R.

Say you have a data frame with a number of variables that you would like to compare against each other. While you could plot them all on the same graph, statisticians frequently wish to look for visual evidence of correlation between different sets of observations — particularly when looking for visual evidence of heteroskedasticity. A simple way to do this for every variable in a data frame is to call plot on the data frame itself.

Say we have data as such:

> s <- data.frame(x=1:30, y=10*runif(n=30))
> s$z <- 10*runif(n=30)
# (a more common application is calling residual or predict on a fitted model)
> plot(s)
>


data: plot03

Pairs plot for a data frame

Pairs plot for a data frame

This is an example of a pairs plot, which I’ll cover in more detail in the future.

This entry was posted in Plotting, R, Visualization and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>