Apprentice Piece with Lattice Graphs

February 28, 2012

(This article was first published on theBioBucket*, and kindly contributed to R-bloggers)

Lattice graphs can be quite tedious. I don’t use them too often and  when I need them I usually have to dig the archives for the parameter-details.
The here presented example may serve as a welcome template for the usage of panel functions, panel ordering, for drawing of lattice keys, etc.
You can download the example data HERE.

(Also, check this resource with examples by the lattice-author himself). 

df <- read.csv("PATH/TO/Downloads/lattice_data.csv",
header = T, sep = ";")
mypch <- rep(21, 3)
mycol <- c(rgb(0.2, 0.8, 0.9), rgb(0.8, 0.2, 0.9), rgb(0.9, 0.2, 0.2))

stripplot(mean ~ group1 | item_parc, groups = group2, data = df,
type = c("a", "p"), strip = strip.custom(strip.names = c(F, T)),
ylab = "Score-Mittelwert", layout = c(2, 4),
scales = list(y = list(cex = 0.9),
x = list(cex = 1.1, labels = c("männl.", "weibl."),
tck = c(1, 0))),
par.strip.text = list(cex = 0.9),
panel = function(...) {
panel.stripplot(..., col = mycol, pch = mypch, fill = mycol)
index.cond = list(c(7,8,5,6,3,4,1,2)),
key = list(space = "bottom", text = list(c("Alter < 35 J.",
"Alter 35-50 J.",
"Alter > 50 J.")),
points = list(col = mycol, cex = 0.8, pch = mypch, fill = mycol),
rep = F))

To leave a comment for the author, please follow the link and comment on their blog: theBioBucket*. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)