Lattice exercises – part 1

plot exercises-10In the exercises below we will use the lattice package. First, we have to install this package with install.packages("lattice") and then we will call it library(lattice) . The Lattice package permits us to create univariate, bivariate and trivariate plots. For this set of exercises we will see univariate and bivariate plots. We will use a dataset example that we have to download from here.

Answers to the exercises are available here.

If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.

Exercise 1
Create a barchart of goals done (Variable gd, grouping by team.

Exercise 2
Now let’s create two datesets (subset dataset by team) and then use the bwplot function to plot goals received (Var: gs).

Exercise 3
Return to the main dataset and then create a densityplot of goals received, grouping by team.

Exercise 4
Create a histogram of win matches (Var: Win), grouping by team.

Exercise 5
Now we introduce the xyplot command. In this exercises you have to create a plot of goals received against goals done and play at home (variable home), grouping by team.

Exercise 6
From the previous issue we will plot in this exercises a time-series xyplot. Again use goals done variable by team (hint:you have to do two different plots).

Exercise 7
Return to exercise 5 and create a time-series xyplot, grouping by team for goals received variable. Customize your plot with the cut option.

Exercise 8
Finally, produce a quantile-quantile (qqplot) plot of win matches against goals received and injuries (variable inj), grouping by team.