12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Base, grid, and lattice graphicsPerhaps confusingly, the standard distribution of R actually contains threedifferent graphics packages:Base graphics is the graphics system that was originally developed forR. The workhorse function of base graphics is a plot() (see Chapter 16). Thecode for base graphics is in the graphics package, which is loaded by defaultwhen you start R.Grid graphics is an alternative graphics system that was later added toR. The big difference between grid and the original base graphics system isthat grid allows for the creation of multiple regions, called viewports, on asingle graphics page. Grid is a framework of code and doesn’t, by itself,create complete charts. The author of grid, Paul Murrell, describes some ofthe ideas behind grid graphics on his website atwww.stat.auckland.ac.nz/~paul/grid/doc/grid.pdf. Note: The gridpackage needs to be loaded before you can use it.Lattice is a graphics system that specifically implements the idea ofTrellis graphics (or faceted graphics), which was originally developed for thelanguages S and S-Plus at Bell Labs. Lattice graphics in R make use of gridgraphics. This means that the functions for creating graphics and changingoptions in base and lattice are mostly incompatible with one another. Thelattice package needs to be loaded before use.Strictly speaking, type is not an argument to xyplot(), but an argument topanel.xyplot(). You can control the panels of lattice graphics with a panelfunction. The function xyplot() calls this panel function internally, using thetype argument you specified. The default panel function for xyplot() ispanel.xyplot(). Similarly, the panel function for barchart() — which we coverlater in this chapter — is panel.barchart(). The panel function allows you totake fine control over many aspects of your chart. You can find out more in theexcellent Help for these functions — for example, by typing ?panel.xyplot

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!