library(StratTourn) library(xtable) library(ggplot2) library(reshape2) library(googleVis)
library(StratTourn) library(xtable) library(shiny) library(dplyr) setwd("D:/libraries/StratTourn/studies") name = "Tourn_Noisy_PD_20141020_170203" tourn = load.tournament(paste0(name,".tou")) # Data for each match md = tourn$dt md = add.other.var(md,c("strat","u")) md$delta.u = md$u - md$other.u # Names of all strategies strats = unique(md$strat) # Data for each round file = paste0(name,"_rs.csv") rd = fread(file) rd = as.tbl(as.data.frame(rd)) rd = add.other.var(rd,c("strat","u")) # Names of all strategies strats = unique(rd$strat) # Perhaps select a subset of strategies used.strats = strats ard = rd if (!identical(used.strats,strats)) { rows = rd$strat %in% used.strats & rd$other.strat %in% used.strats rd = ard[rows,] }
end.t = 50 start.t = 1
library(dplyr) td = summarise(group_by(rd,strat,t), u=mean(u),other.u = mean(other.u), num.obs = length(t)) td = as.data.frame(td) t.seq = start.t:min(max(td$t),end.t) tsd = do(group_by(td, strat), get.smoothed.vals(.,xout=t.seq, xvar="t",yvar=c("u","other.u"), wvar="num.obs", spar=0.2)) tsd$Strat = tsd$strat tsd$t = tsd$t+1900 state = ' {"iconType":"LINE","duration":{"timeUnit":"Y","multiplier":1},"xAxisOption":"_TIME","orderedByY":false,"nonSelectedAlpha":0.4,"yLambda":1,"dimensions":{"iconDimensions":["dim0"]},"showTrails":false,"yZoomedDataMin":-0.5,"xLambda":1,"yZoomedDataMax":13,"playDuration":15000,"yAxisOption":"3","time":"1951","colorOption":"2","yZoomedIn":false,"orderedByX":false,"sizeOption":"_UNISIZE","xZoomedIn":false,"xZoomedDataMin":-2177452800000,"uniColorForNonSelected":false,"xZoomedDataMax":-599616000000} ' tsd = as.data.frame(tsd) tsd$const=1 p = gvisMotionChart(tsd, idvar = "Strat", timevar = "t", xvar = "u", yvar = "u", colorvar = "strat", sizevar = "const", options = list(state=state)) #plot(p) print(p, tag="chart")
t.obs = tabulate(rd$t) / 2 plot(t.obs, xlab="t",ylab="matches (log scale)",main="Number of matches with a period t",log="y") grid(nx = NA, ny = NULL, col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.