Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One method for including the names of your samples in a dendrogram generated using the hclust package in R is to use the labels parameter in the plot() function.

First, you need to generate the dendrogram using the hclust() function, saving the result to a variable (e.g. "hc"). Then, you can use the plot() function to create the dendrogram and include the labels.

For example:

# Generate dendrogram using hclust
hc <- hclust(dist(mydata))

# Plot dendrogram with labels
plot(hc, main="My Dendrogram", xlab="Samples", sub="", labels=row.names(mydata))

In this example, we are using the row names of the "mydata" matrix as the labels for the samples. You can customize the title and axis labels as desired.