R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(222,223,179,335,286,154,443,165,275,304,303,342,322,291,300,491,266,176) > par1 = '12' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), Mean Plot (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_meanplot.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > par1 <- as.numeric(par1) > (n <- length(x)) [1] 18 > (np <- floor(n / par1)) [1] 1 > arr <- array(NA,dim=c(par1,np+1)) > darr <- array(NA,dim=c(par1,np+1)) > ari <- array(0,dim=par1) > dx <- diff(x) > j <- 0 > for (i in 1:n) + { + j = j + 1 + ari[j] = ari[j] + 1 + arr[j,ari[j]] <- x[i] + darr[j,ari[j]] <- dx[i] + if (j == par1) j = 0 + } > ari [1] 2 2 2 2 2 2 1 1 1 1 1 1 > arr [,1] [,2] [1,] 222 322 [2,] 223 291 [3,] 179 300 [4,] 335 491 [5,] 286 266 [6,] 154 176 [7,] 443 NA [8,] 165 NA [9,] 275 NA [10,] 304 NA [11,] 303 NA [12,] 342 NA > darr [,1] [,2] [1,] 1 -31 [2,] -44 9 [3,] 156 191 [4,] -49 -225 [5,] -132 -90 [6,] 289 NA [7,] -278 NA [8,] 110 NA [9,] 29 NA [10,] -1 NA [11,] 39 NA [12,] -20 NA > arr.mean <- array(NA,dim=par1) > arr.median <- array(NA,dim=par1) > arr.midrange <- array(NA,dim=par1) > for (j in 1:par1) + { + arr.mean[j] <- mean(arr[j,],na.rm=TRUE) + arr.median[j] <- median(arr[j,],na.rm=TRUE) + arr.midrange[j] <- (quantile(arr[j,],0.75,na.rm=TRUE) + quantile(arr[j,],0.25,na.rm=TRUE)) / 2 + } > overall.mean <- mean(x) > overall.median <- median(x) > overall.midrange <- (quantile(x,0.75) + quantile(x,0.25)) / 2 > postscript(file="/var/wessaorg/rcomp/tmp/1mk521444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(arr.mean,type='b',ylab='mean',main='Mean Plot',xlab='Periodic Index') > mtext(paste('#blocks = ',np)) > abline(overall.mean,0) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2q70q1444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(arr.median,type='b',ylab='median',main='Median Plot',xlab='Periodic Index') > mtext(paste('#blocks = ',np)) > abline(overall.median,0) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/34v0n1444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(arr.midrange,type='b',ylab='midrange',main='Midrange Plot',xlab='Periodic Index') > mtext(paste('#blocks = ',np)) > abline(overall.midrange,0) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/4h9y61444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > z <- data.frame(t(arr)) > names(z) <- c(1:par1) > (boxplot(z,notch=TRUE,col='grey',xlab='Periodic Index',ylab='Value',main='Notched Box Plots - Periodic Subseries')) $stats [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 222 223 179.0 335 266 154 443 165 275 304 303 342 [2,] 222 223 179.0 335 266 154 443 165 275 304 303 342 [3,] 272 257 239.5 413 276 165 443 165 275 304 303 342 [4,] 322 291 300.0 491 286 176 443 165 275 304 303 342 [5,] 322 291 300.0 491 286 176 443 165 275 304 303 342 $n [1] 2 2 2 2 2 2 1 1 1 1 1 1 $conf [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 160.2771 181.0284 104.3153 238.7123 253.6554 140.421 443 165 275 304 [2,] 383.7229 332.9716 374.6847 587.2877 298.3446 189.579 443 165 275 304 [,11] [,12] [1,] 303 342 [2,] 303 342 $out numeric(0) $group numeric(0) $names [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" Warning message: In bxp(list(stats = c(222, 222, 272, 322, 322, 223, 223, 257, 291, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/5hub21444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > z <- data.frame(t(darr)) > names(z) <- c(1:par1) > (boxplot(z,notch=TRUE,col='grey',xlab='Periodic Index',ylab='Value',main='Notched Box Plots - Differenced Periodic Subseries')) $stats [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] -31 -44.0 156.0 -225 -132 289 -278 110 29 -1 39 -20 [2,] -31 -44.0 156.0 -225 -132 289 -278 110 29 -1 39 -20 [3,] -15 -17.5 173.5 -137 -111 289 -278 110 29 -1 39 -20 [4,] 1 9.0 191.0 -49 -90 289 -278 110 29 -1 39 -20 [5,] 1 9.0 191.0 -49 -90 289 -278 110 29 -1 39 -20 $n [1] 2 2 2 2 2 1 1 1 1 1 1 1 $conf [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] -50.75132 -76.71312 134.397 -333.63225 -157.92361 289 -278 110 29 [2,] 20.75132 41.71312 212.603 59.63225 -64.07639 289 -278 110 29 [,10] [,11] [,12] [1,] -1 39 -20 [2,] -1 39 -20 $out numeric(0) $group numeric(0) $names [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" Warning message: In bxp(list(stats = c(-31, -31, -15, 1, 1, -44, -44, -17.5, 9, 9, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/62ywo1444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > z <- data.frame(arr) > names(z) <- c(1:np) > (boxplot(z,notch=TRUE,col='grey',xlab='Block Index',ylab='Value',main='Notched Box Plots - Sequential Blocks')) $stats [,1] [,2] [1,] 154.0 266.0 [2,] 200.5 266.0 [3,] 280.5 295.5 [4,] 319.5 322.0 [5,] 443.0 322.0 $n [1] 12 6 $conf [,1] [,2] [1,] 226.2233 259.3782 [2,] 334.7767 331.6218 $out [1] 491 176 $group [1] 2 2 $names [1] "1" NA Warning message: In bxp(list(stats = c(154, 200.5, 280.5, 319.5, 443, 266, 266, 295.5, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/7eow61444981465.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > z <- data.frame(cbind(arr.mean,arr.median,arr.midrange)) > names(z) <- list('mean','median','midrange') > (boxplot(z,notch=TRUE,col='grey',ylab='Overall Central Tendency',main='Notched Box Plots')) $stats [,1] [,2] [,3] [1,] 165.00 165.00 165.00 [2,] 248.25 248.25 248.25 [3,] 275.50 275.50 275.50 [4,] 323.00 323.00 323.00 [5,] 413.00 413.00 413.00 $n [1] 12 12 12 $conf [,1] [,2] [,3] [1,] 241.406 241.406 241.406 [2,] 309.594 309.594 309.594 $out [1] 443 443 443 $group [1] 1 2 3 $names [1] "mean" "median" "midrange" Warning message: In bxp(list(stats = c(165, 248.25, 275.5, 323, 413, 165, 248.25, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > > try(system("convert tmp/1mk521444981465.ps tmp/1mk521444981465.png",intern=TRUE)) character(0) > try(system("convert tmp/2q70q1444981465.ps tmp/2q70q1444981465.png",intern=TRUE)) character(0) > try(system("convert tmp/34v0n1444981465.ps tmp/34v0n1444981465.png",intern=TRUE)) character(0) > try(system("convert tmp/4h9y61444981465.ps tmp/4h9y61444981465.png",intern=TRUE)) character(0) > try(system("convert tmp/5hub21444981465.ps tmp/5hub21444981465.png",intern=TRUE)) character(0) > try(system("convert tmp/62ywo1444981465.ps tmp/62ywo1444981465.png",intern=TRUE)) character(0) > try(system("convert tmp/7eow61444981465.ps tmp/7eow61444981465.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.358 0.425 2.807