Builds a shared nearest-neighbour graph from the input data and applies
the Louvain algorithm (igraph::cluster_louvain()) to detect
communities.
Arguments
- data
matrix or data.frame. Rows are observations, columns are variables.
- vars
character vector or
NULL. Column names to use for clustering. IfNULL(default), all columns are used.- k
integer(1). Number of nearest neighbours used to build the kNN graph. Default
15L.- resolution
numeric(1). Resolution parameter passed to
igraph::cluster_louvain(). Higher values yield more (smaller) clusters. Default1.
Value
A character vector of cluster labels, one per row of data.
Labels are of the form "1", "2", etc.
Details
The function:
Scales the selected columns to zero mean and unit variance.
Finds the
knearest neighbours for each observation using Euclidean distance (viaFNN::get.knn()).Constructs a shared-nearest-neighbour (SNN) graph where the edge weight between two observations equals the number of shared neighbours.
Applies Louvain community detection on the SNN graph.