rasterize: Bin environmental data

Description Usage Arguments Value Examples

Description

Bin each environment variable and count the number of observation of all combinations of bins. Is then used to filter out rare combinations of variables.

Usage

1
rasterize(X, n = 10, precision = NULL, breaks = NULL)

Arguments

X

matrix (or data.frame) of environmental data.

n

number of bins for each variable in the data (either one number or a vector with one number per column of X).

precision

the precision used to cut each column of the data into bins (either one number or a vector with one number per column of X); overrides n.

breaks

list of vectors of cut points for each variable (should have as many elements as columns in X); overrides n and precision.

Value

A data.frame with all observed combinations of binned variables and a column n containing the number of observations of this combination. Each bin is identified by the average value of each variable in the bin. Therefore, it changes from bin to bin, i.e. even with a precision of 0.1, binned values are not all 0.05, 0.15, etc.

Examples

1
2
3
4
5
6
X <- data.frame(a=runif(100), b=runif(100)*10)
rasterize(X, n=2)
rasterize(X, n=c(2,4))
rasterize(X, precision=1)
rasterize(X, precision=c(0.5, 5))
rasterize(X, breaks=list(c(0, 0.5, 1), c(0, 2, 4, 10)))

jiho/nppen documentation built on May 19, 2019, 10:31 a.m.