morph function applies a kernel to a target array. Optionally, applying the kernel to a particular array element can be made conditional on its value, or the number of nonzero immediate neighbours that it has. The morph function is (S3) generic.morph(x, kernel, ...)## S3 method for class 'default':
morph(x, kernel, operator = c("+","-","*","i","1","0"),
merge = c("sum","min","max","mean","median"), value = NULL,
valueNot = NULL, nNeighbours = NULL, nNeighboursNot = NULL, ...)
x"i" is the identity operator, where every value within the kernel will be included as-is; avalueNot if both are specified.nNeighboursNot if both are specified.kernels for kernel-generating functions, and morphology for more specific mathematical morphology functions. gameOfLife shows how this function can be used for non-morphological purposes, in that case to power a cellular automaton. See also the kernel and kernapply functions in the stats package, particularly if you want to smooth time series.