Takes two arrays defining the nodes of a grid over a 2D covariate space and two arrays
defining the location of data in that space, and returns a logical vector with elements
the corresponding node is too far from data and
FALSE otherwise. Basically a service routine for
co-ordinates of grid relative to first axis.
co-ordinates of grid relative to second axis.
co-ordinates of data relative to first axis.
co-ordinates of data relative to second axis.
how far away counts as too far. Grid and data are first scaled so that the grid lies exactly
in the unit square, and
Linear scalings of the axes are first determined so that the grid defined by the nodes in
g2 lies exactly in the unit square (i.e. on [0,1] by [0,1]). These scalings are
d2. The minimum Euclidean
distance from each node to a datum is then determined and if it is greater than
corresponding entry in the returned array is set to
TRUE (otherwise to
distance calculations are performed in compiled code for speed without storage overheads.
A logical array with
TRUE indicating a node in the grid defined by
is ‘too far’ from any datum.
Simon N. Wood firstname.lastname@example.org
library(mgcv) x<-rnorm(100);y<-rnorm(100) # some "data" n<-40 # generate a grid.... mx<-seq(min(x),max(x),length=n) my<-seq(min(y),max(y),length=n) gx<-rep(mx,n);gy<-rep(my,rep(n,n)) tf<-exclude.too.far(gx,gy,x,y,0.1) plot(gx[!tf],gy[!tf],pch=".");points(x,y,col=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.