Eventually I would like to get the following result:
I start with a simple bar chart, using the
Insurance
data set of the MASS package.Please note that if you use R-2.15.2 or higher you may get a warning message with the current version of lattice (0.20-10), but this is a known issue, and I don't think you need to worry about it.
library(MASS)
library(lattice)
## Plot the claims frequency against age group by engine size and district
barchart(Claims/Holders ~ Age | Group, groups=District,
data=Insurance, origin=0, auto.key=TRUE)
To change the legend I specify a list with the various options for
auto.key
. Here I want to set the legend items next to each other, add a title for the legend and change its font size: Read more »