plot_clusgap | R Documentation |
Create a ggplot summary of gap statistic results
plot_clusgap(clusgap, title = "Gap Statistic results")
clusgap |
(Required).
An object of S3 class |
title |
(Optional). Character string.
The main title for the graphic.
Default is |
A ggplot
plot object.
The rendered graphic should be a plot of the gap statistic score
versus values for k
, the number of clusters.
gapstat_ord
clusGap
ggplot
# Load and process data data("soilrep") soilr = rarefy_even_depth(soilrep, rngseed=888) print(soilr) sample_variables(soilr) # Ordination sord = ordinate(soilr, "DCA") # Gap Statistic gs = gapstat_ord(sord, axes=1:4, verbose=FALSE) # Evaluate results with plots, etc. plot_scree(sord) plot_ordination(soilr, sord, color="Treatment") plot_clusgap(gs) print(gs, method="Tibs2001SEmax") # Non-ordination example, use cluster::clusGap function directly library("cluster") pam1 = function(x, k){list(cluster = pam(x, k, cluster.only=TRUE))} gs.pam.RU = clusGap(ruspini, FUN = pam1, K.max = 8, B = 60) gs.pam.RU plot(gs.pam.RU, main = "Gap statistic for the 'ruspini' data") mtext("k = 4 is best .. and k = 5 pretty close") plot_clusgap(gs.pam.RU)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.