R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(13.5,8.4,10.5,9,9.2,9.7,6.6,10.6,10.1,7.1,8,7.9,6.8,9.5,8.1,13.5,9.9,6.9,7.5,11.1,8.2,8,7.7,7.4,6.5,9.5,8.2,6.9,7.2,8.2,9.6,7.2,8.8,11.3,8.5,9.4,10.5,6.9,6.5,7.5,7.1,13.2,7.7,5.9,5.2,5.6,11.7,6,7.8,6.5) > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), Percentiles (v1.0.6) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_percentiles.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > x <-sort(x[!is.na(x)]) > q1 <- function(data,n,p,i,f) { + np <- n*p; + i <<- floor(np) + f <<- np - i + qvalue <- (1-f)*data[i] + f*data[i+1] + } > q2 <- function(data,n,p,i,f) { + np <- (n+1)*p + i <<- floor(np) + f <<- np - i + qvalue <- (1-f)*data[i] + f*data[i+1] + } > q3 <- function(data,n,p,i,f) { + np <- n*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i] + } else { + qvalue <- data[i+1] + } + } > q4 <- function(data,n,p,i,f) { + np <- n*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- (data[i]+data[i+1])/2 + } else { + qvalue <- data[i+1] + } + } > q5 <- function(data,n,p,i,f) { + np <- (n-1)*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i+1] + } else { + qvalue <- data[i+1] + f*(data[i+2]-data[i+1]) + } + } > q6 <- function(data,n,p,i,f) { + np <- n*p+0.5 + i <<- floor(np) + f <<- np - i + qvalue <- data[i] + } > q7 <- function(data,n,p,i,f) { + np <- (n+1)*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i] + } else { + qvalue <- f*data[i] + (1-f)*data[i+1] + } + } > q8 <- function(data,n,p,i,f) { + np <- (n+1)*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i] + } else { + if (f == 0.5) { + qvalue <- (data[i]+data[i+1])/2 + } else { + if (f < 0.5) { + qvalue <- data[i] + } else { + qvalue <- data[i+1] + } + } + } + } > lx <- length(x) > qval <- array(NA,dim=c(99,8)) > mystep <- 25 > mystart <- 25 > if (lx>10){ + mystep=10 + mystart=10 + } > if (lx>20){ + mystep=5 + mystart=5 + } > if (lx>50){ + mystep=2 + mystart=2 + } > if (lx>=100){ + mystep=1 + mystart=1 + } > for (perc in seq(mystart,99,mystep)) { + qval[perc,1] <- q1(x,lx,perc/100,i,f) + qval[perc,2] <- q2(x,lx,perc/100,i,f) + qval[perc,3] <- q3(x,lx,perc/100,i,f) + qval[perc,4] <- q4(x,lx,perc/100,i,f) + qval[perc,5] <- q5(x,lx,perc/100,i,f) + qval[perc,6] <- q6(x,lx,perc/100,i,f) + qval[perc,7] <- q7(x,lx,perc/100,i,f) + qval[perc,8] <- q8(x,lx,perc/100,i,f) + } > postscript(file="/var/fisher/rcomp/tmp/1q2qo1355649917.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myqqnorm <- qqnorm(x,col=2) > qqline(x) > grid() > dev.off() null device 1 > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Percentiles - Ungrouped Data',9,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'p',1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_1.htm', 'Weighted Average at Xnp',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_2.htm','Weighted Average at X(n+1)p',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_3.htm','Empirical Distribution Function',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_4.htm','Empirical Distribution Function - Averaging',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_5.htm','Empirical Distribution Function - Interpolation',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_6.htm','Closest Observation',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_7.htm','True Basic - Statistics Graphics Toolkit',''),1,TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/method_8.htm','MS Excel (old versions)',''),1,TRUE) > a<-table.row.end(a) > for (perc in seq(mystart,99,mystep)) { + a<-table.row.start(a) + a<-table.element(a,round(perc/100,2),1,TRUE) + for (j in 1:8) { + a<-table.element(a,round(qval[perc,j],6)) + } + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/286jy1355649917.tab") > > try(system("convert tmp/1q2qo1355649917.ps tmp/1q2qo1355649917.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.944 0.262 1.184