binMean2D {oce} | R Documentation |
Average the values of a vector f(x,y)
in bins defined on
vectors x
and y
. A common example might be averaging
spatial data into location bins.
binMean2D(x, y, f, xbreaks, ybreaks, flatten = FALSE, fill = FALSE, fillgap = -1)
x |
Vector of numerical values. |
y |
Vector of numerical values. |
f |
Matrix of numerical values, a matrix f=f(x,y). |
xbreaks |
Vector of values of |
ybreaks |
Vector of values of |
flatten |
A logical value indicating whether
the return value also contains equilength
vectors |
fill |
Logical value indicating whether to fill |
fillgap |
Integer controlling the size of gap that can be filled across. If this is negative (as in the default), gaps will be filled regardless of their size. If it is positive, then gaps exceeding this number of indices will not be filled. |
A list with the following elements: the midpoints (renamed as
x
and y
), the count (number
) of f(x,y)
values
for x
and y
values that lie between corresponding breaks,
and the resultant average (f
) of f(x,y)
, classified by the
x
and y
breaks.
Dan Kelley
Other bin-related functions: binApply1D
,
binApply2D
, binAverage
,
binCount1D
, binCount2D
,
binMean1D
library(oce) x <- runif(500) y <- runif(500) f <- x + y xb <- seq(0, 1, 0.1) yb <- seq(0, 1, 0.2) m <- binMean2D(x, y, f, xb, yb) plot(x, y) contour(m$xmids, m$ymids, m$result, add=TRUE, levels=seq(0, 2, 0.5), labcex=1)