Advertisement
Guest User

histo

a guest
Nov 25th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.14 KB | None | 0 0
  1. winlose = read.csv("WIN_LOSE_20141119-20141125.csv",sep=",", na.string="#", header = TRUE)
  2.  
  3. winloseLevels <- aggregate(cbind(Unique.Events.GAMEOVER,Unique.Events.WON) ~ Event.Action, data=winlose, FUN=sum)
  4. winloseLevels $Event.Action = as.character(winloseLevels $Event.Action)
  5. winloseLevels <- winloseLevels[ order(nchar(winloseLevels$Event.Action)), ]
  6. ratio <- (winloseLevels$Unique.Events.WON / winloseLevels$Unique.Events.GAMEOVER)
  7. winloseLevels  <- cbind(winloseLevels, ratio)
  8. winloseLevels$ratio = as.numeric(winloseLevels $ratio)
  9. winloseLevels$ratio = round(winloseLevels$ratio, digits = 2)
  10. counts <- cbind(winloseLevels$Unique.Events.GAMEOVER, winloseLevels$Unique.Events.WON)
  11. colnames(counts) <- c("LOSE", "WIN")
  12. rownames(counts) <- winloseLevels$Event.Action
  13.  
  14. pdf("graph/winloseratio.pdf")
  15. bplt <- barplot(t(counts), main="WIN/LOSE ratio Level",beside=T,ylab="# of unique games", col=c("red","darkblue"),legend = colnames(counts),cex.names=0.8, las=2, ylim=c(0,max(winloseLevels$Unique.Events.GAMEOVER,winloseLevels$Unique.Events.WON)+10))
  16. ypos <- apply(counts, 1, max)
  17. text(y= ypos+1, x= colMeans(bplt), labels=winloseLevels$ratio)
  18. dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement