Learn R Programming

sits (version 0.13.0)

sits_cluster_dendro: Clusters a set of time series using aglomerative hierarchical clustering

Description

Takes a SITS tibble and produces a sits tibble with an added "cluster" column. This is done in several steps: 1. Calculation of the dendrogram; 2. Get validity index for best cluster using the adjusted Rand Index; 3. Cut the dendrogram using the chosen validity index.

Usage

sits_cluster_dendro(
  samples = NULL,
  bands = NULL,
  dist_method = "dtw_basic",
  linkage = "ward.D2",
  k = NULL,
  colors = "RdYlGn",
  .plot = TRUE,
  ...
)

Arguments

samples

A tibble with input set of time series

bands

Bands to be used in the clustering

dist_method

String with one of the supported distances.

linkage

String with agglomeration method to be used. Can be any `hclust` method (see `hclust`). Default is 'ward.D2'.

k

Desired number of clusters (overrides default value)

colors

Color scheme as per .sits_brewer_color_name` function.

.plot

Plot the dendrogram?

...

Additional parameters to be passed to dtwclust::tsclust() function.

Value

A tibble with the clusters or clusters' members.

References

"dtwclust" package (https://CRAN.R-project.org/package=dtwclust)

Examples

Run this code
# NOT RUN {
# Load the "dtwclust" package
# library(dtwclust)
# load a simple data set with two classes
data(cerrado_2classes)
# calculate the dendrogram and the best clusters
clusters <- sits_cluster_dendro(cerrado_2classes, bands = c("NDVI", "EVI"))
# }

Run the code above in your browser using DataLab