RDX2 X  g4.1 source> 4function(mu = 10, sigma = 1, n = c(4, 9), device="") { 8 if(device!="")hardcopy(width=4, height=2, pointsize=8, $ device=device) D titl <- paste(": Sampling Distribution of the Mean, for Samples", < "of sizes n =", paste(n, collapse = " & "), H "\nfrom a Normal Population with Mean = 10 and SD = 1.",  sep = "")  n2 <- length(n) 5 z <- range(pretty(mu + (c(-3.4, 3.4) * sigma), 50)) ' ylim<-c(0,dnorm(0)*sqrt(max(n)))*1.08 < xy <- list(one=list(n=n[1],xlim=z,ylim=ylim,atx=pretty(z), ! aty=pretty(ylim)), F two=list(n=n[2],xlim=z,ylim=ylim,atx=pretty(z),aty=NULL)) 7 panel.dist <- function(data, mu = 10, sigma = 1, ...)  { / vline <- function(x, y, lty = 1, col = 1) {  if(length(y) == 1)  y <- c(0, y) 1 lines(c(x, x), y, lty = lty, col = col) }  nn<-data$n . z <- pretty(mu + (c(-3, 3) * sigma), 50) ! qz <- pnorm((z - mu)/sigma) ! dz <- dnorm((z - mu)/sigma)  lines(z, dz, yaxs = "s")  chw <- strwidth("O") chh <- strheight("O")*1.25 & z2 <- min(z[z > mu + 2 * sigma])  nz <- match(z2, z) F text(z2 + chw/3.5, dz[nz] + chh/2, "n = 1", adj = 0, cex = 0.75) 7 vline(mu - sigma, y = c( - chh/4, 0) + dnorm(-1)) 6 vline(mu + sigma, y = c( - chh/4, 0) + dnorm(1)) ( vline(mu - sigma, y = c(chh/4, 0)) ( vline(mu + sigma, y = c(chh/4, 0)) & vline(mu, y = dnorm(0), lty = 1) " zn <- mu + (z - mu)/sqrt(nn) ; dzn <- dnorm(((zn - mu) * sqrt(nn))/sigma) * sqrt(nn)  abline(h = 0) $ lines(zn, dzn, col = 2, lwd=2) B vline(mu - sigma/sqrt(nn), y = dnorm(1) * sqrt(nn), col = 2) B vline(mu + sigma/sqrt(nn), y = dnorm(1) * sqrt(nn), col = 2) 7 text(mu + chw*6.5/nn, dnorm(0) * sqrt(nn)-chh/2, 9 paste("Sampling \ndistribution \nof means of", : "\nsamples of \nsize n =", nn), col = 2,  adj = 0, cex = 0.7)  atx <- data$atx  aty <- data$aty : if(!is.null(atx))text(atx,rep(-chh*0.4,length(atx)), 0 paste(atx),cex=0.75) % if(!is.null(aty))axis(2,at=aty)  }  C panelplot(xy,panel=panel.dist,totrows=1,totcols=2,oma=c(1,4,1,2))  titl <- paste(titl, F "\nThe dark curve shows the population distribution,", 0 "\ni.e., the curve is for n=1.") 5 mtext(side = 2, line = 3.25, "Probability density")  if(device!="")dev.off()  cat(titl,"\n") }ў§ mu@$ sigma?№ n c@@"ў device ў { if !=џ ў hardcopy width@ height@ pointsize@ џџўў <- titl paste 0: Sampling Distribution of the Mean, for Samples of sizes n =џџ collapse  & ў 4 from a Normal Population with Mean = 10 and SD = 1. sep ўўџ n2 lengthџўўџ z range pretty +џ ( *џ -@ 333333ў@ 333333ўџўўў@Iўўўџ ylimџџџ dnormў sqrt maxџўўўў?ёGЎzсHўўџ xy list one"џџ [џ?№ў xlimџџџ atxџџў atyџџўў two"џџ$џџ@ў%џџџџ&џџџў'џўўўўџ panel.dist function dataћџ@$џ?№ ...ћўџџ vline*џ xћ yћ lty?№ col?№ўџ џ ==џ/џў?№ўџ/џџ/џўўў linesџ.џ.џў/џ0џ0џ1џ1џўў function(x, y, lty = 1, col = 1) {  if(length(y) == 1)  y <- c(0, y) 1 lines(c(x, x), y, lty = lty, col = col) }ўўџ nn $+џџўўџџџџџџџџџ@ў@ўџўўў@Iўўџ qz pnorm /џџџџўўџўўўџ dzџ8џџџџџўўџўўў3џџ9џ yaxs sўџ chw strwidth Oўўџ chhџ strheight Oў?єўўџ z2 min$џџ >џџџџ@џўўўўўўџ nz match?џџўў textџ?џ8џ;џ@ ўўџ$џ9џBџў8џ=џ@ўў n = 1 adj cex?шў-џџџџў/џџџ8џџ=џў@ўўџџ?№ўўўў-џџџџў/џџџ8џџ=џў@ўўџ?№ўўў-џџџџў/џџ8џ=џ@ўўў-џџџџў/џџ8џ=џ@ўўў-џџ/џџў0џ?№ўџ znџџ8џџџџџўўџ4џўўўўџ dznџџ8џџџџџGџџўўџ4џўўўџўўџ4џўўў abline hў3џGџHџ1џ@ lwd@ў-џџџ8џџџ4џўўў/џџџ?№ўџ4џўў1џ@ў-џџџ8џџџ4џўўў/џџџ?№ўџ4џўў1џ@ўDџџџ8џџ;џ@ў4џўўџџџўџ4џўў8џ=џ@ўўџ #Sampling distribution of means of  samples of size n =4џў1џ@EџFџ?цffffffўџ&џ5џ+џ&џўўџ'џ5џ+џ'џўў џ ! is.null&џўўDџ&џ repџџ=џў?й™™™™™šўџ&џўўџ&џўFџ?шўў џLџMџ'џўў axis@ at'џўўў' 'function(data, mu = 10, sigma = 1, ...)  { / vline <- function(x, y, lty = 1, col = 1) {  if(length(y) == 1)  y <- c(0, y) 1 lines(c(x, x), y, lty = lty, col = col) }  nn<-data$n . z <- pretty(mu + (c(-3, 3) * sigma), 50) ! qz <- pnorm((z - mu)/sigma) ! dz <- dnorm((z - mu)/sigma)  lines(z, dz, yaxs = "s")  chw <- strwidth("O") chh <- strheight("O")*1.25 & z2 <- min(z[z > mu + 2 * sigma])  nz <- match(z2, z) F text(z2 + chw/3.5, dz[nz] + chh/2, "n = 1", adj = 0, cex = 0.75) 7 vline(mu - sigma, y = c( - chh/4, 0) + dnorm(-1)) 6 vline(mu + sigma, y = c( - chh/4, 0) + dnorm(1)) ( vline(mu - sigma, y = c(chh/4, 0)) ( vline(mu + sigma, y = c(chh/4, 0)) & vline(mu, y = dnorm(0), lty = 1) " zn <- mu + (z - mu)/sqrt(nn) ; dzn <- dnorm(((zn - mu) * sqrt(nn))/sigma) * sqrt(nn)  abline(h = 0) $ lines(zn, dzn, col = 2, lwd=2) B vline(mu - sigma/sqrt(nn), y = dnorm(1) * sqrt(nn), col = 2) B vline(mu + sigma/sqrt(nn), y = dnorm(1) * sqrt(nn), col = 2) 7 text(mu + chw*6.5/nn, dnorm(0) * sqrt(nn)-chh/2, 9 paste("Sampling \ndistribution \nof means of", : "\nsamples of \nsize n =", nn), col = 2,  adj = 0, cex = 0.7)  atx <- data$atx  aty <- data$aty : if(!is.null(atx))text(atx,rep(-chh*0.4,length(atx)), 0 paste(atx),cex=0.75) % if(!is.null(aty))axis(2,at=aty)  }ўў panelplot!џ panel)џ totrows?№ totcols@ omaџ?№@?№@ўўџџџџ 2 The dark curve shows the population distribution,  i.e., the curve is for n=1.ўў mtext side@ line@  Probability densityў џ џџ ў dev.offўў catџ  ўў g4.10џ* Afunction(x1=two65$ambient, x2=two65$heated, nsim=2000, plotit=T, % fignum="4.10", device=""){ B if(device!="")hardcopy(width=2.25, height=2.25, device=device) ) oldpar<-par(mar=par()$mar-c(1,0,1,0))  on.exit(par(oldpar))  library(DAAG); data(two65)  n1 <- length(x1)  n2<-length(x2) n<-n1+n2  x<-c(x1,x2)  dbar <- mean(x2)-mean(x1)  z <- array(,nsim)  for(i in 1:nsim){ & mn <- sample(n,n2,replace=FALSE) , dbardash <- mean(x[mn]) - mean(x[-mn])  z[i] <- dbardash  } : pval <- (sum(z>abs(dbar)) + sum (z < -abs(dbar)))/nsim ; if(plotit){plot(density(z), xlab="", main="", yaxs="i", 1 ylim=c(0,0.08), cex.axis=0.8)  abline(v=dbar) % abline(v=-dbar, lty=2) % mtext(side=3,line=0.5, J text=expression(bar(italic(x))[2]-bar(italic(x))[1]),  at=dbar) % mtext(side=3,line=0.5, 9 text=expression(-(bar(italic(x))[2]- 8 bar(italic(x))[1])), at=-dbar)}  print(signif(pval,3))  ## Second try  for(i in 1:nsim){ & mn <- sample(n,n2,replace=FALSE) , dbardash <- mean(x[mn]) - mean(x[-mn])  z[i] <- dbardash  } : pval <- (sum(z>abs(dbar)) + sum (z < -abs(dbar)))/nsim , if(plotit){lines(density(z),lty=5,lwd=2) $ print(signif(pval,3))  }  if(device!="")dev.off()  }ў§ x15џ two65 ambientў x25џ]џ heatedў nsim@Ÿ@ plotit T fignum 4.10џ ўџ џ џџ ў џ џ@ џ@џџўўџ oldpar par marџ5џdџў marўџ?№?№ўўўў on.exitdџcџўў library DAAGў+џ]џўџ n1џ\џўўџџџ^џўўџџџiџџўўџ.џџ\џ^џўўџ dbarџ mean^џўkџ\џўўўџџ arrayћ_џўў for i :?№_џўџџ mn sampleџџ replace ўўџ dbardashџkџ$џ.џpџўўkџ$џ.џџpџўўўўўџ$џџnџўsџўўўџ pval8џџџ sumAџџ absjџўўўuџ <џџvџjџўўўўўў_џўў џ`џџ plot densityџў xlab  main :џ iџџ?ДzсGЎ{ў cex.axis?щ™™™™™šўIџ vjџўIџ}џџjџў0џ@ўVџWџ@Xџ?рDџ expressionџ$џ bar italic.џўў@ў$џџ€џ.џўў?№ўўўPџjџўVџWџ@Xџ?рDџ~џџџџ$џџ€џ.џўў@ў$џџ€џ.џўў?№ўўўўўPџџjџўўўў print signiftџ@ўўmџnџoџ?№_џўџџpџqџџџrџ ўўџsџџkџ$џ.џpџўўkџ$џ.џџpџўўўўўџ$џџnџўsџўўўџtџ8џџџuџAџџvџjџўўўuџwџџџvџjџўўўўўў_џўў џ`џџ3џyџџў0џ@Kџ@ўџ‚џtџ@ўўўў џ џџ ўYџўўў g4.2џ function(device=""){ 2 if(device!="")hardcopy(width=4.5, pointsize=8, 2 device=device, height=2.2) A oldpar <- par(mfrow = c(1,2), mar=par()$mar-c(.5, 0, 1.5, 0), , mgp=c(2.5, .75, 0), xpd=T)  on.exit(par(oldpar)) 2 x <- seq(from=-4.2, to = 4.2, length.out = 50)  ylim <- c(0, dnorm(0)) % ylim[2] <- ylim[2]+0.1*diff(ylim)  h1 <- dnorm(x)  h3 <- dt(x, 3)  h8 <- dt(x,8) . plot(x, h1, type="l", xlab = "", xaxs="i", 1 ylab = "", yaxs="i", bty="L", ylim=ylim) * mtext(side=3,line=0.75, "A", adj=-0.2)  lines(x, h8, col="grey60") 4 mtext(side=1, line=2.5, "No. of SEMs from mean") 2 mtext(side=2, line=2.5, "Probability density")  chh <- par()$cxy[2] 0 topleft <- par()$usr[c(1,4)] + c(0, 0.4*chh) ; legend(topleft[1], topleft[2], col=c("black","grey60"), I lty=c(1,1), legend=c("Normal","t (8 d.f.)"), bty="n", cex=0.8) . plot(x, h1, type="l", xlab = "", xaxs="i", 1 ylab = "", yaxs="i", bty="L", ylim=ylim) * mtext(side=3,line=0.75, "B", adj=-0.2)  lines(x, h3, col="grey60") 4 mtext(side=1, line=2.5, "No. of SEMs from mean") 2 mtext(side=2, line=2.5, "Probability density") ; legend(topleft[1], topleft[2], col=c("black","grey60"), I lty=c(1,1), legend=c("Normal","t (3 d.f.)"), bty="n", cex=0.8)  if(device!="")dev.off()  }ў§џ ўџ џ џџ ў џ џ@џ@ џџ џ@™™™™™šўўџcџdџ mfrowџ?№@ўeџџ5џdџўeџўџ?р?јўў mgpџ@?шў xpdaџўўfџdџcџўўџ.џ seq fromџ@ЬЬЬЬЬЭў to@ЬЬЬЬЬЭ length.out@Iўўџџџџўўўџ$џџ@ўџ$џџ@ўџ?Й™™™™™š diffџўўўўџ h1џ.џўўџ h3 dt.џ@ўўџ h8Žџ.џ@ ўўxџ.џŒџ type lzџ  xaxs i ylab :џ i bty LџџўVџWџ@Xџ?ш AEџџ?Щ™™™™™šўў3џ.џџ1џ grey60ўVџWџ?№Xџ@ No. of SEMs from meanўVџWџ@Xџ@ Probability densityўџ=џ$џ5џdџў cxyў@ўўџ topleftџ$џ5џdџў usrўџ?№@ўўџџ?й™™™™™š=џўўўў legend$џ•џ?№ў$џ•џ@ў1џџ black grey60ў0џџ?№?№ў—џџ Normal t (8 d.f.)ў“џ nFџ?щ™™™™™šўxџ.џŒџџ lzџ ‘џ i’џ :џ i“џ LџџўVџWџ@Xџ?ш BEџџ?Щ™™™™™šўў3џ.џџ1џ grey60ўVџWџ?№Xџ@ No. of SEMs from meanўVџWџ@Xџ@ Probability densityў—џ$џ•џ?№ў$џ•џ@ў1џџ black grey60ў0џџ?№?№ў—џџ Normal t (3 d.f.)ў“џ nFџ?щ™™™™™šў џ џџ ўYџўўў g4.2aџ 'function(fignum="4.2a", pscript=FALSE){ 7if(pscript)psfile(fignum=fignum, width=4.5, height=2.2) Qoldpar <- par(mfrow = c(1,2), mar=par()$mar-c(.5, 0, 1.5, 0), mgp=c(2.5, .75, 0)) on.exit(par(oldpar)) .x <- seq(from=-4.2, to = 4.2, length.out = 50) ylim <- c(0, dnorm(0)) h1 <- dnorm(x) h3 <- dt(x, 3) h8 <- dt(x,8) *plot(x, h1, type="l", xlab = "", xaxs="i", , ylab = "", yaxs="i", bty="L", ylim=ylim) #mtext(side=3,line=1, "A", adj=-0.2) lines(x, h8, col="grey60") 0mtext(side=1, line=2.5, "No. of SEMs from mean") .mtext(side=2, line=2.5, "Probability density") chh <- par()$cxy[2] -topleft <- par()$usr[c(1,4)] + c(0, 0.75*chh) 7legend(topleft[1], topleft[2], col=c("black","grey60"), B lty=c(1,1), legend=c("Normal","t (8 d.f.)"), bty="n", cex=0.8) *plot(x, h1, type="l", xlab = "", xaxs="i", , ylab = "", yaxs="i", bty="L", ylim=ylim) #mtext(side=3,line=1, "B", adj=-0.2) lines(x, h3, col="grey60") 0mtext(side=1, line=2.5, "No. of SEMs from mean") .mtext(side=2, line=2.5, "Probability density") 7legend(topleft[1], topleft[2], col=c("black","grey60"), B lty=c(1,1), legend=c("Normal","t (3 d.f.)"), bty="n", cex=0.8) if(pscript)dev.off() }ў§bџ 4.2a pscript ўџ џ™џ psfilebџbџ џ@ џ@™™™™™šўўџcџdџ„џџ?№@ўeџџ5џdџўeџўџ?р?јўў…џџ@?шўўўfџdџcџўўџ.џ‡џˆџџ@ЬЬЬЬЬЭў‰џ@ЬЬЬЬЬЭŠџ@IўўџџџџўўўџŒџџ.џўўџџŽџ.џ@ўўџџŽџ.џ@ ўўxџ.џŒџџ lzџ ‘џ i’џ :џ i“џ LџџўVџWџ@Xџ?№ AEџџ?Щ™™™™™šўў3џ.џџ1џ grey60ўVџWџ?№Xџ@ No. of SEMs from meanўVџWџ@Xџ@ Probability densityўџ=џ$џ5џdџў”џў@ўўџ•џџ$џ5џdџў–џўџ?№@ўўџџ?ш=џўўўў—џ$џ•џ?№ў$џ•џ@ў1џџ black grey60ў0џџ?№?№ў—џџ Normal t (8 d.f.)ў“џ nFџ?щ™™™™™šўxџ.џŒџџ lzџ ‘џ i’џ :џ i“џ LџџўVџWџ@Xџ?№ BEџџ?Щ™™™™™šўў3џ.џџ1џ grey60ўVџWџ?№Xџ@ No. of SEMs from meanўVџWџ@Xџ@ Probability densityў—џ$џ•џ?№ў$џ•џ@ў1џџ black grey60ў0џџ?№?№ў—џџ Normal t (3 d.f.)ў“џ nFџ?щ™™™™™šў џ™џYџўўў g4.3џ1 function(cump=0.975, device=""){ > if(device!="")hardcopy(width=4.5, height=2.2, pointsize=8, ) device=device) A oldpar <- par(mfrow = c(1,2), mar=par()$mar-c(.5, 0, 1.5, 0), % mgp=c(2.5, .75, 0))  on.exit(par(oldpar)) 2 x <- seq(from=-3.9, to = 3.9, length.out = 50)  ylim <- c(0, dnorm(0)) 7 plotfun <- function(cump, dfun = dnorm, qfun=qnorm, < ytxt = "Normal probability density", . txt1="qnorm", txt2="")  {  h <- dfun(x) ; plot(x, h, type="l", xlab = "", xaxs="i", xaxt="n", 7 ylab = ytxt, yaxs="i", bty="L", ylim=ylim) % axis(1, at=c(-2, 0), cex=0.8) ' axis(1, at=c((-3):3), labels=F)  tailp <- 1-cump  z <- qfun(cump) " ztail <- pretty(c(z,4),20)  htail <- dfun(ztail) J polygon(c(z,z,ztail,max(ztail)), c(0,dfun(z),htail,0), col="gray") ) text(0, 0.5*dfun(z)+0.08*dfun(0), > paste(round(tailp, 3), " + ", round(1-2*tailp,3), < "\n= ", round(cump, 3), sep=""), cex=0.8) ' lines(rep(z, 2), c(0, dfun(z))) 6 lines(rep(-z, 2), c(0, dfun(z)), col="gray60")  chh <- par()$cxy[2] 7 arrows(z, -2*chh,z,-0.1*chh, length=0.1, xpd=T) A text(z, -3*chh, paste(txt1, "(", cump, txt2, ")", "\n= ", 9 round(z,2), sep=""), xpd=T)  x1 <- z + .3  y1 <- dfun(x1)*0.35  y0 <- dfun(0)*0.2 < arrows(-2.75, y0, -x1, y1, length=0.1, col="gray60") , arrows(2.75, y0, x1, y1, length=0.1) 4 text(-2.75, y0+0.5*chh, tailp, col="gray60") % text(2.75, y0+0.5*chh, tailp)  } , ytxt <- "t probability density (8 d.f.)"  plotfun(cump=cump) * mtext(side=3, line=1.5, "A", adj=-0.2) , ytxt <- "t probability density (8 d.f.)" 0 plotfun(cump=cump, dfun=function(x)dt(x, 8), % qfun=function(x)qt(x, 8), - ytxt=ytxt, txt1="qt", txt2=", 8") * mtext(side=3, line=1.5, "B", adj=-0.2)  if(device!="")dev.off()  }ў§ cump?я333333џ ўџ џ џџ ў џ џ@ џ@™™™™™šџ@ џџўўџcџdџ„џџ?№@ўeџџ5џdџў marўџ?р?јўў…џџ@?шўўўfџdџcџўўџ.џ‡џˆџџ@333333ў‰џ@333333Šџ@Iўўџџџџўўўџ plotfun*џ$œџћ$ dfunџ$ qfun qnorm$ ytxt Normal probability density$ txt1 qnorm$ txt2 ўџџJџžџ.џўўxџ.џJџџ lzџ ‘џ i xaxt n’џЁџ:џ i“џ LџџўOџ?№Pџџџ@ўўFџ?щ™™™™™šўOџ?№Pџџoџџџ@ўў@ўў labels Fўџ tailpџ?№œџўўџџŸџœџўўџ ztailџџџ@ў@4ўўџ htailžџЈџўў polygonџџџЈџ џЈџўўџžџџўЉџў1џ grayўDџџџ?рžџџўўџ?ДzсGЎ{žџўўўџ roundЇџ@ў  + Ћџџ?№џ@Їџўў@ў  = Ћџœџ@ўџ ўFџ?щ™™™™™šў3џNџџ@ўџžџџўўў3џNџџџў@ўџžџџўў1џ gray60ўџ=џ$џ5џdџў cxyў@ўў arrowsџџџ@ў=џўџџџ?Й™™™™™šў=џўџ?Й™™™™™š†џaџўDџџџџ@ў=џўџЂџ (œџЃџ )  = Ћџџ@ўџ ў†џaџўџ\џџџ?г333333ўўџ y1џžџ\џў?жffffffўўџ y0џžџў?Щ™™™™™šўўЌџџ@ўЎџџ\џў­џџ?Й™™™™™š1џ gray60ўЌџ@Ўџ\џ­џџ?Й™™™™™šўDџџ@ўџЎџџ?р=џўўЇџ1џ gray60ўDџ@џЎџџ?р=џўўЇџўў (function(cump, dfun = dnorm, qfun=qnorm, < ytxt = "Normal probability density", . txt1="qnorm", txt2="")  {  h <- dfun(x) ; plot(x, h, type="l", xlab = "", xaxs="i", xaxt="n", 7 ylab = ytxt, yaxs="i", bty="L", ylim=ylim) % axis(1, at=c(-2, 0), cex=0.8) ' axis(1, at=c((-3):3), labels=F)  tailp <- 1-cump  z <- qfun(cump) " ztail <- pretty(c(z,4),20)  htail <- dfun(ztail) J polygon(c(z,z,ztail,max(ztail)), c(0,dfun(z),htail,0), col="gray") ) text(0, 0.5*dfun(z)+0.08*dfun(0), > paste(round(tailp, 3), " + ", round(1-2*tailp,3), < "\n= ", round(cump, 3), sep=""), cex=0.8) ' lines(rep(z, 2), c(0, dfun(z))) 6 lines(rep(-z, 2), c(0, dfun(z)), col="gray60")  chh <- par()$cxy[2] 7 arrows(z, -2*chh,z,-0.1*chh, length=0.1, xpd=T) A text(z, -3*chh, paste(txt1, "(", cump, txt2, ")", "\n= ", 9 round(z,2), sep=""), xpd=T)  x1 <- z + .3  y1 <- dfun(x1)*0.35  y0 <- dfun(0)*0.2 < arrows(-2.75, y0, -x1, y1, length=0.1, col="gray60") , arrows(2.75, y0, x1, y1, length=0.1) 4 text(-2.75, y0+0.5*chh, tailp, col="gray60") % text(2.75, y0+0.5*chh, tailp)  }ўўџЁџ t probability density (8 d.f.)ўџœџœџўVџWџ@Xџ?ј AEџџ?Щ™™™™™šўўџЁџ t probability density (8 d.f.)ўџœџœџžџ*џ.џћўŽџ.џ@ ў function(x)dt(x, 8)ўŸџ*џ.џћў qt.џ@ ў function(x)qt(x, 8)ўЁџЁџЂџ qtЃџ , 8ўVџWџ@Xџ?ј BEџџ?Щ™™™™™šўў џ џџ ўYџўўў g4.4џ function(device="") { = if(device!="")hardcopy(width=4.75, height=2.5, pointsize=8, ' device=device)  library(DAAG); data(pair65)  titl <- paste( I "Second versus first member, for each pair. The first", J "\npanel is for the elastic band data. The second (from", F "\nDarwin) is for plants of the species Reseda lutea") O oldpar <- par(mfrow = c(1, 2), mar = par()$mar - c(.5, -0.5, .5, 0), pty="s", 3 oma=c(0,0,0,.5),mgp = c(2, 0.5, 0))  on.exit(par(oldpar)) = onesamp(dset = pair65, x = "ambient", y = "heated", xlab = 0 "Amount of stretch (ambient)", ylab = ' "Amount of stretch (heated)") B ## Data set mignonette holds Darwin's data on Reseda lutea, from G ## Darwin, Charles 1877. The Effects of Cross and Self Fertilisation F ## in the Vegetable Kingdom. Appleton and Company, New York, p.118. > ## Data were in five pots, holding 5,5,5,5,4 pairs of plants  ## respectively. = onesamp(dset = mignonette, x = "self", y = "cross", xlab = 4 "Height of Self-fertilised Plant", ylab = : "Height of Cross-Fertilised Plant", dubious = 0)  cat("\n", titl, "\n")  if(device!="")dev.off() invisible() }ў§$џ ўџ џ џџ ў џ џ@ џ@џ@ џџўўgџhџў+џ pair65ўџџџ 5Second versus first member, for each pair. The first 5 panel is for the elastic band data. The second (from 2 Darwin) is for plants of the species Reseda luteaўўџcџdџ„џџ?№@ўeџџ5џdџў marўџ?рџ?рў?рўў pty sUџџ?рў…џџ@?рўўўfџdџcџўў onesamp dsetБџ.џ ambient/џ heatedzџ Amount of stretch (ambient)’џ Amount of stretch (heated)ўГџДџ mignonette.џ self/џ crosszџ Height of Self-fertilised Plant’џ Height of Cross-Fertilised Plant dubiousўZџ  џ  ў џ џџ ўYџўў invisibleўў g4.5џ function(device="") { < if(device!="")hardcopy(width=2.4, height=2.4, pointsize=8, ' device=device) F oldpar<-par(mar=c(4.1,4.1,1.1,1.1), mfrow=c(1,1), mgp=c(2.5,0.75,0))  on.exit(par(oldpar))  library(DAAG)  x2 <- chisq.test(rareplants) * x2E <- stack(data.frame(t(x2$expected)))  habitat <- rep(c(1,2,3), 4) t plot(x2E$values ~ habitat, xlab="habitat", ylab="Expected Number of Species",axes=FALSE, xlim=c(0.5, 3.5), pch=16) C text(x2E$values ~ habitat, labels=x2E$ind, pos=rep(c(4,4,2,2),3),  cex=0.85) 0 axis(1, at=seq(1,3), labels=c("D", "W", "WD")) axis(2)  box()  if(device!="")dev.off() invisible() }ў§џ ўџ џ џџ ў џ џ@333333 џ@333333џ@ џџўўџcџdџeџџ@ffffff@ffffff?ё™™™™™š?ё™™™™™šў„џџ?№?№ў…џџ@?шўўўfџdџcџўўgџhџўџ^џ chisq.test rareplantsўўџ x2E stack data.frame t5џ^џ expectedўўўўўџ habitatNџџ?№@@ў@ўўxџ ~5џЛџ valuesўПџўzџ habitat’џ Expected Number of Species axes %џџ?р@ ў pch@0ўDџРџ5џЛџСџўПџўЅџ5џЛџ indў posNџџ@@@@ў@ўFџ?ы333333ўOџ?№Pџ‡џ?№@ўЅџџ D W WDўўOџ@ў boxў џ џџ ўYџўўЗџўў g4.6џ function(device="") { M if(device!="")hardcopy(width=3.0, height=1.75, device=device, trellis=TRUE) < oldpar <- par(mar = c(4.1,4.1,1.1,1.1), mgp=c(2.5,0.75,0))  on.exit(par(oldpar)) tomato <-  data.frame(weight= 6 c(1.5, 1.9, 1.3, 1.5, 2.4, 1.5, # water 9 1.5, 1.2, 1.2, 2.1, 2.9, 1.6, # Nutrient = 1.9, 1.6, 0.8, 1.15, 0.9, 1.6), # Nutrient+24D > trt = rep(c("water", "Nutrient", "Nutrient+24D"),  c(6, 6, 6))) 0tomato$trt <- relevel(tomato$trt, ref="water") 8 gph <- with(tomato, stripplot(trt~weight, aspect=0.6)) print(gph) , figtxt <- paste("Weights of tomato plants"  )  cat(figtxt,"\n")  if(device!="")dev.off() invisible() }ў§џ ўџ џ џџ ў џ џ@ џ?ќџџ trellis ўўџcџdџeџџ@ffffff@ffffff?ё™™™™™š?ё™™™™™šў…џџ@?шўўўfџdџcџўўџ tomatoНџ weightџ?ј?ўffffff?єЬЬЬЬЬЭ?ј@333333?ј?ј?ѓ333333?ѓ333333@ЬЬЬЬЬЭ@333333?љ™™™™™š?ўffffff?љ™™™™™š?щ™™™™™š?ђffffff?ьЬЬЬЬЬЭ?љ™™™™™šў trtNџџ water Nutrient Nutrient+24Dўџ@@@ўўўўџ5џШџЪџў relevel5џШџ trtў ref waterўўџ gph withШџ stripplotРџЪџЩџў aspect?у333333ўўўџЭџўџ figtxtџ Weights of tomato plantsўўZџбџ  ў џ џџ ўYџўўЗџўў g4.7џ function(device=""){ @ if(device!="")hardcopy(width=4.2, height=2.0, device=device) tomato <-  data.frame(weight= 6 c(1.5, 1.9, 1.3, 1.5, 2.4, 1.5, # water 9 1.5, 1.2, 1.2, 2.1, 2.9, 1.6, # Nutrient = 1.9, 1.6, 0.8, 1.15, 0.9, 1.6), # Nutrient+24D > trt = rep(c("water", "Nutrient", "Nutrient+24D"),  c(6, 6, 6))) 8 tomato$trt <- relevel(tomato$trt, ref="water") . tomato.aov <- aov(weight~trt, data=tomato)  onewayPlot(obj=tomato.aov)  if(device!="")dev.off()  }ў§џ ўџ џ џџ ў џ џ@ЬЬЬЬЬЭ џ@џџўўџШџНџЩџџ?ј?ўffffff?єЬЬЬЬЬЭ?ј@333333?ј?ј?ѓ333333?ѓ333333@ЬЬЬЬЬЭ@333333?љ™™™™™š?ўffffff?љ™™™™™š?щ™™™™™š?ђffffff?ьЬЬЬЬЬЭ?љ™™™™™šўЪџNџџ water Nutrient Nutrient+24Dўџ@@@ўўўўџ5џШџЪџўЫџ5џШџ trtўЬџ waterўўџ tomato.aov aovРџЩџЪџў+џШџўў onewayPlot objгџў џ џџ ўYџўўў g4.8џ 5function(figtxt = "Interaction plot of rice data", mc  = F, device="") { ; if(device!="")hardcopy(width=5, height=2.35, pointsize=8, ' device=device) 2 oldpar <- par(mgp=c(2.5,0.75,0), pty="s", las=1)  on.exit(par(oldpar))  attach(rice) 6par(fig=c(0,0.555,0,1), mar=c(4.1,9.1,1.1,1.1), las=1) Jstripchart(ShootDryMass ~ trt, pch=1, cex=1, col="gray40", xlim=c(0,140), 7 ylim=c(.5, 6.25), xlab="Shoot dry mass (g)") box(col="gray75") /av <- tapply(ShootDryMass, INDEX=trt, FUN=mean) Nstripchart(av ~ factor(names(av), levels=names(av)), pch=3, cex=1.5, add=TRUE) ;par(fig=c(0.555,1,0,1), mar = c(4.1,5.1,1.1,1.6), new=TRUE) B## Interaction plot for ShootDryMass with factors fert and variety >interaction.plot(fert, variety, ShootDryMass, legend = FALSE, . xlab="Fertilizer treatment", / ylab="Mean of Shoot dry mass") detach(rice) box(col="gray75")  if(device!="")dev.off() invisible() }ў§бџ Interaction plot of rice data mcІџџ ў srcref ' srcfileђ encoding native.enc timestampAбЏFс class POSIXt POSIXctў filename /tmp/johnm.g4.8.R wd /Users/johnm/r/ch4ўўоџ srcfileўоџ srcrefў 2кџлџоџ srcrefў кџлџоџ srcrefў   кџлџоџ srcrefў   6кџлџоџ srcrefў   7кџлџоџ srcrefў   кџлџоџ srcrefў /кџлџоџ srcrefў Nкџлџоџ srcrefў ;кџлџоџ srcrefў /кџлџоџ srcrefў  кџлџоџ srcrefў кџлџоџ srcrefў кџлџоџ srcrefў  кџлџоџ srcrefўкџлџўџ џ џџ ў џ џ@ џ@ЬЬЬЬЬЭџ@ џџўўџcџdџ…џџ@?шўВџ s las?№ўўfџdџcџўў attach riceўdџ figџ?сТ\(ѕУ?№ўeџџ@ffffff@"333333?ё™™™™™š?ё™™™™™šўсџ?№ў stripchartРџ ShootDryMassЪџўУџ?№Fџ?№1џ gray40%џџ@a€ўџџ?р@ўzџ Shoot dry mass (g)ўХџ1џ gray75ўџ av tapplyцџ INDEXЪџ FUNkџўўхџРџчџ factor namesчџў levelsьџчџўўўУџ@Fџ?ј add ўdџфџџ?сТ\(ѕУ?№?№ўeџџ@ffffff@ffffff?ё™™™™™š?љ™™™™™šў new ў interaction.plot fert varietyцџ—џ zџ Fertilizer treatment’џ Mean of Shoot dry massў detachуџўХџ1џ gray75ў џ џџ ўYџўўЗџўў g4.9џ 'function(mc = F, type="box", device="") { G if(device!="")hardcopy(width=2, height=2, pointsize=8, device=device) K figtxt <- "Distance travelled, relative to distance up a 20 degree ramp." E oldpar <- par(mar = c(4.1,4.1,1.1,1.1), pty="s", mgp=c(2.5,0.75,0))  on.exit(par(oldpar)) library(DAAG); data(modelcars)  attach(modelcars) L stripchart(distance.traveled~starting.point, vertical=T, pch=16, cex=0.75, B xlab = "Distance up ramp", ylab="Distance travelled")  detach(modelcars)  if(device!="")dev.off() invisible() }ў§иџІџџ boxџ ўџ џ џџ ў џ џ@ џ@џ@ џџўўџбџ =Distance travelled, relative to distance up a 20 degree ramp.ўџcџdџeџџ@ffffff@ffffff?ё™™™™™š?ё™™™™™šўВџ s…џџ@?шўўўfџdџcџўўgџhџў+џ modelcarsўтџѕџўхџРџ distance.traveled starting.pointў verticalaџУџ@0Fџ?шzџ Distance up ramp’џ Distance travelledўѓџѕџў џ џџ ўYџўўЗџўў gdumpџ 7function(fnam=NULL, prefix="~/r-book/ed2/figures/figs",  splitchar="/ch"){  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="/") H objnames <- c(objects(pattern="^g", envir=sys.frame(0)), "hardcopy") & cat("\nDump to file:", fnam, "\n")  print(objnames)  dump(objnames, fnam)  }ў§ fnamў prefix ~/r-book/ed2/figures/figs splitchar /chўџ џMџњџўџџ path getwdўўџ pathtag [[ strsplit§џ /ch fixed ў?№ўўџњџџћџ$џџџџџџўў .Rџ ўўўџњџџћџњџџ /ўўўџ objnamesџ objects pattern ^g envir sys.frameўў hardcopyўўZџ  Dump to file:њџ  ўџџў dumpџњџўў gfileџ& 5function(width=3.75, height=3.75, color=F, trellis=F, J 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" H ## 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) D fnam <- strsplit(as.character(funtxt), "(", fixed=T)[[1]][1] . dotsplit <- strsplit(fnam, "\\.")[[1]] 0 dotsplit[1] <- substring(dotsplit[1], 2) K prefix1 <- paste(if(nchar(dotsplit[1])==1)"0" else "", dotsplit[1], sep="") K prefix2 <- paste(if(nchar(dotsplit[2])==1)"0" else "", dotsplit[2], sep="") 7 suffix <- switch(device, ps=".eps", pdf=".pdf") A fnam <- paste("~/r-book/second/Art/",prefix1,"-",prefix2, % suffix, sep="")  print(fnam)  dev.out <- device[1] : dev.fun <- switch(dev.out, pdf=pdf, ps=postscript)  if(trellis){  library(lattice) D trellis.device(file=fnam, device=dev.fun, color = color, C width=width, height=height, horiz=horiz) R trellis.par.set(fontsize=list(text=pointsize[1], points=pointsize[2])) } else  if (dev.out!=""){ ' print(c(width, height)) 3 dev.fun(file=fnam, paper="special", 4 enc="MacRoman", horiz=horiz, K width=width, height=height, pointsize=pointsize[1]) }  }ў§ џ@ џ@ colorІџЧџІџџџ  pdf psў§џ џџ@ @ў horizІџўџ џLџЧџўџџ$џџ?№ўўўџ funtxt sys.call?№ўўџњџ$џџџ as.character џў (џaџў?№ў?№ўўџ dotsplitџџњџ \.ў?№ўўџ$џџ?№ў substring$џџ?№ў@ўўџ prefix1џ џ2џ nchar$џџ?№ўў?№ў 0 ў$џџ?№ўџ ўўџ prefix2џ џ2џџ$џџ@ўў?№ў 0 ў$џџ@ўџ ўўџ suffix switchџ ps .eps pdf .pdfўўџњџџ ~/r-book/second/Art/џ -џџџ ўўџњџўџ dev.out$џџ?№ўўџ dev.funџџџџџ postscriptўў џЧџџgџ latticeў trellis.device fileњџџџ џ џ џ џ џ џ џ џў trellis.par.set fontsize"џDџ$џџ?№ў points$џџ@ўўўў џ џџ ўџџџ џ џўўџџњџ paper special enc MacRoman џ џ џ џ џ џџ$џџ?№ўўўўўў 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()  }ў§џ ўџgџџўgџ gridў џ џџ ў џџџ џ@ џ@Чџ  џ ўўџ layout.heights"џ key.top?а axis.top?рўўџ hp1.plt1 xyplotРџ o2 wattsPerKgў groups id+џ humanpower1Rџ*џ.џћ/џћ subscriptsћ,џћ,џћўџџ u lmРџ/џџ,џ.џўўўўџ hat fitted0џўў panel.superpose.џ/џ/џ,џў4џ.џ2џ/џ,џџ 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")  }ўzџ Watts per kilogram’џ~џџџџ Oxygen intake ( ^ ml.minџџ?№ўўўў5џ .kgџџ?№ўўўў )ўў—џ"џ top"џ fun textGrob args"џ label A.џўўўўўџ(џ positionџ?сИQы…?№ўўџ0џ lmeРџ*џ+џў randomРџ |+џ-џўў+џ.џўўџ hp1.plt2)џРџ*џ+џў,џ-џ+џ.џRџ*џ.џћ/џћ/џћ,џћ,џћўџџ0џ1џРџ/џџ,џ.џўўўўџ2џ3џ0џўў4џ.џ2џ/џ,џџ lўў $function(x,y,subscripts,groups,...){ ' u <- lm(y~groups*x); # hat <- fitted(u) E panel.superpose(x,hat,subscripts,groups, type="l")  }ўzџ Watts per kilogram’џ —џ"џ8џ"џ9џ:џ;џ"џ<џ B.џўўўўўџ2џ3џ0џўўџAџ=џџ?нТ\(ѕУ?№?№ў newpage ў trellis.focus panel row?№ column?№ўџ arglist trellis.panelArgsўў4џ.џ5џFџ.џў/џ2џ/џ5џFџ/џў,џ5џFџ,џўћџ l0џ@ў trellis.unfocusў џ џџ ўYџўўў gsaveџ 7function(fnam=NULL, prefix="~/r-book/ed2/figures/figs", K splitchar="/ch", xtras=c("renum.fun","renum.files","hardcopy")){  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 xtrasџ renum.fun renum.files hardcopyўўџ џMџњџўџџ§џўџўўџџџџџ§џ /chџ ў?№ўўџњџџћџ$џџџџџџўў .RDataџ ўўўџњџџћџњџџ /ўўўџџџџџ ^gџџўўJџўўZџ  Dump to file:њџ  ўџџў save"џџџњџўў gtestџ function(){ / trellis.device(postscript, file="test.eps") 5 trellis.par.set(layout.heights=list(key.top=0.5)) 6 zz.d <- dotplot(variety ~ yield, data = barley, B legend=list(top=list(fun=grid.text, I args=list(label="ABC", x=0)))) 4 pushViewport(viewport(layout=grid.layout(2, 1))) , pushViewport(viewport(layout.pos.row=1))  print(zz.d,newpage=FALSE)  upViewport() , pushViewport(viewport(layout.pos.row=2))  print(zz.d, newpage=FALSE)  popViewport(2) dev.off()  }ў§ўџџџџ test.epsўџ%џ"џ&џ?рўўџ zz.d dotplotРџђџ yieldў+џ barley—џ"џ8џ"џ9џ grid.text;џ"џ<џ ABC.џўўўўў pushViewport viewport layout grid.layout@?№ўўўRџSџ layout.pos.row?№ўўџMџBџ ў upViewportўRџSџVџ@ўўџMџBџ ў popViewport@ўYџўў renum.funџ Gfunction(from.prefix="g4.", to.prefix="g4.",from=4:10, to=3:9, doit=F){  for(i in 1:length(to)) E {txt<-paste(to.prefix,to[i]," <- ", from.prefix,from[i],sep="") 7 if(doit)eval(parse(text=txt),envir=sys.frame(0))  print(txt)  }  }ў§ from.prefix g4. to.prefix g4.ˆџoџ@@$ў‰џoџ@@"ў$ doitІџўџmџnџoџ?№џ‰џўўџџ txtџ[џ$џ‰џnџў  <- Zџ$џˆџnџўџ ўў џ\џ eval parseDџ]џўџџўўўџ]џўўўў renum.filesџ Tfunction(from.prefix="~/r-book/second/Art/02-", to.prefix="~/r-book/second/Art/02-", ' from=6:9, to=5:8, doit=F){ ! for(i in 1:length(from)){ > if (from[i]<=9) ltext <- paste("0",from[i],sep="") ( else ltext <- paste(from[i]) : if (to[i]<=9) rtext <- paste("0",to[i],sep="") 2 else rtext <- paste(to[i]) > txt<-paste("mv ", from.prefix, ltext, ".eps", " ", 8 to.prefix, rtext, ".eps", sep="")  if(doit)system(txt)  print(txt) }  }ў§Zџ ~/r-book/second/Art/02-[џ ~/r-book/second/Art/02-ˆџoџ@@"ў‰џoџ@@ ў\џІџўџmџnџoџ?№џˆџўўџ џ <=$џˆџnџў@"ўџ ltextџ 0$џˆџnџўџ ўўџbџџ$џˆџnџўўўў џaџ$џ‰џnџў@"ўџ rtextџ 0$џ‰џnџўџ ўўџcџџ$џ‰џnџўўўўџ]џџ mv Zџbџ .eps  [џcџ .epsџ ўў џ\џ system]џўўџ]џўўўў џџ4 =function(width=3.75, height=3.75, color=FALSE, trellis=FALSE, < device=c("","pdf","ps"), path=getwd(), 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ў§џўџўџў formatџ nn-nn nameў split \.џџ@ @ў fontsў џ ,џћўйџ  )кџђмџ native.encнџAбрТŽоџ POSIXt POSIXctўпџ /tmp/johnm.hardcopy.Rрџ /Users/johnm/r/ch4ўўоџ srcfileўоџ srcrefў кџhџоџ srcrefў   Bкџhџоџ srcrefў   3кџhџоџ srcrefў   &кџhџоџ srcrefў  кџhџоџ srcrefў кџhџоџ srcrefў -кџhџоџ srcrefў :кџhџоџ srcrefў кџhџоџ srcrefў 6кџhџоџ srcrefў  2кџhџоџ srcrefў 34<кџhџоџ srcrefўкџhџўџ џLџЧџўџџ$џџ?№ўўўџ џ џ?№ўўџ nam$џџџџ џў (џ ў?№ў?№ўўџџџџџ .epsџ .pdfўў џ &jџ is.character§џўAџџ§џў?№ўў џџ§џџ§џўў /ўўџ§џџ§џ /џ ўўў џMџџў џ2џ$џeџ?№ў nn-nnўйџ кџhџоџ srcrefў 8кџhџоџ srcrefў кџhџоџ srcrefў кџhџоџ srcrefў %кџhџоџ srcrefўкџhџўџ џLџMџfџўўџџџџiџfџў?№ўўџџiџўў џ2џџџў?№ўџџџ џўўўџ nn2џ џ2џџ$џџ@ўў?№ў 0 ў$џџ@ўџ ўў џAџџ$џџ?№ўўўйџ  Oкџhџоџ srcrefў  /кџhџоџ srcrefў  Gкџhџоџ srcrefўкџhџўџџ numstart$џ which %in% unlistџ$џџ?№ў ўўџoџ@"ўўўў?№ўўџ nn1џ$џџ?№ўmџўўџqџџ џ2џџqџў?№ў 0 ўqџ -џ ўўўџqџ ўўџџџqџlџџ ўўўџџiџўўў џjџAџџџў@ў2џџџџџџџўџџўў?№ўўџўўџџ ўўџџџ§џџџџ ўўџџ Output will be directed to file:џўўџџ$џџ?№ўўџџџџџџџџўў џЧџйџ !!кџhџоџ srcrefў "'Dкџhџоџ srcrefў ))Rкџhџоџ srcrefўкџhџўџgџџў џ2џџ psўџџџџџ џ џ џ џgџgџ џ џ џ џ,џўџџџџџgџgџ џ џ џ џ џ џ,џўўџ"џџ"џDџ$џџ?№ў џ$џџ@ўўўўў џ џџ ўйџ ,,кџhџоџ srcrefў -1Fкџhџоџ srcrefўкџhџўџџџ џ џўў џ2џџ psўџџџ!џ special џ џgџgџ џ џ џ џџ$џџ?№ў,џўџџџ!џ specialgџgџ џ џ џ џџ$џџ?№ў,џўўўўў џЧџџ"џџ"џDџ$џџ?№ў џ$џџ@ўўўўўўў