Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
library(engsoccerdata)
library(dplyr)
m <- table(engsoccerdata2$home, engsoccerdata2$visitor) %>% as.data.frame.matrix %>% as.matrix
m1 <- m + t(m)
d<-dist(m1)
library(MASS)
fit <- isoMDS(d, k=6)
x <- fit$points[,1]
y <- fit$points[,2]
mycols<-as.numeric(kmeans(d,6)[[1]])
ddf <- data.frame(x,y,mycols,id=row.names(m1))
library(ggplot2)
ggplot(ddf,aes(x,y,color=factor(mycols))) + geom_text(aes(label=id), cex=4) +
theme(plot.title = element_text(hjust = 0, vjust = 1, size = rel(2.3)),
panel.background = element_blank(), panel.grid.major.y = element_line(color = "gray65"),
panel.grid.major.x = element_line(color = "gray65"),
panel.grid.minor = element_blank(), plot.background = element_blank(),
text = element_text(color = "gray20", size = 10), axis.text = element_text(size = rel(1)),
axis.text.x = element_text(color = "gray20", size = rel(1.5)),
axis.text.y = element_text(color = "gray20", size = rel(1.5)),
axis.title.x = element_text(size = rel(1.5), vjust = 0),
axis.title.y = element_text(size = rel(1.5), vjust = 1),
axis.ticks.y = element_blank(), axis.ticks.x = element_blank(),
legend.position = "none")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment