R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-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(1200,1400,1210,1260,1320,1320,1310,1260,1340,1180,1330,1390,1130,1340,1140,1290,1260,1280,1330,1270,1300,1150,1410,1250,1030,1320,1160,1300,1190,1310,1290,1320,1300,1230,1330,1220,1010,1290,1170,1240,1260,1260,1310,1360,1250,1170,1360,1140,1030,1260,1210,1190,1230,1350,1300,1340,1270,1220,1400,1120,1000,1260,1260,1150,1240,1360,1350,1280,1320,1210,1370,1060,1040,1260,1210,1200,1200,1290,1400,1280,1280,1220,1350,1000,980,1240,1190,1200,1150,1270,1410,1420,1260,1300,1410,1000,950,1280,1330,1190,1170,1270,1340,1470,1270,1280,1430,980) > 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] 108 > (np <- floor(n / par1)) [1] 9 > 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] 9 9 9 9 9 9 9 9 9 9 9 9 > arr [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1200 1130 1030 1010 1030 1000 1040 980 950 NA [2,] 1400 1340 1320 1290 1260 1260 1260 1240 1280 NA [3,] 1210 1140 1160 1170 1210 1260 1210 1190 1330 NA [4,] 1260 1290 1300 1240 1190 1150 1200 1200 1190 NA [5,] 1320 1260 1190 1260 1230 1240 1200 1150 1170 NA [6,] 1320 1280 1310 1260 1350 1360 1290 1270 1270 NA [7,] 1310 1330 1290 1310 1300 1350 1400 1410 1340 NA [8,] 1260 1270 1320 1360 1340 1280 1280 1420 1470 NA [9,] 1340 1300 1300 1250 1270 1320 1280 1260 1270 NA [10,] 1180 1150 1230 1170 1220 1210 1220 1300 1280 NA [11,] 1330 1410 1330 1360 1400 1370 1350 1410 1430 NA [12,] 1390 1250 1220 1140 1120 1060 1000 1000 980 NA > darr [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 200 210 290 280 230 260 220 260 330 NA [2,] -190 -200 -160 -120 -50 0 -50 -50 50 NA [3,] 50 150 140 70 -20 -110 -10 10 -140 NA [4,] 60 -30 -110 20 40 90 0 -50 -20 NA [5,] 0 20 120 0 120 120 90 120 100 NA [6,] -10 50 -20 50 -50 -10 110 140 70 NA [7,] -50 -60 30 50 40 -70 -120 10 130 NA [8,] 80 30 -20 -110 -70 40 0 -160 -200 NA [9,] -160 -150 -70 -80 -50 -110 -60 40 10 NA [10,] 150 260 100 190 180 160 130 110 150 NA [11,] 60 -160 -110 -220 -280 -310 -350 -410 -450 NA [12,] -260 -220 -210 -110 -120 -20 -20 -50 NA 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/1ha841344872994.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/2t33d1344872994.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/33gaw1344872994.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/4ubsa1344872994.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,] 950 1240 1140 1150 1150 1260 1290 1260 1250 1150 1330 980 [2,] 1000 1260 1170 1190 1190 1270 1310 1280 1270 1180 1350 1000 [3,] 1030 1280 1210 1200 1230 1290 1330 1320 1280 1220 1370 1120 [4,] 1040 1320 1210 1260 1260 1320 1350 1360 1300 1230 1410 1220 [5,] 1040 1400 1260 1300 1320 1360 1410 1470 1340 1300 1430 1390 $n [1] 9 9 9 9 9 9 9 9 9 9 9 9 $conf [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1008.933 1248.4 1188.933 1163.133 1193.133 1263.667 1308.933 1277.867 [2,] 1051.067 1311.6 1231.067 1236.867 1266.867 1316.333 1351.067 1362.133 [,9] [,10] [,11] [,12] [1,] 1264.2 1193.667 1338.4 1004.133 [2,] 1295.8 1246.333 1401.6 1235.867 $out [1] 1200 1130 1330 $group [1] 1 1 3 $names [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" Warning message: In bxp(list(stats = c(950, 1000, 1030, 1040, 1040, 1240, 1260, 1280, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/5wi7h1344872994.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,] 200 -200 -140 -110 0 -50 -120 -200 -160 100 -450 -260 [2,] 220 -160 -20 -30 20 -10 -60 -110 -110 130 -350 -215 [3,] 260 -50 10 0 100 50 10 -20 -70 150 -280 -115 [4,] 280 -50 70 40 120 70 40 30 -50 180 -160 -35 [5,] 330 50 150 90 120 140 130 80 40 190 60 -20 $n [1] 9 9 9 9 9 9 9 9 9 9 9 8 $conf [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 228.4 -107.933333 -37.4 -36.86667 47.33333 7.866667 -42.66667 -93.73333 [2,] 291.6 7.933333 57.4 36.86667 152.66667 92.133333 62.66667 53.73333 [,9] [,10] [,11] [,12] [1,] -101.6 123.6667 -380.0667 -215.55058 [2,] -38.4 176.3333 -179.9333 -14.44942 $out [1] 260 $group [1] 10 $names [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" Warning message: In bxp(list(stats = c(200, 220, 260, 280, 330, -200, -160, -50, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6ixp41344872994.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] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1180 1130 1160 1010 1030 1000 1200 980 950 NA [2,] 1235 1200 1205 1170 1200 1180 1200 1170 1180 NA [3,] 1315 1275 1295 1255 1245 1260 1240 1250 1275 NA [4,] 1335 1315 1315 1300 1320 1335 1285 1355 1335 NA [5,] 1400 1410 1330 1360 1400 1370 1400 1420 1470 NA $n [1] 12 12 12 12 12 12 12 12 12 0 $conf [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1269.389 1222.548 1244.828 1195.706 1190.267 1189.303 1201.231 1165.62 [2,] 1360.611 1327.452 1345.172 1314.294 1299.733 1330.697 1278.769 1334.38 [,9] [,10] [1,] 1204.303 NA [2,] 1345.697 NA $out [1] 1030 1040 1000 $group [1] 3 7 7 $names [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" NA Warning message: In bxp(list(stats = c(1180, 1235, 1315, 1335, 1400, 1130, 1200, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/7xf6r1344872994.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,] 1128.889 1120 1110.0 [2,] 1213.333 1205 1197.5 [3,] 1256.111 1255 1255.0 [4,] 1317.222 1305 1307.5 [5,] 1376.667 1370 1380.0 $n [1] 12 12 12 $conf [,1] [,2] [,3] [1,] 1208.727 1209.389 1204.828 [2,] 1303.496 1300.611 1305.172 $out [1] 1041.111 1030.000 1020.000 $group [1] 1 2 3 $names [1] "mean" "median" "midrange" Warning message: In bxp(list(stats = c(1128.88888888889, 1213.33333333333, 1256.11111111111, : some notches went outside hinges ('box'): maybe set notch=FALSE > dev.off() null device 1 > > try(system("convert tmp/1ha841344872994.ps tmp/1ha841344872994.png",intern=TRUE)) character(0) > try(system("convert tmp/2t33d1344872994.ps tmp/2t33d1344872994.png",intern=TRUE)) character(0) > try(system("convert tmp/33gaw1344872994.ps tmp/33gaw1344872994.png",intern=TRUE)) character(0) > try(system("convert tmp/4ubsa1344872994.ps tmp/4ubsa1344872994.png",intern=TRUE)) character(0) > try(system("convert tmp/5wi7h1344872994.ps tmp/5wi7h1344872994.png",intern=TRUE)) character(0) > try(system("convert tmp/6ixp41344872994.ps tmp/6ixp41344872994.png",intern=TRUE)) character(0) > try(system("convert tmp/7xf6r1344872994.ps tmp/7xf6r1344872994.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.208 0.504 2.709