Lattice exercises – part 1

April 30, 2016
By

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

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 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...

Comments are closed.

Sponsors

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)