Variables

merged2 <- merged %>% 
           remove_rownames %>% 
           column_to_rownames(var="Nom_Barri") %>% 
           select("n.tot","pc.esp","pc.ext","pc.ue27-esp","pc.20.34","2019-2014","var20192014",
                  "hotel2019",
                  "alq.mq","alq.num","alq.pmq",
                  "tot_ann","pc.ent","pc.priv","pc.shared","pc.hotel","pm_ent","pm_priv","pm_sha","pm_hot",
                  "RFD.2017",
                  "tot.comp","perc.nou.comp","perc.prot.comp","perc.usat.comp",
                  "tot.m2","nou.m2","prot.m2","usat.m2",
                  "tot.eur","nou.eur","usat.eur",
                  "tot.eurm2","nou.eurm2","usat.eurm2")

Standardizar los datos

df <- scale(merged2)

Hier

d <- dist(df, method = "euclidean")

#ward hier
res.hc <- hclust(d, method = "ward.D2" )
#plot
plot(res.hc, cex = 0.6, hang = -1)

Cut 3

grp3 <- cutree(res.hc, k = 3)
table(grp3)
## grp3
##  1  2  3 
## 18 10 45
plot(res.hc, cex = 0.6)
rect.hclust(res.hc, k = 3, border = 2:5)

Cut 4

grp4 <- cutree(res.hc, k = 4)
table(grp4)
## grp4
##  1  2  3  4 
## 18 10  6 39
plot(res.hc, cex = 0.6)
rect.hclust(res.hc, k = 4, border = 2:5)

Cut 5

grp5 <- cutree(res.hc, k = 5)
table(grp5)
## grp5
##  1  2  3  4  5 
##  4 10 14  6 39
plot(res.hc, cex = 0.6)
rect.hclust(res.hc, k = 5, border = 2:5)