Combining several lattice charts into oneI mentioned the
grid.arrangefunction of the
gridExtrapackage that allows me to combine graphical grid objects onto one page. The
latticeExtrapackage provides another elegant solution for trellis (lattice) plots: the function
c()combines the panels of multiple trellis objects into one.
Here is minimal example from the help file of
library(latticeExtra) ## Combine different types of plots. c(wireframe(volcano), contourplot(volcano))
In my next example I am using data from Eurostat, the statistical office of the European Union, showing the use of public transport in four countries. The data can be accessed directly in R via the eurostat package; see also the package vignette.
Here I have two
xyplotobjects that I combine into one chart using a named vector. I know this is not the best way to present the data, but that is not the point here. Naming the elements in
c()adds those names also into the panel strip. Very handy indeed!
R version 3.1.3 (2015-03-09) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.10.3 (Yosemite) locale:  en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages:  stats graphics grDevices utils datasets methods  base other attached packages:  latticeExtra_0.6-26 lattice_0.20-31 RColorBrewer_1.1-2  eurostat_1.0.16 loaded via a namespace (and not attached):  grid_3.1.3 plyr_1.8.1 Rcpp_0.11.5 reshape2_1.4.1  stringi_0.4-1 stringr_0.6.2 tidyr_0.2.0 tools_3.1.3