Friday, January 8, 2010

multifactorial plotting in R: lattice

I've mentioned before in personal communications that if you have lots of factors in a data set you can just flatten out the data set and then use openoffice data pilot to pivot around different factors (also can be done in ruby with Ruport and 'pivot'). This is a good method.

There is a much better method I recently came across: "trellis plots". The package in R is called lattice.

This is clearly the way to quickly and neatly plot multifactorial data in lots of meaningful ways.

Some resources:
In R (as sudo if you want system wide installation):
install.packages("lattice", dependencies=TRUE)  # I don't think there are any dependencies
library("lattice")

2 comments:

EGP said...

Well done Padawan. ;) Also check out: http://www.statmethods.net/advgraphs/trellis.html

I really like this website in general for R help.

JTP said...

Ahhh.. did you already know about lattice (I'm always a little late to the R party) :)

Ohh, that is nice... now I realize why that little table is so handy. It suggests the type of associations that will work with each of the different types of plots.

So a bar chart can be done vert or horizontal: x~A or A~x
While getting 3D cloud data would be done with something like: z~x*y|A

Very smooth. I just can't imagine ever trying to make my own multi-plot again since this covers so much of what I probably will ever want to do. What a time saver!