y <- c(52,55,80,45,60,34,45,68,26,70,85,54,55,40,55,50,71,55,70,55,60,65,66,55,90,55,60,35,55,26,14,45,35,65,35,60,60,60,65,45,20,50,60,48,40,55,54,40,40,34,60,30,75,24,30,80,60,46,35,60,75,54,78,20,45,60,70,35,20,60,20,50,50,75,70,20,45,20,50,55,15,26,25,30,60,40,40,50)
x <- c(111,102,108,109,118,79,88,102,105,92,131,104,83,84,85,110,121,120,100,94,89,93,128,84,127,106,129,82,106,109,91,111,105,118,103,101,101,95,108,95,98,82,100,100,107,95,97,93,81,89,111,95,106,83,81,115,112,92,85,95,115,91,107,102,86,96,114,105,82,120,88,90,85,106,109,75,91,96,108,86,98,99,95,88,111,103,107,118)
par2 = 'two.sided'
par1 = 'pearson'
ylab = 'Grade'
xlab = 'IQ'
postscript(file="/var/fisher/rcomp/tmp/1m4lj1385641462.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 
plot(x,y, xlab=xlab, ylab=ylab)
abline(coef=(lm(y ~ x))$coeff, col='red')
ctp<-cor.test(x, y, use='pair', method='pearson')
legend('bottomright', c('cor =', as.character(round(ctp$estimate, digits=4))))
dev.off()
(sw1<-shapiro.test(x))
(sw2<-shapiro.test(y))
(cxy<-cor.test(x, y, method=par1))

#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,paste('Shapiro Test (', xlab,')',sep=''),3,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Statistic W',header=TRUE)
a<-table.element(a,'Probability',header=TRUE)
a<-table.element(a,'Link',header=TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,round(sw1$statistic, digits=4))
a<-table.element(a,round(sw1$p.value, digits=4))
a<-table.element(a,hyperlink('http://en.wikipedia.org/wiki/Shapiro%E2%80%93Wilk_test','Shapiro-Wilk Test','Shapiro-Wilk Test'))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/fisher/rcomp/tmp/27zi61385641462.tab") 
a<-table.start()
a<-table.row.start(a)
a<-table.element(a, paste('Shapiro Test (', ylab,')',sep=''),3,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Statistic W',header=TRUE)
a<-table.element(a,'probability',header=TRUE)
a<-table.element(a,'Link',header=TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,round(sw2$statistic, digits=4))
a<-table.element(a,round(sw2$p.value, digits=4))
a<-table.element(a,hyperlink('http://en.wikipedia.org/wiki/Shapiro%E2%80%93Wilk_test','Shapiro-Wilk Test','Shapiro-Wilk Test'))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/fisher/rcomp/tmp/3nbm41385641462.tab") 
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Correlation Test X-Y',5,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Statistic',header=TRUE)
a<-table.element(a,'Value',header=TRUE)
a<-table.element(a,'probability',header=TRUE)
a<-table.element(a,'Method',header=TRUE)
a<-table.element(a,'alternative',header=TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,names(cxy$estimate))
a<-table.element(a,round(cxy$estimate, digits=4))
a<-table.element(a,round(cxy$p.value, digits=4))
a<-table.element(a,cxy$method)
a<-table.element(a,cxy$alternative)
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/fisher/rcomp/tmp/45hm51385641462.tab") 

try(system("convert tmp/1m4lj1385641462.ps tmp/1m4lj1385641462.png",intern=TRUE))

