Lattice part 1 solutions

Below are the solutions to these exercises on lattice.

###############
#             #
# Exercise 1  #
#             #
###############

library(lattice)
dataset <- read.csv("https://www.r-exercises.com/wp-content/uploads/2016/04/dataset.csv", sep=";")
attach(dataset)
barchart(gd ~ win |team,groups=team,xlab="Goals",box.ratio=2,horizontal=F,auto.key=list(space="top", columns=2,
title="Team", cex.title=1))
plot of chunk plot exercises
###############
#             #
# Exercise 2  #
#             #
###############
Team1<-subset(dataset,team==1)
Team2<-subset(dataset,team==2)
 bwplot(Team1$gs,col=2)
plot of chunk plot exercises
bwplot(Team2$gs,col=4)
plot of chunk plot exercises
###############
#             #
# Exercise 3  #
#             #
###############

densityplot(gs,group=team,col=c(2,4))
plot of chunk plot exercises
###############
#             #
# Exercise 4  #
#             #
###############

histogram(win,group=team,col=c(2,4))
plot of chunk plot exercises
###############
#             #
# Exercise 5  #
#             #
###############

xyplot(gd ~ gs+home,group=team,col=c(2,4),data=dataset)
plot of chunk plot exercises
###############
#             #
# Exercise 6  #
#             #
###############

xyplot.ts(gs,screens=c(1,2),group=team,col=c(2,4))
plot of chunk plot exercises
xyplot.ts(gs,screens=c(1,2),group=team,col=c(2,4))
plot of chunk plot exercises
###############
#             #
# Exercise 7  #
#             #
###############

xyplot.ts(gs,screens=c(2,4),group=team,col=c(2,4),cut = list(number = 4, overlap = 0.05))
plot of chunk plot exercises
###############
#             #
# Exercise 8  #
#             #
###############

qq(win ~ gs+inj,group=team,col=c(2,4),data=dataset)
plot of chunk plot exercises