public
Created

  • Download Gist
competitor-analysis.R
R
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# Klout scores
klouts <- read.csv("klout-scores.csv", header=TRUE)
 
# Radiuses for rendering bubbles
radius <- sqrt( klouts$klout_score / pi )
 
# Competitor matrix
competitors <- read.csv("competitors.csv", header=TRUE)
 
# Co-ords for plotting competitors
coords <- cmdscale(competitors, k=2)
 
# Plot the co-ordinates
plot(coords, type="n")
 
# Fill colours
fill_colours <- c()
for (i in 1:length(klouts$type)) {
if (klouts$type[i] == "us") {
fill_colours <- c(fill_colours, "#CBE11D")
}
else if (klouts$type[i] == "current") {
fill_colours <- c(fill_colours, "#2DB3CB")
}
else if (klouts$type[i] == "future") {
fill_colours <- c(fill_colours, "#BC006B")
}
}
 
# Show competitors
symbols(coords, circles=radius, inches=0.35, fg="white", bg=fill_colours, xlab="X", ylab="Y")
 
# Label competitors
text(coords, labels=names(competitors), cex=0.5, col="white")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.