Learning R in Practice

lattice

lattice is a R package specialized in making plot in one step. It created a trellis object print() out to graphics device. In the command line environment, the object will be printed out automatically.

Simple plot

Scatter plot- xyplot

xyplot(Ozone ~ Wind, data=airquality)

Multi-panel plot

The multi-panle plot is marked as subplot is Python.

Create panel

xyplot(Ozone ~ Wind | Month, data=airquality, layout=c(5,1))

Advance usage of panel

Custom panel function

xyplot(y~x |f, panel=function(x,y,...){ panel.xyplot(x,y,...) panel.lmline(x,y,col=2) }