I am plotting a graph, but instead of getting the points on the graph, I would like the graph to show which cluster corresponds to those points. The graph I made can be seen in the attachment. So, instead of the graph containing points, I would like it to have the numbers corresponding to the clusters. I left another image as an example of what I want more or less. This example chart contains the numbers of the corresponding clusters. I am using hierarchical clustering. The code is below. Thanks for any help.
library(readxl)
complete_data <- read_excel('C:/Users/Jovani Souza/Word/Cluster/test2.xlsx')
nproperty<-dim(complete_data)[2]
coordinates<- complete_data [,1:2] #matrix containing latitude and longitude
d<-dist(coordinates)
fit.average<-hclust(d,method="average")
#########varying the value of k
mean<-matrix (nrow= nproperty-2,ncol=2)
standard_deviation<-matrix(nrow=npropriedades-2,ncol=2)
for(k in 2:nproperty-1){
clusters<-cutree(fit.average, k) # set the number of k clusters
nclusters<-matrix(table(clusters)) #to indicate how many properties are in each cluster
########inserting column with determination of clusters
complete_data$cluster <- clusters
#########calculate center of mass
mass_center<-matrix(nrow=k,ncol=2)
for(i in 1:k){
mass_center[i,]<-c(weighted.mean(subset(complete_data,cluster==i)$Latitude,subset(complete_data,cluster==i)$Production),
weighted.mean(subset(complete_data,cluster==i)$Longitude,subset(complete_data,cluster==i)$Production))}
coordinates$cluster<-clusters #including clusters index
mass_center<-cbind(mass_center,matrix(c(1:k),ncol=1)) #including clusters index
###############calculation of clusters coverage, considered as the largest distance between properties and center of mass
coverage<-matrix(nrow=k,ncol=1)
for(i in 1:k){
aux_dist<-pdist(rbind(subset(coordinates, cluster==i),mass_center[i,]))
coverage[i,]<-max(aux_dist[nclusters[i,1]+1,])}
###########Production sum of the clusters
sum_production<-matrix(nrow=k,ncol=1)
for(i in 1:k){
sum_production[i,]<-sum(subset(complete_data,cluster==i)["Production"])
}
###########mean of coverage and biogás
mean[k-1,]<-c(mean(coverage),mean(sum_production)) #ver como nomear colunas
standard_deviation[k-1,]<-c(sd(coverage),sd(sum_production))
}
colnames(mean)<-c("Coverage","Production")
colnames(standard_deviation)<-c("Coverage","Production")
plot(mean)