-
Notifications
You must be signed in to change notification settings - Fork 0
/
code
24 lines (24 loc) · 783 Bytes
/
code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
install.packages('dendextend')
install.packages("ggplot2")
install.packages("ggdendro")
library(dendextend)
library("ggplot2")
library("ggdendro")
states=c("AP","TN","kerala","karnataka","maharashtra","assam","orissa")
x1=c(78.8,79.3,88.5,66.5,73.4,86.3,65.6)
x2=c(87.9,89.1,72.1,84.9,66.9,65.6,61.3)
x3=c(50.6,56.4,61.6,65.3,70.1,66.1,59.5)
x4=c(80.6,87.2,68.9,81.2,69.8,68.6,67.3)
data=data.frame(x1,x2,x3,x4)
##single
dist_single <- dist(data, method = 'euclidean')
hclust_single <- hclust(dist_single , method = 'single')
plot(hclust_single )
##complete
dist_compl <- dist(data, method = 'euclidean')
hclust_compl <- hclust(dist_compl )
plot(hclust_compl)
##average
dist_avg <- dist(data, method = 'euclidean')
hclust_avg <- hclust(dist_avg, method = 'average')
plot(hclust_avg)