Lattice exercises – part 1

[This article was first published on R-exercises, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.

To leave a comment for the author, please follow the link and comment on their blog: R-exercises.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)