Difference between revisions of "Talk:Ladle/Statistics"

From Armagetron
Line 1: Line 1:
http://wiki.armagetronad.org/index.php/Ladle/Statistics#Individual_stats
+
=== Instructions for generating the plots for 'Individual stats' ===
  
Script to generate plot (use http://www.rstudio.com/)
+
1. Download and install Rstudio (http://www.rstudio.com/)
  
    require(ggplot2)
+
2. Create a new "R script" and copy the code below (with updated ladle data)
    require(scales)
+
 
    list <- sapply(list(
+
    require(ggplot2)
      newb=c(1,4,6,9,11,21,24,33,34,35),
+
    require(scales)
      dlh=c(6,9,18,19,33,34,35,55,56,61),
+
   
      dread=c(22,37,39,42,48,51,54,55,56,61,65,66,69,73,74),
+
    data <- list(
       titan=c(33,38,43,46,60,63,70),
+
    fofo=       c(12,13,15,27,29,30,31,36,46,48,50,52,57,58,75),
       eckz=c(41,49,51,54,57,58,59,62,65,66),
+
    dread=       c(22,37,39,42,48,51,54,55,56,61,65,66,69,73,74),
      flex=c(12,13,15,18,19,26,29,30,31,36,50,52),
+
    hoax=        c(12,13,15,22,23,28,44,45,50,55,56,61,75),
      woned=c(16,20,25,32,37,39,40,42,53,71,72),
+
    xyron=       c(21,24,27,32,33,37,39,40,42,50,55,56,61),
       emmy=c(16,20,25,32,37,39,40,42),
+
    lacka=       c(03,09,11,14,18,34,35,38,43,60,63,64),
      gonzap=c(20,32,37,39,40,42,53,71,72),
+
    flex=       c(12,13,15,18,19,26,29,30,31,36,50,52),
      b3er=c(25,32,37,39,40,42,53,71,72),
+
    woned=       c(16,20,25,32,37,39,40,42,53,71,72),
      mazuff=c(4,6,9,11,18,19,33,34,48),
+
    eckz=        c(41,49,51,54,57,58,59,62,65,66),
      lacka=c(3,9,11,14,18,34,35,38,43,60,63,64),
+
    dlh=        c(06,09,18,19,33,34,35,55,56,61),
       fofo=c(12,13,15,27,29,30,31,36,46,48,50,52,57,58,75),
+
    durka=       c(08,10,14,17,22,23,28,44,45,61),
       hoax=c(12,13,15,22,23,28,44,45,50,55,56,61,75),
+
    newb=       c(01,04,06,09,11,21,24,33,34,35),
      durka=c(8,10,14,17,22,23,28,44,45,61),
+
    gonzap=     c(20,32,37,39,40,42,53,71,72),
       xyron=c(21,24,27,32,33,37,39,40,42,50,55,56,61),
+
    b3er=       c(25,32,37,39,40,42,53,71,72),
       viper=c(7,24,27,29,30,31,36,46)
+
    freako=     c(14,17,21,24,27,34,41,55,56),
        ),sort)
+
    mazuff=     c(04,06,09,11,18,19,33,34,48),
    data <- data.frame(p=rep(paste(names(list)," (",sapply(list,length),")",sep=""),times=sapply(list,length)),
+
    viper=       c(07,24,27,29,30,31,36,46),
                      ladle=unlist(list,use.names=F),
+
    emmy=        c(16,20,25,32,37,39,40,42),
                      c=unlist(sapply(list,function(x)(1:length(x))),use.names=F))
+
    titan=       c(33,38,43,46,60,63,70),
    bre <- unique(c(seq(from=1,to=max(data$c),by=5),max(data$c)))
+
    gazelle=    c(53,62,68,69,73,74),
    ggplot(data) + geom_point(aes(x=ladle,y=reorder(p,ladle),size=c,colour=c),shape=9) +  
+
    wap=         c(37,40,42,53,71,72),
        scale_colour_gradient('wins', guide="legend", breaks=bre) +
+
    poke=        c(38,43,60,63,64,70),
        scale_size_area('wins',breaks=bre) +  
+
    psyko=       c(07,11,26,29,30,36),
        theme(axis.title.y=element_blank(),panel.grid.minor=element_blank(),axis.ticks.x=element_blank(),axis.ticks.y=element_blank()) +  
+
    soul=        c(65,66,69,73,74),
        scale_x_continuous(breaks=c(1,seq(from=12,to=max(data$ladle),by=12)))
+
    over=        c(63,64,71),
 +
    jdawg=       c(71,72),
 +
    fippmam=    c(62,67),
 +
    magi=        c(67),
 +
    orion=      c(36))
 +
   
 +
    plot_ladle_wins <- function(at_least=5) {
 +
      df <- data.frame(p=rep(paste(names(data)," (",sapply(data,length),")",sep=""),times=sapply(data,length)),
 +
                        l=unlist(data,use.names=F),
 +
                        c=unlist(sapply(data,function(x)(1:length(x))),use.names=F),
 +
                        m=unlist(sapply(data,function(x)(rep(length(x),length(x)))),use.names=F))
 +
      dfup <- df[df$m >= at_least,]
 +
      bre <- unique(c(seq(from=1,to=max(dfup$c),by=4),max(dfup$c)))
 +
      ggplot(dfup) + geom_point(aes(x=l,y=reorder(p,l),size=c,colour=c),shape=9) +  
 +
        scale_colour_gradient('wins', guide="legend", breaks=bre) +
 +
        scale_size_area('wins',breaks=bre) +  
 +
        theme(axis.title.y=element_blank(),axis.ticks.x=element_blank(),axis.ticks.y=element_blank()) +  
 +
        scale_x_continuous(breaks=c(1,seq(from=12,to=max(dfup$l),by=12)),minor_breaks=seq(from=1,to=max(dfup$l), by=1)) +
 +
        xlab(paste("Ladle trophies (",at_least,"+) sorted by players' activity\n", "(updated ", format(Sys.time(), "%Y/%m/%d"),")",sep=""))}
 +
   
 +
   
 +
    plot_ladle_dominance <- function (last_ladle=75, months_ago=18, at_least=3) {
 +
      data2 <- lapply(data,function(a)(a[a>(last_ladle-months_ago) & a<=last_ladle]))
 +
      data2 <- data2[sapply(data2,length)>0]
 +
      df2 <- data.frame(p=rep(paste(names(data2)," (",sapply(data2,length),")",sep=""),times=sapply(data2,length)),
 +
                        l=unlist(data2,use.names=F),
 +
                        c=unlist(sapply(data2,function(x)(1:length(x))),use.names=F),
 +
                        m=unlist(sapply(data2,function(x)(rep(length(x),length(x)))),use.names=F))
 +
      df2up <- df2[df2$m >= at_least,]
 +
      ggplot(df2up) + geom_point(aes(x=l,y=reorder(p,c),size=c,color=c),shape=21,fill="Black") +
 +
        scale_x_continuous(breaks = seq(from = min(df2up$l), to = max(df2up$l), by = 1)) +
 +
        theme(axis.title.y=element_blank(),panel.grid.minor=element_blank(),axis.ticks.x=element_blank(),axis.ticks.y=element_blank(),legend.position="none") +
 +
        coord_fixed(1) +
 +
        xlab(paste("Ladle dominance (",at_least,"+) in the last ",months_ago," months since L",last_ladle,"\n", "(updated ", format(Sys.time(), "%Y/%m/%d"),")",sep=""))}
 +
   
 +
    ### GENERATE PLOTS
 +
    plot_ladle_wins(at_least=5)
 +
    plot_ladle_dominance(last_ladle=75, months_ago=18, at_least=3)
 +
 
 +
3. Run the scripts. Two plots will be generated in the 'Plots' tab. You can browse them by using < and > arrows. Save them via 'Export' -> 'Save plot as timage...'

Revision as of 07:59, 27 November 2013

Instructions for generating the plots for 'Individual stats'

1. Download and install Rstudio (http://www.rstudio.com/)

2. Create a new "R script" and copy the code below (with updated ladle data)

    require(ggplot2)
    require(scales)
    
    data <- list(
    fofo=        c(12,13,15,27,29,30,31,36,46,48,50,52,57,58,75),
    dread=       c(22,37,39,42,48,51,54,55,56,61,65,66,69,73,74),
    hoax=        c(12,13,15,22,23,28,44,45,50,55,56,61,75),
    xyron=       c(21,24,27,32,33,37,39,40,42,50,55,56,61),
    lacka=       c(03,09,11,14,18,34,35,38,43,60,63,64),
    flex=        c(12,13,15,18,19,26,29,30,31,36,50,52),
    woned=       c(16,20,25,32,37,39,40,42,53,71,72),
    eckz=        c(41,49,51,54,57,58,59,62,65,66),
    dlh=         c(06,09,18,19,33,34,35,55,56,61),
    durka=       c(08,10,14,17,22,23,28,44,45,61),
    newb=        c(01,04,06,09,11,21,24,33,34,35),
    gonzap=      c(20,32,37,39,40,42,53,71,72),
    b3er=        c(25,32,37,39,40,42,53,71,72),
    freako=      c(14,17,21,24,27,34,41,55,56),
    mazuff=      c(04,06,09,11,18,19,33,34,48),
    viper=       c(07,24,27,29,30,31,36,46),
    emmy=        c(16,20,25,32,37,39,40,42),
    titan=       c(33,38,43,46,60,63,70),
    gazelle=     c(53,62,68,69,73,74),
    wap=         c(37,40,42,53,71,72),
    poke=        c(38,43,60,63,64,70),
    psyko=       c(07,11,26,29,30,36),
    soul=        c(65,66,69,73,74),
    over=        c(63,64,71),
    jdawg=       c(71,72),
    fippmam=     c(62,67),
    magi=        c(67),
    orion=       c(36))
    
    plot_ladle_wins <- function(at_least=5) {
      df <- data.frame(p=rep(paste(names(data)," (",sapply(data,length),")",sep=""),times=sapply(data,length)),
                       l=unlist(data,use.names=F),
                       c=unlist(sapply(data,function(x)(1:length(x))),use.names=F),
                       m=unlist(sapply(data,function(x)(rep(length(x),length(x)))),use.names=F))
      dfup <- df[df$m >= at_least,]
      bre <- unique(c(seq(from=1,to=max(dfup$c),by=4),max(dfup$c)))
      ggplot(dfup) + geom_point(aes(x=l,y=reorder(p,l),size=c,colour=c),shape=9) + 
        scale_colour_gradient('wins', guide="legend", breaks=bre) +
        scale_size_area('wins',breaks=bre) + 
        theme(axis.title.y=element_blank(),axis.ticks.x=element_blank(),axis.ticks.y=element_blank()) + 
        scale_x_continuous(breaks=c(1,seq(from=12,to=max(dfup$l),by=12)),minor_breaks=seq(from=1,to=max(dfup$l), by=1)) + 
        xlab(paste("Ladle trophies (",at_least,"+) sorted by players' activity\n", "(updated ", format(Sys.time(), "%Y/%m/%d"),")",sep=""))}
    
    
    plot_ladle_dominance <- function (last_ladle=75, months_ago=18, at_least=3) {
      data2 <- lapply(data,function(a)(a[a>(last_ladle-months_ago) & a<=last_ladle]))
      data2 <- data2[sapply(data2,length)>0]
      df2 <- data.frame(p=rep(paste(names(data2)," (",sapply(data2,length),")",sep=""),times=sapply(data2,length)),
                        l=unlist(data2,use.names=F),
                        c=unlist(sapply(data2,function(x)(1:length(x))),use.names=F),
                        m=unlist(sapply(data2,function(x)(rep(length(x),length(x)))),use.names=F))
      df2up <- df2[df2$m >= at_least,]
      ggplot(df2up) + geom_point(aes(x=l,y=reorder(p,c),size=c,color=c),shape=21,fill="Black") + 
        scale_x_continuous(breaks = seq(from = min(df2up$l), to = max(df2up$l), by = 1)) +
        theme(axis.title.y=element_blank(),panel.grid.minor=element_blank(),axis.ticks.x=element_blank(),axis.ticks.y=element_blank(),legend.position="none") +
        coord_fixed(1) +
        xlab(paste("Ladle dominance (",at_least,"+) in the last ",months_ago," months since L",last_ladle,"\n", "(updated ", format(Sys.time(), "%Y/%m/%d"),")",sep=""))}
    
    ### GENERATE PLOTS
    plot_ladle_wins(at_least=5)
    plot_ladle_dominance(last_ladle=75, months_ago=18, at_least=3)

3. Run the scripts. Two plots will be generated in the 'Plots' tab. You can browse them by using < and > arrows. Save them via 'Export' -> 'Save plot as timage...'