# The clustering of a random matrix is close to one
ls <- 100 # lattice size
mm <- matrix(sample(c("sp1", "sp2", "sp3", "sp4"), size = ls^2, replace = TRUE),
nrow = ls, ncol = ls)
clust <- raw_clustering(mm, wrap = TRUE, use_8_nb = TRUE)
print(clust)
# Compute clustering along the gradient for the serengeti dataset
# \donttest{
data(forestgap)
clust_indic <- compute_indicator(serengeti, raw_clustering,
wrap = TRUE, use_8_nb = FALSE)
# The interesting one is the clustering of state 0 (FALSE in the original matrix),
# which corresponds to grassland pixels, which get more and more clustered with
# increasing rainfall (see also ?generic_sews for how that compares with generic
# indicators)
plot(clust_indic, along = serengeti.rain)
# Add null trend
clust_test <- indictest(clust_indic, nulln = 19)
plot(clust_test, along = serengeti.rain)
# Show the proportion of each pairs of states in the matrix...
pair_counts(serengeti[[5]])
# ... or the total count
pair_counts(serengeti[[5]], prop = FALSE)
# }
Run the code above in your browser using DataLab