Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2016 18:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/78999aeaf6c010e6a149f1646956a454 to your computer and use it in GitHub Desktop.
#require(readODS)
require(readxl)
require(irr)
# for read.ods:
# pts = read.ods("ESC-2016-grand_final-full_results.ods")[[1]]
# colnames(pts) = pts[2,]
# pts = pts[-(1:2),]
# download.file("http://www.eurovision.tv/upload/voting/ESC-2016-grand_final-full_results.xls","ESC-2016-grand_final-full_results.xls")
pts = read_excel("ESC-2016-grand_final-full_results.xls",skip=1)
pts[3:ncol(pts)] = sapply(pts[3:ncol(pts)],as.integer)
colnames(pts) = make.names(colnames(pts), unique=TRUE)
countries = unique(pts[,1])
cw = sapply(countries,function(x) kendall(subset(pts,From.country==x)[,3:7])$value)
cw = sort(cw,decreasing=TRUE)
cf = sapply(countries,function(x) friedman.test(t(as.matrix(subset(pts,From.country==x)[,3:7])),NULL,NULL)$statistic)
names(cf) = countries
cf = sort(cf,decreasing=TRUE)
cft = sapply(countries,function(x) friedman.test(as.matrix(subset(pts,From.country==x)[,3:7]),NULL,NULL)$statistic)
names(cft) = countries
cft = sort(cft)
cms = sapply(countries,function(x) mean(apply(subset(pts,From.country==x)[,3:7],1,sd)^2))
cms = sort(cms)
cat("And the winners are:\n")
cat(names(cw[1]),"(Kendall's W),\n")
cat(names(cf[1]),"(Friedman) and\n")
cat(names(cms[1]),"(Mean of variances)\n")
cat("2nd Places go to:\n")
cat(names(cw[2]),"(Kendall's W),\n")
cat(names(cf[2]),"(Friedman) and\n")
cat(names(cms[2]),"(Mean of variances)\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment