RDX2 X  g10.1 source function(device=""){ 3 if(device!="")hardcopy(width=3.25, height=2.25, F device=device, trellis=T, pointsize=c(9,6)) 2 oldpar <- par(mar = par()$mar - c(1, 0, 1, 0))  on.exit(par(oldpar))  library(lattice) 3 print(stripplot(loc ~ harvwt, data=ant111block, 3 xlab="Harvest weight of corn"))  if(device!="")dev.off()  }ў§$ device ў { if !=џ ў hardcopy width@  height@џџ trellis T pointsize c@"@ўўў <- oldpar par mar - $џў marў џ?№?№ўўўў on.exitџџўў library latticeў print stripplot ~ loc harvwtў data ant111block xlab Harvest weight of cornўўџџџ ў dev.offўўў g10.10џ( function(device=""){ A if(device!="")hardcopy(device=device, width=4.5, height=2.25, 3 color=TRUE, pointsize=8) E oldpar <- par(mar=c(4.1,4.1,1.1,1.1), mgp=c(2.5,0.75,0), pty="s",  mfrow=c(1,2))  on.exit(par(oldpar))  library(lme4) ## library(MEMSS) % Orthodont$age <- Orthodont$age-11 > ab <- coef(lmList(distance ~ age|Subject, data=Orthodont)) ) ab$sex <- substring(rownames(ab),1,1) # names(ab) <- c("a", "b", "sex")  xlim <- range(ab[,1]) * xlim <- xlim+diff(xlim)*c(-.015, .185)  ylim <- range(ab[,2]) * ylim <- ylim+diff(ylim)*c(-.015, .015) : plot(ab[,1], ab[,2], col=c(F="red", M="blue")[ab$sex], 7 pch=c(F=1, M=3)[ab$sex], xlim=xlim, ylim=ylim, ( xlab="Intercept", ylab="Slope") : use <- ab$a %in% range(ab$a) | ab$b %in% range(ab$b) | ab$b==min(ab$b[ab$sex=="M"]) D text(ab[use, 1], ab[use, 2], rownames(ab)[use], pos=4, xpd=TRUE) / mtext(side=3, line=1,"A: Distances", adj=0)  ## 0 Orthodont$logdist <- log(Orthodont$distance) = ab <- coef(lmList(logdist ~ age|Subject, data=Orthodont)) ) ab$sex <- substring(rownames(ab),1,1) # names(ab) <- c("a", "b", "sex")  xlim <- range(ab[,1]) * xlim <- xlim+diff(xlim)*c(-.015, .185)  ylim <- range(ab[,2]) * ylim <- ylim+diff(ylim)*c(-.015, .015) : plot(ab[,1], ab[,2], col=c(F="red", M="blue")[ab$sex], 7 pch=c(F=1, M=3)[ab$sex], xlim=xlim, ylim=ylim, ( xlab="Intercept", ylab="Slope") D text(ab[use, 1], ab[use, 2], rownames(ab)[use], pos=4, xpd=TRUE) = mtext(side=3, line=1,"B: Logarithms of distances", adj=0)  if(device!="")dev.off()  }ў§$џ ўџџџџ ўџџџџ@ џ@ color  џ@ ўўџџџџ џ@ffffff@ffffff?ё™™™™™š?ё™™™™™šў mgp џ@?шў pty s mfrow џ?№@ўўўџџџўўџ lme4ўџџ Orthodont ageўџџ&џ'џў@&ўўџ ab coef lmListџ distance |'џ Subjectўўџ&џўўўџџ(џ sexў substring rownames(џў?№?№ўўџ names(џў џ a b sexўўџ xlim range [(џћ?№ўўўџ2џ +2џ * diff2џў џџ?ŽИQы…Иў?ЧЎzсGЎўўўўџ ylim3џ4џ(џћ@ўўўџ8џ5џ8џ6џ7џ8џў џџ?ŽИQы…Иў?ŽИQы…Иўўўў plot4џ(џћ?№ў4џ(џћ@ў col4џ џ F red M blueўџ(џ.џўў pch4џ џ;џ?№<џ@ўџ(џ.џўў2џ2џ8џ8џџ Intercept ylab Slopeўџ use,џ,џ %in%џ(џ aў3џџ(џAџўўў@џџ(џ bў3џџ(џBџўўўў ==џ(џBџў min4џџ(џBџўCџџ(џ.џў Mўўўўўў text4џ(џ?џ?№ў4џ(џ?џ@ў4џ0џ(џў?џў pos@ xpd ў mtext side@ line?№ A: Distances adjўџџ&џ logdistў logџ&џ+џўўўџ(џ)џ*џџLџ,џ'џ-џўўџ&џўўўџџ(џ.џў/џ0џ(џў?№?№ўўџ1џ(џў џ a b sexўўџ2џ3џ4џ(џћ?№ўўўџ2џ5џ2џ6џ7џ2џў џџ?ŽИQы…Иў?ЧЎzсGЎўўўўџ8џ3џ4џ(џћ@ўўўџ8џ5џ8џ6џ7џ8џў џџ?ŽИQы…Иў?ŽИQы…Иўўўў9џ4џ(џћ?№ў4џ(џћ@ў:џ4џ џ;џ red<џ blueўџ(џ.џўў=џ4џ џ;џ?№<џ@ўџ(џ.џўў2џ2џ8џ8џџ Intercept>џ SlopeўEџ4џ(џ?џ?№ў4џ(џ?џ@ў4џ0џ(џў?џўFџ@Gџ ўHџIџ@Jџ?№ B: Logarithms of distancesKџўџџџ ўџўўў g10.2џ function(device="") { = if(device!="")hardcopy(width=3, height=1.85, device=device) > oldpar <- par(mar = c(4.1, 6.1,1.1,1.1), mgp=c(2.5, 0.75,0))  on.exit(par(oldpar))  require(DAAG); data(science)  attach(science) ; classmeans <- aggregate(like,by=list(PrivPub,Class),mean) 2 names(classmeans) <- c("PrivPub","Class","like")  dim(classmeans)  detach(science)  attach(classmeans) @ boxplot(split(like, PrivPub), xlab = "Class average of score", / boxwex = 0.4, horizontal=TRUE, las=2) + rug(like[PrivPub == "private"], side = 1) * rug(like[PrivPub == "public"], side = 3)  detach(classmeans)  if(device!="")dev.off() }ў§$џ ўџџџџ ўџџ@ џ?§™™™™™šџџўўџџџџ џ@ffffff@ffffff?ё™™™™™š?ё™™™™™šў"џ џ@?шўўўџџџўў require DAAGўџ scienceў attachQџўџ classmeans aggregate like by list PrivPub Classў meanўўџ1џSџў џ PrivPub Class likeўў dimSџў detachQџўRџSџў boxplot splitUџXџўџ Class average of score boxwex?й™™™™™š horizontal  las@ў rug4џUџCџXџ privateўўIџ?№ўbџ4џUџCџXџ publicўўIџ@ў\џSџўџџџ ўџўўў g10.3џ= !function(pnum=c(1,3), device=""){ ` # leg <- c("Class effect vs #", "W/i class var vs #", j # "qnorm(); site effect", "qnorm(); w/i class resids")  require(lme4)  leg <- rep("",4) , mtext3 <- function(item="A", txt=leg[1], = xleft=par()$usr[1]+1.25*par()$cxy[1]){ 1 mtext(side = 3, line = 0.25, item, adj = 0) F mtext(side = 3, line = 0.25, txt, cex = 0.85, at=xleft, adj = 0)  } * science$class <- factor(science$class) , science$school <- factor(science$school) 3 if(device!="")hardcopy(width=3.75, height=3.75, : device=device, pointsize=9) D science1.lmer <- lmer(like ~ sex + PrivPub + (1 | school:class), ? data = science, na.action=na.exclude) O oldpar <- par(mfrow=c(2,2), mar = c(4.6, 4.1, 2.6, 2.1), mgp=c(2.5,0.75,0), ! oma=c(0,0,2,0))  on.exit(par(oldpar)) G rfinfo <- ranef.extract(obj = science1.lmer, term = "school:class", H fun = c("length", "var"), addfact="PrivPub")  num <- rfinfo[, "length"]  use <- num>5  numlabs <- pretty(num) " privpub <- rfinfo[, "PrivPub"] " rf <- rfinfo[, "school:class"] @ plot(sqrt(num), rf, xaxt="n", pch=pnum[as.numeric(privpub)], / xlab="# in class (square root scale)", ) ylab="Estimate of class effect") 5 lines(lowess(sqrt(num[privpub=="private"&num>5]), = rf[privpub=="private"&num>5], f=1.1), lty=2) . lines(lowess(sqrt(num[privpub=="public"]), 6 rf[privpub=="public"], f=1.1), lty=3) 4 axis(1, at=sqrt(numlabs), labels=paste(numlabs)) J mtext3(item="A", txt=leg[1], xleft=par()$usr[1]+1.25*par()$cxy[1])  vars <- rfinfo[, "var"] B plot(sqrt(num), vars, xaxt="n", pch=pnum[as.numeric(privpub)], / xlab="# in class (square root scale)", & ylab="Within class variance") 5 lines(lowess(sqrt(num[privpub=="private"&num>5]), J as.vector(vars)[privpub=="private"&num>5], f=1.1), lty=2) . lines(lowess(sqrt(num[privpub=="public"]), G as.vector(vars)[privpub=="public"], f=1.1), lty=3) 4 axis(1, at=sqrt(numlabs), labels=paste(numlabs)) F mtext3(item="B", txt=leg[2], xleft=par()$usr[1]+1.25*par()$cxy[1]) 4 qqnorm(rf, ylab="Ordered site effects", main="") F mtext3(item="C", txt=leg[3], xleft=par()$usr[1]+1.25*par()$cxy[1]) H qqnorm(residuals(science1.lmer), ylab="Ordered w/i class residuals",  main="") J mtext3(item="D", txt=leg[4], xleft=par()$usr[1]+1.25*par()$cxy[1])   par(mfrow=c(1,1)) 7 par(fig=c(0,1,0.8,1), mar=c(0,0,0,0), mgp=c(0,0,0), # oma=c(0,0,0.5,0), new=TRUE)  plot.new() ) plot.window(xlim=c(0,1), ylim=c(0,1)) C legend(x="top", legend=c("Private ", "Public"), pch=c(1,3),  lwd=c(1,1), lty=2:3, @ xjust=0.5, yjust=0, horiz=TRUE, merge=FALSE, bty="n")  if(device!="")dev.off()  }ў§ pnum џ?№@ў$џ ўџOџ%џўџ leg rep @ўўџ mtext3 function$ item A$ txt4џeџ?№ў$ xleft5џ4џџџў usrў?№ў6џ?є4џџџў cxyў?№ўўўўџHџIџ@Jџ?аiџKџўHџIџ@Jџ?аjџ cex?ы333333 atkџKџўў function(item="A", txt=leg[1], = xleft=par()$usr[1]+1.25*par()$cxy[1]){ 1 mtext(side = 3, line = 0.25, item, adj = 0) F mtext(side = 3, line = 0.25, txt, cex = 0.85, at=xleft, adj = 0)  }ўўџџQџ classў factorџQџ classўўўџџQџ schoolўqџџQџ schoolўўўџџџ ўџџ@ џ@џџ џ@"ўўџ science1.lmer lmerџUџ5џ5џ.џXџў (,џ?№ :rџpџўўўўўџQџ na.action na.excludeўўџџџ$џ џ@@ўџ џ@ffffff@ffffff@ЬЬЬЬЬЭ@ЬЬЬЬЬЭў"џ џ@?шў oma џ@ўўўџџџўўџ rfinfo ranef.extract objsџ term school:class fun џ length varў addfact PrivPubўўџ num4џzџћ lengthўўџ?џ >€џ@ўўџ numlabs pretty€џўўџ privpub4џzџћ PrivPubўўџ rf4џzџћ school:classўў9џ sqrt€џў…џ xaxt n=џ4џdџ as.numeric„џўўџ # in class (square root scale)>џ Estimate of class effectў lines lowess†џ4џ€џ &Cџ„џ privateўџ€џ@ўўўў4џ…џ‹џCџ„џ privateўџ€џ@ўўў f?ё™™™™™šў lty@ў‰џŠџ†џ4џ€џCџ„џ publicўўў4џ…џCџ„џ publicўўŒџ?ё™™™™™šўџ@ў axis?№oџ†џ‚џў labels paste‚џўўgџiџ Ajџ4џeџ?№ўkџ5џ4џџџў usrў?№ў6џ?є4џџџў cxyў?№ўўўўџ vars4џzџћ varўў9џ†џ€џў‘џ‡џ n=џ4џdџˆџ„џўўџ # in class (square root scale)>џ Within class varianceў‰џŠџ†џ4џ€џ‹џCџ„џ privateўџ€џ@ўўўў4џ as.vector‘џў‹џCџ„џ privateўџ€џ@ўўўŒџ?ё™™™™™šўџ@ў‰џŠџ†џ4џ€џCџ„џ publicўўў4џ’џ‘џўCџ„џ publicўўŒџ?ё™™™™™šўџ@ўŽџ?№oџ†џ‚џўџџ‚џўўgџiџ Bjџ4џeџ@ўkџ5џ4џџџў usrў?№ў6џ?є4џџџў cxyў?№ўўўў qqnorm…џ>џ Ordered site effects main ўgџiџ Cjџ4џeџ@ўkџ5џ4џџџў usrў?№ў6џ?є4џџџў cxyў?№ўўўў“џ residualssџў>џ Ordered w/i class residuals”џ ўgџiџ Djџ4џeџ@ўkџ5џ4џџџў usrў?№ў6џ?є4џџџў cxyў?№ўўўўџ$џ џ?№?№ўўџ fig џ?№?щ™™™™™š?№ўџ џў"џ џўyџ џ?рў new ў plot.newў plot.window2џ џ?№ў8џ џ?№ўў legend x topšџ џ Private  Publicў=џ џ?№@ў lwd џ?№?№ўџvџ@@ў xjust?р yjust horiz  merge  bty nўџџџ ўџўўў g10.4џ. function(device=""){ B if(device!="")hardcopy(width=4.25, height=4.25, device=device) 2 oldpar <- par(mar=c(0.5,1,1,1),mgp=c(0,.5,.5))  on.exit(par(oldpar)) 2 plot(c(0,13),c(0,13),type="n",xlab="",ylab="",  axes=F)  eps <- 0.1 $ vines<-function(x=1,y=1,subp=0){ . lines(c(x,x+1,x+1,x,x),c(y,y,y+1,y+1,y)) A points(c(x+.2,x+.8,x+.8,x+.2),c(y+.2,y+.2,y+.8,y+.8),pch=3) ! text(x+.5,y+.5,paste(subp))  }  k<-0 : for(i in c(1,3,5,7)){k<-k+1; vines(1,i,c(3,1,0,2)[k])}  k<-0 : for(i in c(1,3,5,7)){k<-k+1; vines(4,i,c(2,1,0,3)[k])} k <- 0  for(i in c(1,4,4,1)){k<-k+1 + j<-c(9,9,11,11)[k] 1 vines(i,j,c(3,2,1,0)[k])  } 4 lines(c(3,3,NA,3,3),c(0,2.85,NA,10.15,13),lty=2) 4 lines(c(0,0,NA,0,0),c(0,2.85,NA,10.15,13),lty=2) 1 lines(c(8,8,NA,8,8),c(0,4.5,NA,8.5,13),lty=2) - lines(c(0,1.25,NA,6.75,8),rep(0,5),lty=2) . lines(c(0,1.25,NA,6.75,8),rep(13,5),lty=2) 1 lines(c(1,5,5,1,1)+c(-eps,eps,eps,-eps,-eps), 9 c(9,9,12,12,9)+c(-eps,-eps,eps,eps,-eps),lwd=2) 1 lines(c(1,2,2,1,1)+c(-eps,eps,eps,-eps,-eps), 7 c(1,1,8,8,1)+c(-eps,-eps,eps,eps,-eps),lwd=2) 3 lines(c(1,2,2,1,1)+3+c(-eps,eps,eps,-eps,-eps), 7 c(1,1,8,8,1)+c(-eps,-eps,eps,eps,-eps),lwd=2) @ text(0,6.5,"6 meters height artifical shelter belt", srt=90) , text(4,0,"9 meters height shelter belt") . text(4,13,"19 meters height shelter belt") , text(8,6.5,"Willow shelter belt",srt=90) P text(8.5,10.5,"0 Unshaded \n1 Shaded Aug-Dec \n2 Dec-Feb \n3 Feb-May",  adj=0) > text(3,6.5,"16 meters height willow shelter belt", srt=90) + lines(c(8.25,8.75),c(13,13-sqrt(3)*.5)) ! lines(rep(8.25,2),c(12.6,13)) , lines(c(8.25,8.25+sqrt(3)/5),c(13,12.8))  text(8.85,12.65,"N")  if(device!="")dev.off()  }ў§$џ ўџџџџ ўџџ@ џ@џџўўџџџџ џ?р?№?№?№ў"џ џ?р?рўўўџџџўў9џ џ@*ў џ@*ў type nџ >џ  axes;џўџ eps?Й™™™™™šўџ vineshџ›џ?№ y?№ subpўџ‰џ џ›џ5џ›џ?№ў5џ›џ?№ў›џ›џў џЇџЇџ5џЇџ?№ў5џЇџ?№ўЇџўў points џ5џ›џ?Щ™™™™™šў5џ›џ?щ™™™™™šў5џ›џ?щ™™™™™šў5џ›џ?Щ™™™™™šўў џ5џЇџ?Щ™™™™™šў5џЇџ?Щ™™™™™šў5џЇџ?щ™™™™™šў5џЇџ?щ™™™™™šўў=џ@ўEџ5џ›џ?рў5џЇџ?рўџЈџўўў function(x=1,y=1,subp=0){ . lines(c(x,x+1,x+1,x,x),c(y,y,y+1,y+1,y)) A points(c(x+.2,x+.8,x+.8,x+.2),c(y+.2,y+.2,y+.8,y+.8),pch=3) ! text(x+.5,y+.5,paste(subp))  }ўўџ kў for i џ?№@@@ўџџЊџ5џЊџ?№ўўІџ?№Ќџ4џ џ@?№@ўЊџўўўўџЊџўЋџЌџ џ?№@@@ўџџЊџ5џЊџ?№ўўІџ@Ќџ4џ џ@?№@ўЊџўўўўџЊџўЋџЌџ џ?№@@?№ўџџЊџ5џЊџ?№ўўџ j4џ џ@"@"@&@&ўЊџўўІџЌџ­џ4џ џ@@?№ўЊџўўўў‰џ џ@@ €@@ў џ@ЬЬЬЬЬЭ €@$LЬЬЬЬЭ@*ўџ@ў‰џ џ €ў џ@ЬЬЬЬЬЭ €@$LЬЬЬЬЭ@*ўџ@ў‰џ џ@ @  €@ @ ў џ@ €@!@*ўџ@ў‰џ џ?є €@@ ўfџ@ўџ@ў‰џ џ?є €@@ ўfџ@*@ўџ@ў‰џ5џ џ?№@@?№?№ў џџЅџўЅџЅџџЅџўџЅџўўў5џ џ@"@"@(@(@"ў џџЅџўџЅџўЅџЅџџЅџўўўœџ@ў‰џ5џ џ?№@@?№?№ў џџЅџўЅџЅџџЅџўџЅџўўў5џ џ?№?№@ @ ?№ў џџЅџўџЅџўЅџЅџџЅџўўўœџ@ў‰џ5џ5џ џ?№@@?№?№ў@ў џџЅџўЅџЅџџЅџўџЅџўўў5џ џ?№?№@ @ ?№ў џџЅџўџЅџўЅџЅџџЅџўўўœџ@ўEџ@ &6 meters height artifical shelter belt srt@V€ўEџ@ 9 meters height shelter beltўEџ@@* 19 meters height shelter beltўEџ@ @ Willow shelter beltЎџ@V€ўEџ@!@% 80 Unshaded 1 Shaded Aug-Dec 2 Dec-Feb 3 Feb-MayKџўEџ@@ $16 meters height willow shelter beltЎџ@V€ў‰џ џ@ €@!€ў џ@*џ@*6џ†џ@ў?рўўўў‰џfџ@ €@ў џ@)333333@*ўў‰џ џ@ €5џ@ € /†џ@ў@ўўў џ@*@)™™™™™šўўEџ@!Г33333@)LЬЬЬЬЭ Nўџџџ ўџўўў g10.5џ) function(device="") { @ if(device!="")hardcopy(width=3.75, height=2.25, device=device) 3 oldpar<-par(mar=c(4.5,6.1,1.1,1.1), mfrow=c(1,1))  on.exit(par(oldpar))  attach(kiwishade) 9 kiwimeans <- aggregate(yield,by=list(block,shade),mean) 4 names(kiwimeans) <- c("block","shade","meanyield")  detach(kiwishade) ; plotmeans.lm <- lm(meanyield~block+shade, data=kiwimeans) 0 effects <- predict(plotmeans.lm, type="terms") 9 kiwishade.lm <- lm(yield ~ block*shade, data=kiwishade) . y <- c(effects[,"block"]/sqrt(2) * sqrt(16), / effects[,"shade"]/sqrt(3) * sqrt(12), 3 residuals(plotmeans.lm)/sqrt(6) * sqrt(4), ! residuals(kiwishade.lm)/  sqrt(12)) " n <- rep(4:1, c(12, 12, 12, 48)) < gps <- rep(c("block effect\n(ms=86.2)", "shade\n(464.8)", B "plot\n(20.9)", "vine\n(12.2)"), c(12, 12, 12, 48)) ? gps <- factor(gps, levels = rev(c("block effect\n(ms=86.2)", 8 "shade\n(464.8)", "plot\n(20.9)", ( "vine\n(12.2)"))) $ gps.sd <- sapply(split(y,gps), sd) & gps.av <- sapply(split(y,gps), mean) M plot(range(y), range(n)+c(-0.5, 0.5), xlab="", ylab="", yaxt="n", type="n")  text(y, n+0.15, "|") un <- 1:4 B sapply(un, function(j){lines(gps.av[j]+c(-gps.sd[j], gps.sd[j]), 8 rep(j-0.15,2), col="gray") 9 lines(rep(gps.av[j],2)-gps.sd[j], > j-0.15+c(-.06, .06), col="gray") 9 lines(rep(gps.av[j],2)+gps.sd[j], > j-0.15+c(-.06, .06), col="gray")  })  mtext(side=1,line=3, M text="Variation in Yield (kg)\n(Add to grand mean of yield = 96.53)") par(las=2) % axis(2, at=1:4, labels=levels(gps))  if(device!="")dev.off() }ў§$џ ўџџџџ ўџџ@ џ@џџўўџџџџ џ@@ffffff?ё™™™™™š?ё™™™™™šў$џ џ?№?№ўўўџџџўўRџ kiwishadeўџ kiwimeansTџ yieldVџWџ block shadeўZџўўџ1џВџў џ block shade meanyieldўў\џБџўџ plotmeans.lm lmџ meanyield5џДџЕџўўџВџўўџ effects predictЖџЃџ termsўўџ kiwishade.lmЗџџГџ6џДџЕџўўџБџўўџЇџ џ6џЏџ4џЙџћ blockў†џ@ўў†џ@0ўў6џЏџ4џЙџћ shadeў†џ@ўў†џ@(ўў6џЏџ•џЖџў†џ@ўў†џ@ўўЏџ•џЛџў†џ@(ўўўўџ nfџvџ@?№ў џ@(@(@(@Hўўўџ gpsfџ џ block effect (ms=86.2) shade (464.8) plot (20.9) vine (12.2)ў џ@(@(@(@HўўўџНџqџНџ levels rev џ block effect (ms=86.2) shade (464.8) plot (20.9) vine (12.2)ўўўўџ gps.sd sapply^џЇџНџў sdўўџ gps.avСџ^џЇџНџўZџўў9џ3џЇџў5џ3џМџў џџ?рў?рўўџ >џ  yaxt nЃџ nўEџЇџ5џМџ?У333333ў |ўџ unvџ?№@ўўСџХџhџ­џћўџ‰џ5џ4џУџ­џў џџ4џРџ­џўў4џРџ­џўўўfџџ­џ?У333333ў@ў:џ grayў‰џџfџ4џУџ­џў@ў4џРџ­џўў5џџ­џ?У333333ў џџ?ЎИQы…Иў?ЎИQы…Иўў:џ grayў‰џ5џfџ4џУџ­џў@ў4џРџ­џўў5џџ­џ?У333333ў џџ?ЎИQы…Иў?ЎИQы…Иўў:џ grayўў 5function(j){lines(gps.av[j]+c(-gps.sd[j], gps.sd[j]), 8 rep(j-0.15,2), col="gray") 9 lines(rep(gps.av[j],2)-gps.sd[j], > j-0.15+c(-.06, .06), col="gray") 9 lines(rep(gps.av[j],2)+gps.sd[j], > j-0.15+c(-.06, .06), col="gray")  }ўўHџIџ?№Jџ@Eџ џ Residuals (level 2) scalesWџ›џWџ alternating ўўšџWџ topWџ~џ textGrob argsWџ label A›џ just leftўўў keyWџ›џ?Й™™™™™šЇџ?ьzсGЎ{ЉџWџ=џvџ?№@ўўEџWџџОџџБџ shadeўўў columns@ўўўџгџ position џ?рЃз =pЄ?№?№ўўџВџ withБџTџГџVџWџДџДџЕџЕџўZџўўўџ4џ1џВџў@ў avyieldўџ kiwimeans.lmertџџ avyield5џЕџuџ,џ?№ДџўўўўџВџўўџ plotres•џфџўўџ plothatеџфџўўџ pk1дџџцџ,џчџДџўўзџ џ@?№ўиџWџnџ?№ў=џvџ?№@ўnџ?ѓ333333жџЕџШџ >џ Plot effectsџВџйџWџ›џWџкџ ўўšџWџлџWџ~џмџнџWџоџ B›џпџ leftўўўрџWџ›џ?Й™™™™™šЇџ?ьzсGЎ{ЉџWџ=џvџ?№@ўўEџWџџОџџБџ shadeўўўсџ@ўџ 1Level 1 fitted values (Treatment + block effects)ўўџшџ newpage тџ џ?№?оИQы…Иўўџџџ ўџўў invisibleўў g10.7џ) function(device=""){  library(lattice)  library(grid)  library(nlme) ? if(device!="")hardcopy(device=device, width=4.25, height=4, 1 color=TRUE, pointsize=10) < oldpar <- par(mgp=c(2.25, .5,0), mar=c(4.1,4.1,1.6,1.1), , pty="s", cex=1, cex.lab=1)  on.exit(par(oldpar))  par(fig=c(0, 0.925, 0, 1)) + plot(o2 ~ wattsPerKg, data=humanpower1,  pch=(1:5)[unlist(id)], # col=palette()[unlist(id)], # xlab="Watts per kilogram", E ylab=expression("Oxygen intake ("*ml.min^{-1}*.kg^{-1}*")")) = hp.lmList <- lmList(o2 ~ wattsPerKg|id, data=humanpower1) I sapply(1:length(hp.lmList), function(i)abline(hp.lmList[[i]], col=i)) - mtext(side=3, line=0.25, "A", adj=-0.165) 7 par(fig=c(0.6, 1, 0.025, 0.525), new=TRUE, cex=0.8) 3 coefs <- data.frame(t(sapply(hp.lmList, coef))) + names(coefs) <- c("Intercept", "Slope") B par(pty="s", tck=-0.025, xpd=TRUE, cex.axis=0.8, cex.lab=0.75,  mgp=c(1.25,0.25,0)) : plot(Slope ~ Intercept, data=coefs, pch=1:5, type="n")  xy <- par()$usr  chw <- par()$cxy[1]  chh <- par()$cxy[2] I rect(xy[1]-3.25*chw,xy[3]-2.75*chh,xy[2]+chw,xy[4]+chh, col="gray80") axis(1) axis(2) box() : with(coefs, points(Slope ~ Intercept, cex=1, pch=1:5))  par(xpd=F) 2 abline(lm(Slope ~ Intercept, data=coefs)$coef)  par(xpd=TRUE, cex=1) - text(xy[1]-2.25*chw, xy[4]+0.25*chh, "B") / mtext(side=1,line=1.5,"Intercept", cex=0.8) + mtext(side=2,line=1.5,"Slope", cex=0.8) ) par(fig=c(0,1,0,1), cex=1, xpd=FALSE)  if(device!="")dev.off()  }ў§џ ўџџџўџШџўџ nlmeўџџџ ўџџџџ@ џ@!џ  џ@$ўўџџџ"џ џ@?рўџ џ@ffffff@ffffff?љ™™™™™š?ё™™™™™šў#џ snџ?№ cex.lab?№ўўџџџўўџ–џ џ?э™™™™™š?№ўў9џџ o2 wattsPerKgўџ humanpower1=џ4џuџvџ?№@ўў unlist idўў:џ4џ paletteўёџђџўўџ Watts per kilogram>џ expression6џ6џ6џ Oxygen intake ( ^ ml.minџџ?№ўўўўѕџ .kgџџ?№ўўўў )ўўўџ hp.lmList*џџюџ,џяџђџўўџ№џўўСџvџ?№ lengthјџўўhџЌџћў abline [[јџЌџў:џЌџў (function(i)abline(hp.lmList[[i]], col=i)ўўHџIџ@Jџ?а AKџџ?ХИQы…ўўџ–џ џ?у333333?№?™™™™™™š?рЬЬЬЬЬЭў—џ nџ?щ™™™™™šўџ coefs data.frame tСџјџ)џўўўўџ1џќџў џ Intercept Slopeўўџ#џ s tckџ?™™™™™™šўGџ  cex.axis?щ™™™™™šэџ?ш"џ џ?є?аўў9џџ Slope Interceptўџќџ=џvџ?№@ўЃџ nўџ xyџџўlџўўџ chw4џџџўmџў?№ўўџ chh4џџџўmџў@ўў rectџ4џџ?№ў6џ@ џўўџ4џџ@ў6џ@џўў5џ4џџ@ўџў5џ4џџ@ўџў:џ gray80ўŽџ?№ўŽџ@ў boxўуџќџЉџџџџўnџ?№=џvџ?№@ўўўџGџ;џўњџџЗџџџџўџќџў)џўўџGџ nџ?№ўEџџ4џџ?№ў6џ@џўў5џ4џџ@ў6џ?аџўў BўHџIџ?№Jџ?ј Interceptnџ?щ™™™™™šўHџIџ@Jџ?ј Slopenџ?щ™™™™™šўџ–џ џ?№?№ўnџ?№Gџ ўџџџ ўџўўў g10.8џ function(device=""){  library(lattice)  library(grid) < if(device!="")hardcopy(device=device, width=4, height=6, 1 trellis=TRUE, color=TRUE) E trellis.par.set(layout.heights=list(key.top=0.25, axis.top=0.65)) # hp1.lme <- lme(o2 ~ wattsPerKg, 8 random=~ -1 +I(wattsPerKg-2.77) | id, $ data=humanpower1)  hat2 <- fitted(hp1.lme) D hp1.plt1 <- xyplot(o2 ~ wattsPerKg, groups=id, data=humanpower1, F panel=function(x,y,subscripts,groups,hat2,...){ / u <- lm(y ~ groups*x); ) hat <- fitted(u) K panel.superpose(x,hat,subscripts,groups, type="l") G panel.superpose(x, y=hat2, subscripts, groups, 9 type="l", lty=2)  }, 1 xlab="Watts per kilogram", S ylab=expression("Oxygen intake ("*ml.min^{-1}*.kg^{-1}*")"), V legend=list(top=list(fun=textGrob, args=list(label="A", x=0))), + hat2=hat2, aspect=1) + print(hp1.plt1, position=c(0,0.42,1,1))  res <- resid(hp1.lme) 3 hp1.plt2 <- xyplot(res ~ wattsPerKg, groups=id, C data=humanpower1, xlab="Watts per kilogram", : ylab="Residuals from random lines", ` legend=list(top=list(fun=textGrob, args=list(label="B", x=0))), type="l") ? print(hp1.plt2, position=c(0.025, 0,1,0.42), newpage=FALSE)  if(device!="")dev.off()  }ў§џ ўџџџўџШџўџџџ ўџџџџ@ џ@ џ !џ ўўЩџЪџWџЫџ?аЬџ?фЬЬЬЬЬЭўўџ hp1.lme lmeџюџяџў randomџ,џ5џџ?№ў Iџяџ@(ѕТ\)ўўўђџўўџ№џўўџ hat2еџ џўўџ hp1.plt1дџџюџяџўжџђџџ№џ panelhџ›џћЇџћ subscriptsћжџћ џћ ...ћўџџ uЗџџЇџ6џжџ›џўўўўџ hatеџџўў panel.superpose›џџџжџЃџ lўџ›џЇџ џџжџЃџ lџ@ўў )function(x,y,subscripts,groups,hat2,...){ / u <- lm(y ~ groups*x); ) hat <- fitted(u) K panel.superpose(x,hat,subscripts,groups, type="l") G panel.superpose(x, y=hat2, subscripts, groups, 9 type="l", lty=2)  }ўџ Watts per kilogram>џєџ6џ6џ6џ Oxygen intake (ѕџіџџџ?№ўўўўѕџїџџџ?№ўўўў )ўўšџWџлџWџ~џмџнџWџоџ A›џўўў џ џ aspect?№ўўџџтџ џ?ксGЎzс?№?№ўўџ res resid џўўџ hp1.plt2дџџџяџўжџђџџ№џџ Watts per kilogram>џ Residuals from random linesšџWџлџWџ~џмџнџWџоџ B›џўўўЃџ lўўџџтџ џ?™™™™™™š?№?ксGЎzсўщџ ўџџџ ўџўўў g10.9џ function(device="", log=2){  library(lattice)  library(grid) B if(device!="")hardcopy(device=device, width=5.25, height=3.25, G trellis=TRUE, color=FALSE, pointsize=c(7,5)) 7 plt <- xyplot(distance ~ age | Subject, groups=Sex, 2 data=Orthodont, type=c("p","r"), E par.strip.text=list(cex=0.75), scale=list(log=log), ! layout=c(11,3))  print(plt)  if(device!="")dev.off()  }ў§$џ Mџ@ўџџџўџШџўџџџ ўџџџџ@ џ@  џ !џ  џ џ@@ўўўџ pltдџџ+џ,џ'џ-џўўжџ Sexџ&џЃџ џ p rўиџWџnџ?шў scaleWџMџMџўзџ џ@&@ўўўџџўџџџ ўџўўў gdumpџ 7function(fnam=NULL, prefix="~/r-book/ed2/figures/figs", / splitchar="/ch", xtras=c("hardcopy", : "renum.fun","renum.files")){  if(is.null(fnam)){  path <- getwd() 7 pathtag <- strsplit(path, "/ch", fixed=TRUE)[[1]] 5 fnam <- paste(prefix, pathtag[length(pathtag)], ! ".R", sep="")  } - else fnam <- paste(prefix, fnam, sep="/") C objnames <- c(objects(pattern="^g", envir=sys.frame(0)), xtras) & cat("\nDump to file:", fnam, "\n")  print(objnames)  dump(objnames, fnam)  }ў§ fnamў prefix ~/r-book/ed2/figures/figs splitchar /ch xtras џ hardcopy renum.fun renum.filesўўџџ is.nullџўџџЧџ getwdўўџ pathtagћџ strsplitЧџ /ch fixed ў?№ўўџџџџ4џ$џљџ$џўў .R sep ўўўџџџџџ'џ /ўўўџ objnames џ objects pattern ^g envir sys.frameўў!џўў cat  Dump to file:џ  ўџ(џў dump(џџўў gfileџ& 5function(width=3.75, height=3.75, color=F, trellis=F, H device=c("","pdf","ps"), path="", pointsize=c(8,5), horiz=F){  ## 1 x 1: 2.25" x 2.25"  ## 2 x 2: 2.75" x 2.75" D ## 3 x 3: 3.75" x 3.75" or 3.25" x 3.25" for simple scatterplots  ## 1 x 2: 4" x 2.25"  ## 2 x 3: 4" x 2.8"  ## 3 x 4: 4.5" x 3.25 ) if(!trellis)pointsize <- pointsize[1]  funtxt <- sys.call(1) @ fnam <- strsplit(as.character(funtxt), "(", fixed=T)[[1]][1] * dotsplit <- strsplit(fnam, "\\.")[[1]] , dotsplit[1] <- substring(dotsplit[1], 2) G prefix1 <- paste(if(nchar(dotsplit[1])==1)"0" else "", dotsplit[1],  sep="") G prefix2 <- paste(if(nchar(dotsplit[2])==1)"0" else "", dotsplit[2],  sep="") 6 if(device=="")stop("No device has been specified") 3 suffix <- switch(device, ps=".eps", pdf=".pdf") = fnam <- paste("~/r-book/second/Art/",prefix1,"-",prefix2, ! suffix, sep="")  print(fnam)  dev.out <- device[1] 6 dev.fun <- switch(dev.out, pdf=pdf, ps=postscript)  if(trellis){  library(lattice) > trellis.device(file=fnam, device=dev.fun, color = color, = width=width, height=height, horiz=horiz) L trellis.par.set(fontsize=list(text=pointsize[1], points=pointsize[2]))  } else  if (dev.out!=""){  print(c(width, height)) + dev.fun(file=fnam, paper="special", , enc="MacRoman", horiz=horiz, C width=width, height=height, pointsize=pointsize[1])  }  }ў§$џ@$ џ@!џ;џ џ;џ$џ џ  pdf psўЧџ  џ џ@ @ўŸџ;џўџџаџ џўџ џ4џ џ?№ўўўџ funtxt sys.call?№ўўџџ4џћџ%џ as.character0џў (&џ џў?№ў?№ўўџ dotsplitћџ%џџ \.ў?№ўўџ4џ3џ?№ў/џ4џ3џ?№ў@ўўџ prefix1џџCџ nchar4џ3џ?№ўў?№ў 0 ў4џ3џ?№ў'џ ўўџ prefix2џџCџ5џ4џ3џ@ўў?№ў 0 ў4џ3џ@ў'џ ўўџCџџ ў stop No device has been specifiedўўџ suffix switchџ ps .eps pdf .pdfўўџџџ ~/r-book/second/Art/4џ -6џ8џ'џ ўўџџўџ dev.out4џџ?№ўўџ dev.fun9џ<џ;џ;џ:џ postscriptўўџ џџџџў trellis.device fileџџ=џ!џ!џџџ џ џŸџŸџўЩџ fontsizeWџEџ4џ џ?№ўЉџ4џ џ@ўўўўџџ<џ ўџџ џџ џўў=џ@џџ paper special enc MacRomanŸџŸџџџ џ џ џ4џ џ?№ўўўўўў gfocus.demoџ$ function(device=""){  library(lattice)  library(grid) Q if(device!="")hardcopy(device=device, width=4, height=2.25, trellis=TRUE, ' color=TRUE) H trellis.par.set(layout.heights=list(key.top=0.25, axis.top=0.5)) H hp1.plt1 <- xyplot(o2 ~ wattsPerKg, groups=id, data=humanpower1, 9 panel=function(x,y,subscripts,groups,...){ ' u <- lm(y~groups*x); # hat <- fitted(u) 9 panel.superpose(x,y,subscripts,groups) E panel.superpose(x,hat,subscripts,groups, type="l")  }, F## key=simpleKey(text=rep("",5), lines=TRUE, columns=5), ) xlab="Watts per kilogram", K ylab=expression("Oxygen intake ("*ml.min^{-1}*.kg^{-1}*")"), N legend=list(top=list(fun=textGrob, args=list(label="A", x=0)))) / print(hp1.plt1, position=c(0,0,.535,1)) J u <- lme(o2 ~ wattsPerKg, random=~wattsPerKg|id, data=humanpower1) H hp1.plt2 <- xyplot(o2 ~ wattsPerKg, groups=id, data=humanpower1, 9 panel=function(x,y,subscripts,groups,...){ ' u <- lm(y~groups*x); # hat <- fitted(u) E panel.superpose(x,hat,subscripts,groups, type="l")  }, 2 xlab="Watts per kilogram", ylab="", N legend=list(top=list(fun=textGrob, args=list(label="B", x=0))))  hat <- fitted(u) ? print(hp1.plt2, position=c(.465, 0,1,1), newpage=FALSE) / trellis.focus("panel", row=1, column=1) & arglist <- trellis.panelArgs() H panel.superpose(x=arglist$x,y=hat,subscripts=arglist$subscripts, A groups=arglist$groups, , type="l", lty=2) ! trellis.unfocus()  if(device!="")dev.off()  }ў§џ ўџџџўџШџўџџџ ўџџџџ@ џ@ џ !џ ўўЩџЪџWџЫџ?аЬџ?рўўџџдџџюџяџўжџђџџ№џџhџ›џћЇџћџћжџћџћўџџџЗџџЇџ6џжџ›џўўўўџџеџџўўџ›џЇџџжџўџ›џџџжџЃџ lўў $function(x,y,subscripts,groups,...){ ' u <- lm(y~groups*x); # hat <- fitted(u) 9 panel.superpose(x,y,subscripts,groups) E panel.superpose(x,hat,subscripts,groups, type="l")  }ўџ Watts per kilogram>џєџ6џ6џ6џ Oxygen intake (ѕџіџџџ?№ўўўўѕџїџџџ?№ўўўў )ўўšџWџлџWџ~џмџнџWџоџ A›џўўўўўџџтџ џ?сИQы…?№ўўџџ џџюџяџў џџ,џяџђџўўџ№џўўџџдџџюџяџўжџђџџ№џџhџ›џћЇџћџћжџћџћўџџџЗџџЇџ6џжџ›џўўўўџџеџџўўџ›џџџжџЃџ lўў $function(x,y,subscripts,groups,...){ ' u <- lm(y~groups*x); # hat <- fitted(u) E panel.superpose(x,hat,subscripts,groups, type="l")  }ўџ Watts per kilogram>џ šџWџлџWџ~џмџнџWџоџ B›џўўўўўџџеџџўўџџтџ џ?нТ\(ѕУ?№?№ўщџ ў trellis.focus panel row?№ column?№ўџ arglist trellis.panelArgsўўџ›џџHџ›џўЇџџџџHџџўжџџHџжџўћЃџ lџ@ў trellis.unfocusўџџџ ўџўўў gsaveџ 7function(fnam=NULL, prefix="~/r-book/ed2/figures/figs", L splitchar="/ch", xtras=c("hardcopy", "renum.fun","renum.files")){  if(is.null(fnam)){  path <- getwd() 7 pathtag <- strsplit(path, "/ch", fixed=TRUE)[[1]] 5 fnam <- paste(prefix, pathtag[length(pathtag)], % ".RData", sep="")  } - else fnam <- paste(prefix, fnam, sep="/") C objnames <- c(objects(pattern="^g", envir=sys.frame(0)), xtras) & cat("\nDump to file:", fnam, "\n")  print(objnames) " save(list=objnames, file=fnam)  }ў§џўџ ~/r-book/ed2/figures/figs џ /ch!џ џ hardcopy renum.fun renum.filesўўџџ"џџўџџЧџ#џўўџ$џћџ%џЧџ /ch&џ ў?№ўўџџџџ4џ$џљџ$џўў .RData'џ ўўўџџџџџ'џ /ўўўџ(џ џ)џ*џ ^g+џ,џўў!џўў-џ  Dump to file:џ  ўџ(џў saveWџ(џ@џџўў gtestџ function(device=""){  library(lattice)  library(grid) ? if(device!="")trellis.device(pdf,width=3, height=3.25, A color=TRUE, file="test.pdf") < plt <- xyplot(uptake ~ conc, groups=Plant, data=CO2)  print(plt) @ trellis.focus("panel", row=1, column=1, highlight=FALSE) # arglist=trellis.panelArgs()  arglist$type <- "l" 1 do.call("panel.superpose", args=arglist) ! trellis.unfocus()  if(device!="")dev.off()  }ў§џ ўџџџўџШџўџџџ ў?џ;џџ@ џ@ !џ @џ test.pdfўўџџдџџ uptake concўжџ Plantџ CO2ўўџџўEџ panelFџ?№Gџ?№ highlight ў =HџIџўўџџHџЃџў lў do.call panel.superposeнџHџўJџўџџџ ўџўўўџџ4 =function(width=3.75, height=3.75, color=FALSE, trellis=FALSE, H device=c("","pdf","ps"), path="~/r-book/ed2/Art/", file=NULL, D format=c("nn-nn", "name"), split="\\.", pointsize=c(8,4),  fonts=NULL,  horiz=FALSE, ...){ ) if(!trellis)pointsize <- pointsize[1]  funtxt <- sys.call(1) B nam <- strsplit(as.character(funtxt), "(", fixed=TRUE)[[1]][1] 3 suffix <- switch(device, ps=".eps", pdf=".pdf") N if(is.character(path) & nchar(path)>1 & substring(path, nchar(path))!="/") & path <- paste(path, "/", sep="") - if(is.null(file)) if(format[1]=="nn-nn"){ C if(!is.null(split))dotsplit <- strsplit(nam, split)[[1]] else  dotsplit <- nam 8 if(length(dotsplit)==1)dotsplit <- c("", dotsplit) E nn2 <- paste(if(nchar(dotsplit[2])==1)"0" else "", dotsplit[2],  sep="")  if(nchar(dotsplit[1])>0){ O numstart <- which(unlist(strsplit(dotsplit[1], "")) %in% paste(0:9))[1] / nn1 <- substring(dotsplit[1], numstart) G nn1 <- paste(if(nchar(nn1) == 1) "0" else "", nn1, "-", sep="")  } else nn1 <- "" % file <- paste(nn1, nn2, sep="")  } else file <- nam L if(nchar(file)>4 & substring(file, nchar(file)-nchar(suffix)+1)==suffix)  suffix <- "" - file <- paste(path, file, suffix, sep="") : print(paste("Output will be directed to file:", file))  dev.out <- device[1] 6 dev.fun <- switch(dev.out, pdf=pdf, ps=postscript)  if(trellis){  library(lattice)  if(device=="ps") 1 trellis.device(file=file, device=dev.fun, ? color = color, horiz=horiz, fonts=fonts, < width=width, height=height, ...) else < trellis.device(file=file, device=dev.fun, fonts=fonts, D color = color, width=width, height=height, ...) R trellis.par.set(list(fontsize=list(text=pointsize[1], points=pointsize[2]))) } else  if (dev.out!=""){  print(c(width, height))  if(device=="ps") F dev.fun(file=file, paper="special", horiz=horiz, fonts=fonts, M width=width, height=height, pointsize=pointsize[1], ...) else 6 dev.fun(file=file, paper="special", fonts=fonts, L width=width, height=height, pointsize=pointsize[1], ...)  } D if(trellis)trellis.par.set(list(fontsize=list(text=pointsize[1], < points=pointsize[2])))  }ў§џ@ џ@!џ  џ џ џ  pdf psўЧџ ~/r-book/ed2/Art/@џў format џ nn-nn nameў^џ \. џ џ@ @ў fontsўŸџ џћў srcref  ) srcfileђ encoding native.enc timestampAбрЧзРpџ POSIXt POSIXctў filename /tmp/johnm.hardcopy.R wd /Users/johnm/r/ch10ўўpџ srcfileўpџ srcrefў XџYџpџ srcrefў   BXџYџpџ srcrefў   3XџYџpџ srcrefў   &XџYџpџ srcrefў  XџYџpџ srcrefў XџYџpџ srcrefў -XџYџpџ srcrefў :XџYџpџ srcrefў XџYџpџ srcrefў 6XџYџpџ srcrefў  2XџYџpџ srcrefў 34<XџYџpџ srcrefўXџYџўџџаџ џўџ џ4џ џ?№ўўўџ0џ1џ?№ўўџ nam4џћџ%џ2џ0џў (&џ ў?№ў?№ўўџ8џ9џџ:џ .eps;џ .pdfўўџ‹џ‹џ is.characterЧџўџ5џЧџў?№ўўџ/џЧџ5џЧџўў /ўўџЧџџЧџ /'џ ўўўџ"џ@џўџCџ4џUџ?№ў nn-nnўWџ XџYџpџ srcrefў 8XџYџpџ srcrefў XџYџpџ srcrefў XџYџpџ srcrefў %XџYџpџ srcrefўXџYџўџџаџ"џ^џўўџ3џћџ%џ^џ^џў?№ўўџ3џ^џўўџCџљџ3џў?№ўџ3џ џ 3џўўўџ nn2џџCџ5џ4џ3џ@ўў?№ў 0 ў4џ3џ@ў'џ ўўџџ5џ4џ3џ?№ўўўWџ  OXџYџpџ srcrefў  /XџYџpџ srcrefў  GXџYџpџ srcrefўXџYџўџџ numstart4џ which@џёџ%џ4џ3џ?№ў ўўџvџ@"ўўўў?№ўўџ nn1/џ4џ3џ?№ўaџўўџcџџџCџ5џcџў?№ў 0 ўcџ -'џ ўўўџcџ ўўџ@џџcџ`џ'џ ўўўџ@џ^џўўўџ‹џџ5џ@џў@ўCџ/џ@џ5џџ5џ@џў5џ8џўў?№ўў8џўўџ8џ ўўџ@џџЧџ@џ8џ'џ ўўџџ Output will be directed to file:@џўўџ<џ4џџ?№ўўџ=џ9џ<џ;џ;џ:џ>џўўџ џWџ !!XџYџpџ srcrefў "'DXџYџpџ srcrefў ))RXџYџpџ srcrefўXџYџўџџџўџCџџ psў?џ@џ@џџ=џ!џ!џŸџŸџVџVџџџ џ џџў?џ@џ@џџ=џVџVџ!џ!џџџ џ џџўўЩџWџAџWџEџ4џ џ?№ўЉџ4џ џ@ўўўўўџџ<џ ўWџ ,,XџYџpџ srcrefў -1FXџYџpџ srcrefўXџYџўџџ џџ џўўџCџџ psў=џ@џ@џBџ specialŸџŸџVџVџџџ џ џ џ4џ џ?№ўџў=џ@џ@џBџ specialVџVџџџ џ џ џ4џ џ?№ўџўўўўўџ џЩџWџAџWџEџ4џ џ?№ўЉџ4џ џ@ўўўўўў renum.funџ :function(from.prefix=NULL, to.prefix="g",from=4:1, to=4:1, % splitchars="/ch", doit=F){  path <- getwd() : pathtag <- strsplit(path, splitchars, fixed=TRUE)[[1]] + if(length(pathtag)==1)endbit <- "" else & endbit <- pathtag[length(pathtag)] 1 to.prefix <- paste(to.prefix, endbit, sep="") 4 if(is.null(from.prefix))from.prefix <- to.prefix  for(i in 1:length(to)) M {txt<-paste(to.prefix,".",to[i]," <- ", from.prefix,".",from[i],sep="") 7 if(doit)eval(parse(text=txt),envir=sys.frame(0))  print(txt) " if(from.prefix!=to.prefix){ B rm.txt <- paste("rm(",from.prefix,".",from[i],")",sep="") < if(doit)eval(parse(text=rm.txt),envir=sys.frame(0))  print(rm.txt)  }  }  }ў§$ from.prefixў to.prefix g$ fromvџ@?№ў$ tovџ@?№ў splitchars /ch$ doit;џўџџЧџ#џўўџ$џћџ%џЧџiџ&џ ў?№ўўџCџљџ$џў?№ўџ endbit ўџkџ4џ$џљџ$џўўўўџfџџfџkџ'џ ўўџ"џeџўџeџfџўўЋџЌџvџ?№љџhџўўџџjџџfџ .4џhџЌџў  <- eџ .4џgџЌџў'џ ўўџjџ eval parseEџjџў+џ,џўўўџjџўџџeџfџўџџ rm.txtџ rm(eџ .4џgџЌџў )'џ ўўџjџlџmџEџnџў+џ,џўўўџnџўўўўўў renum.filesџ Nfunction(from.prefix="~/r-book/second/Art/", to.prefix="~/r-book/second/Art/", ' from=20:7, to=21:8, doit=F){  path <- getwd() 5 pathtag <- strsplit(path, "/ch", fixed=TRUE)[[1]] & endbit <- pathtag[length(pathtag)] 2 if(nchar(endbit)==2)chap <- paste(endbit) else ' chap <- paste("0",endbit,sep="") 8 from.prefix <- paste(from.prefix, chap, "-", sep="") 4 to.prefix <- paste(to.prefix, chap, "-", sep="")  for(i in 1:length(from)){ 8 if (from[i]<=9) ltext <- paste("0",from[i],sep="") " else ltext <- paste(from[i]) 4 if (to[i]<=9) rtext <- paste("0",to[i],sep="") , else rtext <- paste(to[i]) 8 txt<-paste("mv ", from.prefix, ltext, ".eps", " ", 2 to.prefix, rtext, ".eps", sep="") ; backup<-paste("cp ", from.prefix, ltext, ".eps", " ", # "archive", sep="")  if(doit)system(backup)  if(doit)system(txt)  print(backup)  print(txt)  }  }ў§eџ ~/r-book/second/Art/fџ ~/r-book/second/Art/gџvџ@4@ўhџvџ@5@ ўjџ;џўџџЧџ#џўўџ$џћџ%џЧџ /ch&џ ў?№ўўџkџ4џ$џљџ$џўўўџCџ5џkџў@ўџ chapџkџўўџpџџ 0kџ'џ ўўўџeџџeџpџ -'џ ўўџfџџfџpџ -'џ ўўЋџЌџvџ?№љџgџўўџџ <=4џgџЌџў@"ўџ ltextџ 04џgџЌџў'џ ўўџrџџ4џgџЌџўўўўџqџ4џhџЌџў@"ўџ rtextџ 04џhџЌџў'џ ўўџsџџ4џhџЌџўўўўџjџџ mv eџrџ .eps  fџsџ .eps'џ ўўџ backupџ cp eџrџ .eps   archive'џ ўўџjџ systemtџўўџjџuџjџўўџtџўџjџўўўўў