Skip to content

Instantly share code, notes, and snippets.

@henriquepgomide
Created September 21, 2019 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henriquepgomide/612597a32b2106428ca3b53da3412355 to your computer and use it in GitHub Desktop.
Save henriquepgomide/612597a32b2106428ca3b53da3412355 to your computer and use it in GitHub Desktop.
r
# Criar matriz com escalonamento multidimensional
mds <-
data %>%
dist() %>%
cmdscale() %>%
as_tibble(.name_repair = "unique")
colnames(mds) <- c("Dim.1", "Dim.2")
# Preparar dados para algoritmo de propagação por afinidade.
datacluster <- dist(data)
datacluster <- as.matrix(datacluster)
apmodel <- apcluster(negDistMat(r = 2), datacluster)
mds$cluster <- as.factor(apcluster::labels(apmodel, type = "enum"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment