y <- c(20,40,30,50,60)
x <- c(80,60,10,20,30)
ylab = 'Y'
xlab = 'X'
#'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
#Author: Prof. Dr. P. Wessa
#To cite this work: Wessa, (2007), Kendall tau Rank Correlation (v1.0.9) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_kendall.wasp/
#Source of accompanying publication: Office for Research, Development, and Education
#Technical description: uses the Kendall library. The dataset is about O-rings of the Challenger space shuttle - sourcecomes from http://exploringdata.cqu.edu.au/ws_scatr.htm : x = temperature  y = damage index.
library('Kendall')
k <- Kendall(x,y)
postscript(file="/var/www/html/rcomp/tmp/121491192302904.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 

plot(x,y,main='Scatterplot',xlab=xlab,ylab=ylab)
grid()
dev.off()
postscript(file="/var/www/html/rcomp/tmp/2rnot1192302904.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 

plot(rank(x),rank(y),main='Scatterplot of Ranks',xlab=xlab,ylab=ylab)
grid()
dev.off()
load(file='/var/www/html/rcomp/createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Kendall tau Rank Correlation',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Kendall tau',header=TRUE)
a<-table.element(a,k$tau)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'2-sided p-value',header=TRUE)
a<-table.element(a,k$sl)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Score',header=TRUE)
a<-table.element(a,k$S)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Var(Score)',header=TRUE)
a<-table.element(a,k$varS)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Denominator',header=TRUE)
a<-table.element(a,k$D)
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/www/html/rcomp/tmp/3gfkl1192302904.tab") 

system("convert tmp/121491192302904.ps tmp/121491192302904.png")
system("convert tmp/2rnot1192302904.ps tmp/2rnot1192302904.png")

