neighbors: Count neighbors.

Description Usage Arguments Details Value See Also

View source: R/caspr.R

Description

Count neighbors.

Usage

1
neighbors(x, state = levels(x$cells)[1])

Arguments

x

A landscape object.

state

A character value. The state to count. Defaults to the primary cell state, i.e. the first state given in levels(x$cells).

Details

This function is vectorised by using the mapping objects defined by a previous call of mapping.

Value

Returns a vector of the counts in the neighborhood of each cell in the landscape. Neighborhood is specified by the global mapping objects, by default the 4-cell neighborhood.

See Also

For counting the neighborhood of one target file, e.g. when doing sequential updating of randomly drawn cells, the function neighborsij is slightly faster. However, for such updating processes we recommend using C++ via Rcpp (see implementation of the predator prey model, predprey.R, for an example).


caspr documentation built on May 2, 2019, 5:25 p.m.