I have produced a dendrogram in R through hierarchical clustering analysis. I have 310 individuals that have been classified into 1 of 3 groups (my cut off, k, looks to be 3) based on 4 criteria. I have plotted the dendrogram, with the labels I want. But I am hoping to extract the results into a table which will be easier for me to use for further statistical work. I have manually gone through the small text on my dendrogram, but have found an error in my work, so I would like R to create the table for me to verify my work.
I have tried a few options from other websites, and from one entry on stackflow, but have not been successful. I would ideally want the data extraction to provide an output in this format:
columns[Individual ID, clustering group label (1-3)] #with all the results below for my 310 individuals
Here is what I have tried:
eaf.order <- matrix(data=NA, ncol=2, nrow=nrow(residency2), dimnames=list(c(), c("row.num", "row.name")))
leaf.order[,2] <- hc.complete2$labels[hc.complete2$order]
Which gives error:
Error in leaf.order[, 2] <- hc.complete2$labels[hc.complete2$order] : number of items to replace is not a multiple of replacement length