get_coma: Create a co-occurrence matrix (coma)

Description Usage Arguments Value Examples

View source: R/get_coma.R

Description

Create a co-occurrence matrix (coma)

Usage

1
get_coma(x, neighbourhood = 4, classes = NULL)

Arguments

x

A matrix with categories

neighbourhood

The number of directions in which cell adjacencies are considered as neighbours: 4 (rook's case) or 8 (queen's case). The default is 4.

classes

A vector or a list with the values of selected classes from the x object. It is used to calculate coma only for selected classes.

Value

A co-occurrence matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#library(comat)
data(raster_x, package = "comat")

com = get_coma(raster_x)
com

com2 = get_coma(raster_x, classes = c(1, 3))
com2

data(raster_x_na, package = "comat")
com3 = get_coma(raster_x_na, classes = c(0:3, NA))
com3

Example output

  1 2 3
1 4 1 3
2 1 2 2
3 3 2 6
  1 3
1 4 3
3 3 6
     0 1 2 3 <NA>
0    0 0 0 0    0
1    0 2 0 2    1
2    0 0 2 1    2
3    0 2 1 0    3
<NA> 0 1 2 3    2

comat documentation built on Oct. 14, 2021, 5:22 p.m.