library(kableExtra)
library(magrittr)
library(cluster)
library(factoextra)
## Loading required package: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(ggrepel)
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:kableExtra':
##
## group_rows
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(BBmisc)
##
## Attaching package: 'BBmisc'
## The following objects are masked from 'package:dplyr':
##
## coalesce, collapse
## The following object is masked from 'package:base':
##
## isFALSE
library(rio)
ML=import("militarisation.xlsx")
SS=import("safeandsecurity.xlsx")
OC=import("ongoinconflicts.xlsx")
ecologial=import("ecological.xlsx")
ML=select(ML, c(1,17))
names(ML)=c("Country","mili2022")
SS=select(SS, c(1,17))
names(SS)=c("Country","ss2022")
OC=select(OC,c(1,17))
names(OC)=c("Country","ongoing2022")
merge1=inner_join(ML,OC)
## Joining, by = "Country"
merge2=inner_join(merge1,SS)
## Joining, by = "Country"
db=inner_join(merge2,ecologial)
## Joining, by = "Country"
str(db)
## 'data.frame': 163 obs. of 8 variables:
## $ Country : chr "Afghanistan" "Albania" "Algeria" "Angola" ...
## $ mili2022 : num 2.47 1.67 2.04 1.71 1.61 ...
## $ ongoing2022 : num 3.65 1.4 2.07 1.67 1.2 ...
## $ ss2022 : num 4.13 2.12 2.3 2.41 2.66 ...
## $ Food Risk Score : num 4 2 2 5 2 2 1 1 2 2 ...
## $ Natural Disasters Score : num 5 4 5 3 4 2 4 3 1 1 ...
## $ Rapid Population Growth Score: num 5 1 3 5 2 1 3 1 1 3 ...
## $ Water Risk Score : num 5 3 3 5 3 4 3 1 5 3 ...
dataClus=db[,c(2:8)]
row.names(dataClus)=db$Country
g.dist=daisy(dataClus,metric = "gower")
library(factoextra)
fviz_nbclust(dataClus, pam,diss=g.dist,method = "gap_stat",k.max = 10,verbose = F)
Tipificado gaaa
boxplot(normalize(db[,c(3:6)],method='standardize'))
Cluster tipificado
dataClus2=db[,c(2:8)]
row.names(dataClus2)=db$Country
g.dist2=daisy(dataClus,metric = "gower")
library(factoextra)
fviz_nbclust(dataClus2, pam,diss=g.dist,method = "gap_stat",k.max = 10,verbose = F)