Difference between revisions of "Talk:Ladle/Statistics"

From Armagetron
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
=== Instructions for generating the plots for 'Individual stats' ===
+
=== Instructions for generating plots for 'Individual stats' ===
  
1. Download and install Rstudio (http://www.rstudio.com/)
+
1. Install R and Rstudio (http://cran.rstudio.com/bin/windows/base/R-3.0.2-win.exe, http://download1.rstudio.org/RStudio-0.98.501.exe)
  
2. Create a new "R script" and copy the code below (with updated ladle data)
+
2. From within Rstudio install these packages: ggplot2, Cairo
 +
 
 +
3. Create a new "R script" and copy the code below (with updated ladle data)
  
 
     require(ggplot2)
 
     require(ggplot2)
 
     require(scales)
 
     require(scales)
 +
    require(Cairo)
 
      
 
      
 
     data <- list(
 
     data <- list(
    fofo=       c(12,13,15,27,29,30,31,36,46,48,50,52,57,58,75),
+
      dreadlord  =c(22,37,39,42,48,51,54,55,56,61,65,66,69,73,74,76,78),
    dread=       c(22,37,39,42,48,51,54,55,56,61,65,66,69,73,74),
+
      fofo        =c(12,13,15,27,29,30,31,36,46,48,50,52,57,58,75),
    hoax=       c(12,13,15,22,23,28,44,45,50,55,56,61,75),
+
      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),
+
      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),
+
      woned      =c(16,20,25,32,37,39,40,42,53,71,72,80),
    flex=       c(12,13,15,18,19,26,29,30,31,36,50,52),
+
      lacka       =c(03,09,11,14,18,34,35,38,43,60,63,64),
    woned=       c(16,20,25,32,37,39,40,42,53,71,72),
+
      flex       =c(12,13,15,18,19,26,29,30,31,36,50,52),
     eckz=       c(41,49,51,54,57,58,59,62,65,66),
+
      olive      =c(21,24,27,33,34,38,43,55,56,61,78),
    dlh=         c(06,09,18,19,33,34,35,55,56,61),
+
      beer        =c(25,32,37,39,40,42,53,71,72,80,81),
    durka=       c(08,10,14,17,22,23,28,44,45,61),
+
      gonzap     =c(20,32,37,39,40,42,53,71,72,80,81),
     newb=       c(01,04,06,09,11,21,24,33,34,35),
+
      eckz       =c(41,49,51,54,57,58,59,62,65,66),
    gonzap=     c(20,32,37,39,40,42,53,71,72),
+
      dlh         =c(06,09,18,19,33,34,35,55,56,61),
    b3er=       c(25,32,37,39,40,42,53,71,72),
+
      durka       =c(08,10,14,17,22,23,28,44,45,61),
     freako=     c(14,17,21,24,27,34,41,55,56),
+
      newbie     =c(01,04,06,09,11,21,24,33,34,35),
     mazuff=     c(04,06,09,11,18,19,33,34,48),
+
      gazelle    =c(53,62,68,69,73,74,76,77,79),
    viper=       c(07,24,27,29,30,31,36,46),
+
       freako     =c(14,17,21,24,27,34,41,55,56),
    emmy=       c(16,20,25,32,37,39,40,42),
+
      mazuff     =c(04,06,09,11,18,19,33,34,48),
    titan=       c(33,38,43,46,60,63,70),
+
      vov        =c(57,65,66,69,73,74,76,78),
    gazelle=     c(53,62,68,69,73,74),
+
      viper       =c(07,24,27,29,30,31,36,46),
     wap=         c(37,40,42,53,71,72),
+
      emmy       =c(16,20,25,32,37,39,40,42),
    poke=       c(38,43,60,63,64,70),
+
      wap        =c(37,40,42,53,71,72,80,81),
    psyko=       c(07,11,26,29,30,36),
+
      titan       =c(33,38,43,46,60,63,70),
    soul=       c(65,66,69,73,74),
+
      soul        =c(65,66,69,73,74,76,78),
    over=       c(63,64,71),
+
      mister     =c(59,62,68,75,78,79,81),
    jdawg=       c(71,72),
+
      poke       =c(38,43,60,63,64,70),
    fippmam=     c(62,67),
+
      psyko       =c(07,11,26,29,30,36),
    magi=       c(67),
+
      kult        =c(73,74,76,78),
    orion=       c(36))
+
      over       =c(63,64,70,71),
 +
      "J-Dawgg"    =c(71,72,80),
 +
      orion      =c(36,78),
 +
      fippmam    =c(62,67),
 +
      magi        =c(67)
 +
      )
 
      
 
      
 
     plot_ladle_wins <- function(at_least=5) {
 
     plot_ladle_wins <- function(at_least=5) {
Line 52: Line 60:
 
         xlab(paste("Ladle trophies (",at_least,"+) sorted by players' activity\n", "(updated ", format(Sys.time(), "%Y/%m/%d"),")",sep=""))}
 
         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=(max(unlist(data,use.names=F))), months_ago=18, at_least=3) {
     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 <- lapply(data,function(a)(a[a>(last_ladle-months_ago) & a<=last_ladle]))
 
       data2 <- data2[sapply(data2,length)>0]
 
       data2 <- data2[sapply(data2,length)>0]
Line 67: Line 74:
 
         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=""))}
 
         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 (remember to update the 'last_ladle' variable)
+
     ### SAVE GENERATE PLOTS
     plot_ladle_wins(at_least=5)
+
     ggsave("ladle_wins.png", plot_ladle_wins(), width=14.5, height=7.5, dpi=72, type="cairo-png")
     plot_ladle_dominance(last_ladle=75, months_ago=18, at_least=3)
+
     ggsave("ladle_dominance.png", plot_ladle_dominance(), width=14.5, height=4, dpi=72, type="cairo-png")
 
+
3. Run the script. Two png plots will be saved
3. Run the script. Two plots will be generated in the 'Plots' tab. You can browse them by using < and > arrows. Save them via 'Export' -> 'Save plot as image...' (set 'width' and 'height', f.e. 1000x500 & 1000x250)
 

Latest revision as of 03:10, 6 May 2014

Instructions for generating plots for 'Individual stats'

1. Install R and Rstudio (http://cran.rstudio.com/bin/windows/base/R-3.0.2-win.exe, http://download1.rstudio.org/RStudio-0.98.501.exe)

2. From within Rstudio install these packages: ggplot2, Cairo

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

    require(ggplot2)
    require(scales)
    require(Cairo)
    
    data <- list(
      dreadlord   =c(22,37,39,42,48,51,54,55,56,61,65,66,69,73,74,76,78),
      fofo        =c(12,13,15,27,29,30,31,36,46,48,50,52,57,58,75),
      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),
      woned       =c(16,20,25,32,37,39,40,42,53,71,72,80),
      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),
      olive       =c(21,24,27,33,34,38,43,55,56,61,78),
      beer        =c(25,32,37,39,40,42,53,71,72,80,81),
      gonzap      =c(20,32,37,39,40,42,53,71,72,80,81),
      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),
      newbie      =c(01,04,06,09,11,21,24,33,34,35),
      gazelle     =c(53,62,68,69,73,74,76,77,79),
      freako      =c(14,17,21,24,27,34,41,55,56),
      mazuff      =c(04,06,09,11,18,19,33,34,48),
      vov         =c(57,65,66,69,73,74,76,78),
      viper       =c(07,24,27,29,30,31,36,46),
      emmy        =c(16,20,25,32,37,39,40,42),
      wap         =c(37,40,42,53,71,72,80,81),
      titan       =c(33,38,43,46,60,63,70),
      soul        =c(65,66,69,73,74,76,78),
      mister      =c(59,62,68,75,78,79,81),
      poke        =c(38,43,60,63,64,70),
      psyko       =c(07,11,26,29,30,36),
      kult        =c(73,74,76,78),
      over        =c(63,64,70,71),
      "J-Dawgg"    =c(71,72,80),
      orion       =c(36,78),
      fippmam     =c(62,67),
      magi        =c(67)
      )
    
    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=(max(unlist(data,use.names=F))), 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=""))}
    
    ### SAVE GENERATE PLOTS
    ggsave("ladle_wins.png", plot_ladle_wins(), width=14.5, height=7.5, dpi=72, type="cairo-png")
    ggsave("ladle_dominance.png", plot_ladle_dominance(), width=14.5, height=4, dpi=72, type="cairo-png")

3. Run the script. Two png plots will be saved