Riot

Hallo

library("DBI")
library("RSQLite")
drv <- dbDriver("SQLite")
tfile <- "/Users/tobias/Documents/riotStat/sqlite.db"
con <- dbConnect(drv, dbname = tfile)

smaller <- dbGetQuery(con, "SELECT GameID FROM GameStatForR WHERE SubType ='RANKED_SOLO_5x5' GROUP BY GameID HAVING COUNT(*)==10")
df <- dbGetQuery(con, "select SummonerID,GameID,Win,WardKilled,WardPlaced,ChampionsKilled from GameStatForR WHERE SubType = 'RANKED_SOLO_5x5' ")

df <- df[which(df$GameID %in% smaller$GameID), ]

df.1 <- aggregate(df[, 4:5], list(df$Win, df$GameID), mean)

Ward Placed macht einen Unterschied?

grpA <- df.1[which(df.1$Group.1 == 1 & df.1$WardPlaced < 30), ]$WardPlaced
grpB <- df.1[which(df.1$Group.1 == 0 & df.1$WardPlaced < 30), ]$WardPlaced

boxplot(df.1$WardPlaced ~ df.1$Group.1, main = "WardPlaced")

plot of chunk unnamed-chunk-2



t.test(grpA, grpB)
## 
##  Welch Two Sample t-test
## 
## data:  grpA and grpB
## t = 2.126, df = 347.5, p-value = 0.03422
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.06326 1.62817
## sample estimates:
## mean of x mean of y 
##     8.943     8.097
t.test(grpA, grpB, alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  grpA and grpB
## t = 2.126, df = 347.5, p-value = 0.01711
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.1896    Inf
## sample estimates:
## mean of x mean of y 
##     8.943     8.097

Ward Killed macht einen Unterschied?


boxplot(df.1$WardKilled ~ df.1$Group.1, main = "WardKilled")

plot of chunk unnamed-chunk-3


grpA <- df.1[which(df.1$Group.1 == 1 & df.1$WardPlaced < 30), ]$WardKilled
grpB <- df.1[which(df.1$Group.1 == 0 & df.1$WardPlaced < 30), ]$WardKilled

t.test(grpA, grpB)
## 
##  Welch Two Sample t-test
## 
## data:  grpA and grpB
## t = 0.1875, df = 339.9, p-value = 0.8513
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.0759  0.0919
## sample estimates:
## mean of x mean of y 
##    0.3086    0.3006
t.test(grpA, grpB, alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  grpA and grpB
## t = 0.1875, df = 339.9, p-value = 0.4257
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  -0.06236      Inf
## sample estimates:
## mean of x mean of y 
##    0.3086    0.3006

Does kills give more win chance?


df.2 <- aggregate(df[, 6], list(df$Win, df$GameID), sum)
boxplot(df.2$x ~ df.2$Group.1)

plot of chunk unnamed-chunk-4

grpA <- df.2[which(df.2$Group.1 == 1), ]$x
grpB <- df.2[which(df.2$Group.1 == 0), ]$x
t.test(grpA, grpB)
## 
##  Welch Two Sample t-test
## 
## data:  grpA and grpB
## t = 12.14, df = 341.4, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  12.13 16.82
## sample estimates:
## mean of x mean of y 
##     39.17     24.70
t.test(grpA, grpB, alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  grpA and grpB
## t = 12.14, df = 341.4, p-value < 2.2e-16
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  12.51   Inf
## sample estimates:
## mean of x mean of y 
##     39.17     24.70





d  #which(df$WardPlaced>100)
## Error: object 'd' not found
# SELECT ChampionID FROM GameStatForR WHERE SummonerID= 20966655 AND GameID
# = 1381187479; Teemo ist 17



# grpA2 <- df.1[which(df.1$Group.1==1),]$WardKilled grpB2 <-
# df.1[which(df.1$Group.1==0),]$WardKilled t.test(grpA2,grpB2)

ddd

########################## 
require(vegan)
## Loading required package: vegan
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.0-10

df.All <- dbGetQuery(con, "SELECT * FROM GameStatForR")
df.interest <- df.All[which(df.All$GameID %in% smaller$GameID), ]


df.interest[1:2, c(2, 3, 81)]
##       GameID ChampionID Win
## 2 1388101846        412   1
## 3 1388085725        412   1

ttt <- function(x) {
    t <- c()
    for (i in 1:length(x)) {
        t <- c(t, x[i])
    }
    return(t)
}

df.3 <- aggregate(df.interest[, 3], list(df.interest$Win, df.interest$GameID), 
    ttt)

df.3.char <- df.3[, -c(1, 2)]

d <- vegdist(t(df.3[, -c(1, 2)]), methods = "jaccard")
fit <- hclust(d, method = "ward")
plot(fit)





data <- as.data.frame(t(matrix(test, nrow = 3)))
## Error: object 'test' not found
data <- data[-c(2, 7), ]
## Error: object of type 'closure' is not subsettable
d <- vegdist(data, method = "jaccard")
## Error: 'x' must be an array of at least two dimensions
fit <- hclust(d, method = "ward")
plot(fit)

plot of chunk unnamed-chunk-5




#### 

helpfac <- function(x, y) {
    return(table(factor(x, unique(c(y)))))
}


works <- apply(df.3.char, 1, helpfac, y = df.3.char)
d <- vegdist(works, method = "jaccard")
fit <- hclust(d, method = "complete")
plot(fit)

plot of chunk unnamed-chunk-5




############## häufigstes item
t <- c(as.factor(df.interest$Item0), (df.interest$Item1), df.interest$Item2, 
    df.interest$Item3, df.interest$Item4, df.interest$Item5, df.interest$Item6)
sort(table(t))
## t
##    3   13   15   32   33   38   42   50   64   73   83  108  111  116  118 
##    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
##  122  124 3140 3141 3253 3261 3266 3273 3281 3303    9   14   25   31   46 
##    1    1    1    1    1    1    1    1    1    1    2    2    2    2    2 
##   47   60   74   76   87   91   94  101  120  123  127 1080 2039 2041 3056 
##    2    2    2    2    2    2    2    2    2    2    2    2    2    2    2 
## 3106 3131 3167 3168 3263 3271 3276 3279 3284   16   27   37   52   65   75 
##    2    2    2    2    2    2    2    2    2    3    3    3    3    3    3 
##   79   86  112  114 1039 3005 3166 3171 3257 3274 3302    6    7   20   22 
##    3    3    3    3    3    3    3    3    3    3    3    4    4    4    4 
##   55   62   85   97   99 1043 3050 3154 3264   24   28   35   77   90  126 
##    4    4    4    4    4    4    4    4    4    5    5    5    5    5    5 
## 3060 3097 3124 3206 3254 3259   11   70   71  100  109  125 3004 3023 3042 
##    5    5    5    5    5    5    6    6    6    6    6    6    6    6    6 
## 3091 3101   12   21   39   59  104  121 1027 3098 3301 3342    4   10   26 
##    6    6    7    7    7    7    7    7    7    7    7    7    8    8    8 
##   51 1004 3041 3152 3269    5    8   93   96  103  119 1051 3142    2   72 
##    8    8    8    8    8    9    9    9    9    9    9    9    9   10   10 
##   82 3003 3145 3401   63 3028 3172 3252   40   48   80   84   88 3009 3010 
##   10   10   10   10   11   11   11   11   12   12   12   12   12   12   12 
## 3144 3361   41   56   92 2010 3093 3105 3280 2043 3085 3222   61   66  115 
##   12   12   13   13   13   13   13   13   13   14   14   14   15   15   15 
##  117 3146 3364   45   81 3115   36  105    1   29   44   49   67 3077   23 
##   15   15   15   16   16   16   17   17   18   18   18   18   18   18   19 
##   53 3040   68 3092  102 1033 3096 1006   69  110 3108 3207 3362 3024   30 
##   19   19   20   20   21   21   21   22   24   24   24   24   24   25   26 
##   78 3136 3155  128  113 3044 3070   34 3067 3156 3275 1042 3165   43 3001 
##   26   26   26   27   28   29   29   30   32   32   33   34   34   35   36 
## 3025 3057 3022 2004 1018 3128 3075 3158 2044 3086   54 3134 3190 1054 3191 
##   36   36   37   38   39   39   40   41   42   44   46   46   46   47   48 
## 3100   89   98 3110 3102 3211   58 3069 3209   17 3116 3026 3151  106 3027 
##   49   50   50   50   51   52   54   54   56   57   57   58   59   60   61 
##   57 3083 1029 1038 1057 1053 1052 3082 1036 3260 1056   95 1058 3265 3135 
##   62   62   63   64   64   65   67   67   71   72   74   78   78   87   88 
##   19 3270 1055 2045 3111 3174  107 1001 3157 1031 3071 3078 2049 3117 3153 
##   89   90   94   97   98   99  101  103  104  105  106  108  112  112  114 
## 3065 1028 1037 3046 3250 3047 3074 3087 1026 2003   18 3255 1011 3031 3020 
##  115  118  118  120  123  127  127  128  131  135  139  146  148  157  167 
## 3143 3089 3035 3006 3341 3068 3072    0 3340 
##  172  177  195  200  220  246  273 1310 1468