I am doing a hierarchical cluster analysis.
The final data looks like: chr, int, int,..., clustergroup.
The first column (chr) are dates, which are not included in the clusteranalysis.
Is there a way to show the clusters on a calendar? I have column for date and a column for cluster.
What I have already:
data$dayNumber <- yday(data$Date)
calendR(year = 2020, start = "M", special.days ="weekend")
CodePudding user response:
Hierarchical techniques are found at the distance matrix. The basic function in R is:
dist(x, method = "euclidean", diag = FALSE, upper = FALSE, p = 2)
dist(nameofdtaset)
The methods available in this function are: "euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski". But there are other functions for calculating distances.
I don't think that with R You can show the clusters on a calendar, but if you need you can use some graph to make it similar
CodePudding user response:
Ok I have found an answer:
calendar <- 1:365
calendar [1:365] <- rep(NA)
final_data$yday <- yday(final_data$Date)
final_data$clusterNames <- paste("Cluster ", final_data$cluster)
calendar[final_data$yday] <- final_data$clusterNames
calendR(year = 2020, start = "M", special.days =calendar,
special.col = c("pink", "lightblue","lightgreen"), legend.pos = "right")