# load the data: source("/home/longa/www/Rweb/examples/illdat.splus") # we need the interpolation library: library("akima") # we now interpolate the liver cancer variable liver <- interp(illdat$easting,illdat$northing,illdat$liver) persp(liver,scale=F) title(main="Liver Cancer in Illinois, as viewed from the South") par(mfrow = c(1,2), oma = c(0,0,5,0)) plot(illdat$northing,illdat$easting,main="data locations",xlab="easting",ylab="northing") image(liver$y,liver$x,t(liver$z),main="Interpolated via image",xlab="easting",ylab="northing") points(illdat$northing,illdat$easting) # contour(liver$x,liver$y,liver$z,add=T) # - hangs on NA values, for some reason # liver$z[!is.finite(liver$z)] <- mean(illdat$liver) # this would "fix" it, but is undesirable.... r.ak <- sapply(liver, function(x) diff(range(x,na.rm = T))) par(mfrow = c(1,2), oma = c(0,0,5,0)) persp(liver, phi=62,scale=F) persp(liver, theta=45, phi=62,scale=F) par(mfrow = c(1,1), oma = c(0,0,5,0)) title(main="Liver Cancer in Illinois?") par(mfrow = c(1,2), oma = c(0,0,5,0)) persp(liver, theta=90, phi=62,scale=F) persp(liver, theta=135, phi=62,scale=F) par(mfrow = c(1,1), oma = c(0,0,5,0)) title(main="Liver Cancer in Illinois?")