Skip to content

Instantly share code, notes, and snippets.

@tukachev
Last active April 25, 2016 15:56
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 tukachev/cf7448c653a47cb0fd3ec4fb9d877718 to your computer and use it in GitHub Desktop.
Save tukachev/cf7448c653a47cb0fd3ec4fb9d877718 to your computer and use it in GitHub Desktop.
p.disagreement <- function(data) {
n <- ncol(data)
m <- matrix(0, n, n)
rownames(m) <- names(data)
colnames(m) <- names(data)
for (i in 1:n) {
for (j in i:n) {
m[i, j] <- mean(data[, i] != data[, j])
}
}
m[lower.tri(m)] <- t(m)[lower.tri(m)]
as.dist(m)
}
metafor <- read.delim("~/Tsvetovye_metafory_gumanitariev.csv")
mat <- p.disagreement(metafor) #Матрица процент несогласия
fit <- hclust(mat, method = "ward")
plot(fit, hang = -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment