| gg_ordicluster | R Documentation | 
Modeled after the ordicluster function in vegan, this function overlays an ordination object with a cluster dendogram. Functionality has been added to include treatment groups.
gg_ordicluster(
  ord,
  cluster,
  treatments = NA,
  choices = c(1, 2),
  prune = 0,
  col = 1,
  pt.size = 3,
  plot = TRUE
)
ord | 
 An ordination object.  | 
cluster | 
 A cluster object from 'hclust' based on the same distance as 'ord.'  | 
treatments | 
 A vector assigning treatments to samples.  | 
choices | 
 Ordination axes to be plotted.  | 
prune | 
 Number of upper level hierarchies removed from the dendrogram. If prune > 0, dendrogram will be disconnected.  | 
col | 
 A vector of cluster group memberships. Used to assign colors to line segments for each cluster group.  | 
pt.size | 
 Symbol size.  | 
plot | 
 A logical; defaults to TRUE.  | 
'treatments' should be a vector of class factor and length equal to the number of samples included in the ordination and cluster; integers are not coerced into factors.
Invisibly returns a list of the data frames used to make the plot (df_ord, df_segments) and the plot itself (plot).
Jari Oksanen, John Quensen
data(dune)
data(dune.env)
dune.bray <- vegdist(dune, method="bray")
ord <- metaMDS(dune, k=3)
cl <- hclust(dune.bray, method="complete")
gg_ordicluster(ord, cluster=cl, treatments=dune.env$Management, prune=3, col=cutree(cl, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.