R code for seminar 8 (used lattice for graphs)