Compute a histogram from xy data given set of breakpoints.
Arguments
- xy
Numeric. A data.frame
, or object coercible to a data.frame
with as.data.frame()
, where the columns of the data.frame
are,
or can be, interpreted as XY coordinates.
- breaks
List. A list of vectors, one for each dimension of xy
, where
each vector gives the breakpoints between the histogram cells.
Value
A list with three components:
x
The X dimension breakpoints.
y
The Y dimension breakpoints.
z
A frequency table of the number of xy
points in each cell.
Examples
set.seed(1L)
hist_xy(matrix(runif(50), 25), list(seq(0, 1, .2), seq(0, 1, .2)))
#> $x
#> [1] 0.0 0.2 0.4 0.6 0.8 1.0
#>
#> $y
#> [1] 0.0 0.2 0.4 0.6 0.8 1.0
#>
#> $z
#> y
#> x 1 2 3 4 5
#> 1 0 0 0 2 1
#> 2 2 2 1 3 0
#> 3 0 1 0 0 1
#> 4 2 0 4 1 0
#> 5 0 0 2 2 1
#>