a vector the same length as x with the hexagonal cell ID for each point
Arguments
hexbin
hexbin object to be referenced to.
x, y
coordinates or vectors of coordinates of the points.
xbins
number of bins partitioning the range of xbnds
xbnds, ybnds
horizontal and vertical limit of the binning region. Must be numeric vector of length 2.
shape
shape = yheight/xwidth of the plotting regions.
Details
If a hexbin object is not provided, parameters of the binning region (xbins, xbnds, ybnds, shape) can be used instead.
For finding the xy coordinates of the hexagons for a hexbin object, see hcell2xy.
library(hexbin)
set.seed(133)
d=hexDensity(x=rnorm(20000),y=rnorm(20000),xbins=50)
#Get KDE value at the coordinate x=0,y=0loc = xy2hcell(d,x=0,y=0)
d@count[loc]