R/FrequencyOfSquaresByPercentage.R

FrequencyOfSquaresByPercentage <- function(number.of.players = 2, number.of.trials = 100, vector = FALSE){
  x <- NULL
  for (i in 1:number.of.trials){
    x <- rbind(x, SnakesAndLaddersGame(number.of.players))
  }
  y <- as.data.frame(table(x))
  o <- NULL
  for (i in 1:nrow(y)){
    o <- rbind(o, (y[i,2] * 100)/sum(y[,2]) )
  }
  if (vector == TRUE){
    as.vector(o)
  }else {
    o
  }
}

Try the SnakesAndLaddersAnalysis package in your browser

Any scripts or data that you put into this service are public.

SnakesAndLaddersAnalysis documentation built on May 2, 2019, 2:15 p.m.