Skip to content
Prev 66012 / 398502 Next

how to draw xyplot figure like figure 4.18 of MASS (4th) ?

Ups, one mistake!  Change the second line of the code from library(lattice) 
to attach(d), so you get:

d<-read.table('clipboard', header = T)
attach(d)
plot(month,md, col = c('red','blue','black'), type='p')
lines(lowess(d[group=='NN',1]), col = 'red')
lines(lowess(d[group=='SN',1]), col = 'blue')
lines(lowess(d[group=='TP',1]),col = 'black')

par(mfrow = c(2, 2))
plot(d[group=='NN','month'],d[group=='NN','md'], col = 'red', type='p')
lines(lowess(d[group=='NN',1]), col = 'red')
plot(d[group=='SN','month'],d[group=='SN','md'], col = 'blue', type='p')
lines(lowess(d[group=='SN',1]), col = 'blue')
plot(d[group=='TP','month'],d[group=='TP','md'], col = 'black', type='p')
lines(lowess(d[group=='TP',1]), col = 'black')

Francisco