How to rename labels in dendrogram (dendextend)

A simple way to do this could be to change the names in your original dataset rather than trying to rename the labels. Based on your screenshot, it looks like the two digits that you want to keep are enough to uniquely identify each observation, is that correct?

In this case and if your original data has a column that contains the names, you could for example use tidyr::separate to create a column with the short names in your original data.

The functions works like this:


#sample data

#split up the names after the forth and sixth digit
  separate(name,into=c(NA,"shortNname",NA),sep=c(4,6),remove = FALSE)
#>       name shortNname
#> 1 012.4C16         4C
#> 2 002.1B16         1B
#> 3 010.4A16         4A
#> 4 006.2C16         2C

Created on 2020-11-09 by the reprex package (v0.3.0)

If you need help in how to do this in your own data, it would be good if you could post a full reproducible example.