hexTapply | R Documentation |
A wrapper for tapply except that it operates with each hexagon bin being the category. The function operates on the data associated on the points from each bin.
hexTapply(hbin, dat, FUN = sum, ..., simplify=TRUE)
hbin |
a object of class |
dat |
A vector of data the same length as |
FUN |
the function to be applied. In the case of functions like
|
... |
optional arguments to |
simplify |
If |
This function is a wrapper for tapply, except that the cell id is always the categorical variable. This function is specifically good for adding variables to the cAtt slot of a hexbin object or for plotting a third variable in a hexagon plot. See below for examples.
Returns a vector of the result of 'FUN' as in
tapply
. See tapply
for detailed
description of output.
Nicholas Lewin-Koh
tapply
,hexbin
data(NHANES)
hbin<-hexbin(log(NHANES$Diet.Iron+1),log(NHANES$BMI),xbins=25,IDs=TRUE)
hvp<-plot(hbin)
mtrans<-hexTapply(hbin,NHANES$Transferin,median,na.rm=TRUE)
pushHexport(hvp$plot.vp)
grid.hexagons(hbin,style='lattice',pen=0,border='red',use.count=FALSE,
cell.at=mtrans)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.