View source: R/cluster_solutions.R
| cluster_solutions | R Documentation |
Takes the output of CTS_n_sources and groups the tracer
combinations into clusters of similar source contributions (w1, w2, ...).
This helps identify the dominant apportionment solutions and how many
individual tracers support each one.
cluster_solutions(
cts_result,
top_n = 50L,
k = NULL,
max_k = 6L,
interactive = FALSE,
seed = NULL
)
cts_result |
Data frame returned by |
top_n |
Integer. Number of top rows to use for clustering. Default 50. |
k |
Integer or |
max_k |
Integer. Maximum k to evaluate when |
interactive |
Boolean. If |
seed |
Integer or |
Hierarchical clustering with Ward.D2 linkage is used because contribution
clusters are rarely spherical or equal-sized. The optimal number of clusters
is selected automatically via the average silhouette width criterion, but
can be overridden with the k argument.
Visualisation adapts to the number of sources:
2 sources: single 2D panel (w1 vs w2).
3 sources: two 2D panels (w1~w2, w1~w3) plus optional interactive 3D plotly scatter.
4+ sources: all pairwise 2D panels as a grid. Interactive 3D is not available (dimensionality reduction would obscure interpretation).
A named list:
summaryData frame: one row per cluster with mean/SD of each contribution, n_pairs, n_unique_tracers, avg_silhouette.
tracersNamed list. Each element has $pairs (character
vector) and $individual_tracers (data frame ranked by frequency).
plotggplot2 or plotly visualisation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.