Skip to content
RDocumentation: cutree
  • AI Chat
  • Code
  • Report
  • Note that this notebook was automatically generated from an RDocumentation page. It depends on the package and the example code whether this code will run without errors. You may need to edit the code to make things work.

    if(!require('stats')) {
        install.packages('stats')
        library('stats')
    }
    hc <- hclust(dist(USArrests))
    
    cutree(hc, k = 1:5) #k = 1 is trivial
    cutree(hc, h = 250)
    
    ## Compare the 2 and 4 grouping:
    g24 <- cutree(hc, k = c(2,4))
    table(grp2 = g24[,"2"], grp4 = g24[,"4"])