
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
at the boundaries between bins, calculated using
pretty(x)
if not supplied.y
at the boundaries between bins, calculated using
pretty(y)
if not supplied.x
, y
, z
and n
, a flattened
representation of xmids
, ymids
, result
and
number
.NA
-value gaps in
the matrix. Gaps will be filled as the average of linear interpolations
across rows and columns. See fillgap
, which works together with this.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.
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)
Run the code above in your browser using DataLab