Variables
merged2 <- merged %>%
remove_rownames %>%
column_to_rownames(var="Nom_Barri") %>%
select("n.tot","pc.esp","pc.ue27-esp","pc.20.34","2019-2014","n.esp.V1419",
"hotel2019","rest1614",
"RFD.2017",
"tot_ann","pmedio","pmedio.V1519","pm_ent.V1519","pm_priv.V1519","pm_sha.V1519",
"alq.num","alq.pm","alq.pm.V1519","alq.num.V1519",
"tot.comp","tot.eur","perc.nou.comp","perc.usat.comp","tot.comp.V1519",
"nou.eur.V1519","usat.eur.V1519",
)
Standardizar los datos
df <- scale(merged2)
Hier
d <- dist(df, method = "euclidean")
#ward hier
res.hc <- hclust(d, method = "ward" )
## The "ward" method has been renamed to "ward.D"; note new "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
## 5 17 51
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
## 5 17 38 13
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
## 5 17 11 27 13
plot(res.hc, cex = 0.6)
rect.hclust(res.hc, k = 5, border = 2:5)