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. > y <- c(1024,768,700,768,800,1024,800,768,800,1024,800,800,1024,949,900,1200,800,800,768,735,800,845,900,768,768,768,800,1440,768,768,1024,800,900,800,900,768,900,857,800,900,800,768,768,880,768,735,1200,785,800,800,900,1050,900,768,641,1024,800,800,800,800,900,800,864,1024,800,900,800,1024,900,800,800,900,800,1024,900,768,768,800,800,900,768,800,768,800,900,800,800,880,800,900,900,1050,900,900,550,800,990,800,800,800,768,768,900,800,1024,1080,768,768,900,698,900,737,768,640,800,900,800,800,800,900,800,768,768,864,768,768,768,1050,1050,800,768,768,900,768,800,800,800,768,800) > x <- c(1280,1024,1120,1024,1280,1280,1280,1024,1280,1280,1280,1280,1280,1688,1440,1600,1280,1280,1280,1176,1280,1503,1440,1366,1280,1024,1280,2560,1280,1024,1280,1280,1440,1280,1440,1024,1440,1143,1280,1440,1280,1366,1024,1408,1366,1176,1920,1257,1280,1280,1440,1680,1440,1024,1140,1280,1280,1280,1280,1280,1440,1280,1152,1280,1280,1440,1280,1280,1440,1280,1280,1440,1280,1280,1600,1024,1366,1280,1280,1440,1366,1280,1024,1280,1440,1280,1280,1408,1280,1600,1600,1680,1440,1440,917,1280,1760,1280,1280,1280,1024,1366,1440,1280,1280,1920,1024,1024,1600,1117,1440,983,1024,1024,1280,1440,1280,1280,1280,1440,1280,1024,1024,1152,1280,1024,1366,1680,1680,1280,1366,1024,1440,1024,1280,1280,1280,1024,1280) > 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/wessaorg/rcomp/tmp/1xswq1321438291.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 308.0495 0.4098 > abline(r) > box() > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/2hyfa1321438291.tab") > > try(system("convert tmp/1xswq1321438291.ps tmp/1xswq1321438291.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.383 0.178 5.591