agnes(x, diss = F, metric = "euclidean", stand = F, method = "average")
In case of a matrix or dataframe, each row corresponds to an observation, and each column corresponds to a variable. All variables must be numeric. Missing values (NAs) are allowed.
In case of a dissimilarity matrix, x is typically the output of daisy or dist. Also a vector with length n*(n-1)/2 is allowed (where n is the number of objects), and will be interpreted in the same way as the output of the above-mentioned functions. Missing values (NAs) are not allowed.
The agnes-algorithm constructs a hierarchy of clusterings. At first, each object is a small cluster by itself. Clusters are merged until only one large cluster remains which contains all the objects. At each stage the two "nearest" clusters are combined to form one larger cluster. For method="average", the distance between two clusters is the average of the dissimilarities between the points in one cluster and the points in the other cluster. In method="single", we use the minimal dissimilarity between a point in the first cluster and a point in the second cluster. When method="complete", we use the maximal dissimilarity between a point in the first cluster and a point in the second cluster.
agn1 <- agnes(votes.repub, metric = "manhattan", stand = T) print(agn1) plot(agn1)agn2 <- agnes(daisy(votes.repub), diss = T, method = "complete") pltree(agn2)
agnes(dist(votes.repub), diss = T)