R version 2.12.1 (2010-12-16) Copyright (C) 2010 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. > y <- c(21,15,18,11,8,19,4,20,16,14,10,13,14,8,23,11,9,24,5,15,5,19,6,13,11,17,17,5,9,15,17,17,20,12,7,16,7,14,24,15,15,10,14,18,12,9,9,8,18,10,17,14,16,10,19,10,14,10,4,19,9,12,16,11,18,11,24,17,18,9,19,18,12,23,22,14,14,16,23,7,10,12,12,12,17,21,16,11,14,13,9,19,13,19,13,13,13,14,12,22,11,5,18,19,14,15,12,19,15,17,8,10,12,12,20,12,12,14,6,10,18,18,7,18,9,17,22,11,15,17,15,22,9,13,20,14,14,12,20,20,8,17,9,18,22,10,13,15,18,18,12,12,20,12,16,16,18,16,13,17,13,17) > x <- c(26,20,19,19,20,25,25,22,26,22,17,22,19,24,26,21,13,26,20,22,14,21,7,23,17,25,25,19,20,23,22,22,21,15,20,22,18,20,28,22,18,23,20,25,26,15,17,23,21,13,18,19,22,16,24,18,20,24,14,22,24,18,21,23,17,22,24,21,22,16,21,23,22,24,24,16,16,21,26,15,25,18,23,20,17,25,24,17,19,20,15,27,22,23,16,19,25,19,19,26,21,20,24,22,20,18,18,24,24,22,23,22,20,18,25,18,16,20,19,15,19,19,16,17,28,23,25,20,17,23,16,23,11,18,24,23,21,16,24,23,18,20,9,24,25,20,21,25,22,21,21,22,27,24,24,21,18,16,22,20,18,20) > par8 = 'terrain.colors' > par7 = 'Y' > par6 = 'Y' > par5 = '0' > par4 = '0' > par3 = '0' > par2 = '50' > par1 = '50' > ylab = 'y' > xlab = 'x' > main = 'Bivariate Kernel Density' > par1 <- as(par1,'numeric') > par2 <- as(par2,'numeric') > par3 <- as(par3,'numeric') > par4 <- as(par4,'numeric') > par5 <- as(par5,'numeric') > library('GenKern') Loading required package: KernSmooth KernSmooth 2.23 loaded Copyright M. P. Wand 1997-2009 > if (par3==0) par3 <- dpik(x) > if (par4==0) par4 <- dpik(y) > if (par5==0) par5 <- cor(x,y) > if (par1 > 500) par1 <- 500 > if (par2 > 500) par2 <- 500 > if (par8 == 'terrain.colors') mycol <- terrain.colors(100) > if (par8 == 'rainbow') mycol <- rainbow(100) > if (par8 == 'heat.colors') mycol <- heat.colors(100) > if (par8 == 'topo.colors') mycol <- topo.colors(100) > if (par8 == 'cm.colors') mycol <- cm.colors(100) > postscript(file="/var/www/rcomp/tmp/1fwnw1322752575.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- KernSur(x,y, xgridsize=par1, ygridsize=par2, correlation=par5, xbandwidth=par3, ybandwidth=par4) > image(op$xords, op$yords, op$zden, col=mycol, axes=TRUE,main=main,xlab=xlab,ylab=ylab) > if (par6=='Y') contour(op$xords, op$yords, op$zden, add=TRUE) > if (par7=='Y') points(x,y) > (r<-lm(y ~ x)) Call: lm(formula = y ~ x) Coefficients: (Intercept) x 0.6762 0.6550 > abline(r) > box() > dev.off() null device 1 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Bandwidth',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'x axis',header=TRUE) > a<-table.element(a,par3) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'y axis',header=TRUE) > a<-table.element(a,par4) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Correlation',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'correlation used in KDE',header=TRUE) > a<-table.element(a,par5) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'correlation(x,y)',header=TRUE) > a<-table.element(a,cor(x,y)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/2s3ez1322752575.tab") > > try(system("convert tmp/1fwnw1322752575.ps tmp/1fwnw1322752575.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.928 0.100 1.072