This function converts the detailed lists returned (when detail=TRUE
) in the following functions:
and converts them into a dataset with meta data about players, points, games, and sets.
simDf(object)
When converting an object returned by simGames
, simSets
and simMatches
, I recommend adding plyr
’s progress bar, .progress = "text"
, to simDf
as large number of simulations will take a while to convert to a dataset.
simDf(object, .progress = "time")
simGame
and simGames
A look at the dataset returned by simGame
and simGames
, only small number of simulations
egGame <- simGame(p = .78, p2 = .56, firstServe = .67, detail = TRUE)
egGames <- simGames(n = 10, p = .78, p2 = .56, firstServe = .67)
egGame <- simDf(egGame)
head(egGame)
## player p p2 firstServe result server returner
## 1 A 0.78 0.56 0.67 0 2 4
egGames <- simDf(egGames)
head(egGames)
## simNo player p p2 firstServe result server returner
## 1 1 A 0.78 0.56 0.67 1 4 0
## 2 2 A 0.78 0.56 0.67 1 4 0
## 3 3 A 0.78 0.56 0.67 1 4 2
## 4 4 A 0.78 0.56 0.67 1 4 0
## 5 5 A 0.78 0.56 0.67 1 4 0
## 6 6 A 0.78 0.56 0.67 1 6 4
The variables in each dataset are effectively the same, except simGames
dataset has a variable simNo to identify the unique simulations, a look at those variables:
variables | about |
---|---|
simNo | simulation number |
player | player name |
p | probability of server winning a point on their first serve |
p2 | probability of server winning a point on their second serve |
firstServe | probability of first serve being in |
result | game result (1 if server wins, 0 if returner wins) |
server | number of points won by server in service game |
returner | number of points won by returner in service game |
simSet
and simSets
A look at the dataset returned by simSet
and simSets
, only a small number of simulations.
egSet <- simSet(pA = .78, pB = .70, p2A = .56, p2B = .6,
firstServeA = .67, firstServeB = .7, detail = TRUE)
egSets <- simSets(n = 10,
pA = .78, pB = .70, p2A = .56, p2B = .6,
firstServeA = .67, firstServeB = .7)
egSet <- simDf(egSet)
head(egSet)
## pA pB setA setB set_res gameNo serving p p2 firstServe game_res
## 1 A B 7 6 1 1 A 0.78 0.56 0.67 1
## 2 A B 7 6 1 2 B 0.70 0.60 0.70 1
## 3 A B 7 6 1 3 A 0.78 0.56 0.67 1
## 4 A B 7 6 1 4 B 0.70 0.60 0.70 1
## 5 A B 7 6 1 5 A 0.78 0.56 0.67 1
## 6 A B 7 6 1 6 B 0.70 0.60 0.70 1
## server returner
## 1 4 1
## 2 4 0
## 3 5 3
## 4 6 4
## 5 4 0
## 6 4 2
egSets <- simDf(egSets)
head(egSets)
## simNo pA pB setA setB set_res gameNo serving p p2 firstServe
## 1 1 A B 7 6 1 1 A 0.78 0.56 0.67
## 2 1 A B 7 6 1 2 B 0.70 0.60 0.70
## 3 1 A B 7 6 1 3 A 0.78 0.56 0.67
## 4 1 A B 7 6 1 4 B 0.70 0.60 0.70
## 5 1 A B 7 6 1 5 A 0.78 0.56 0.67
## 6 1 A B 7 6 1 6 B 0.70 0.60 0.70
## game_res server returner
## 1 1 4 2
## 2 1 5 3
## 3 1 4 1
## 4 1 4 1
## 5 1 5 3
## 6 1 4 1
The variables in each dataset are similar to those found in the returned datasets from simGame
and simGames
, a look at those variables:
variables | about |
---|---|
simNo | simulation number |
pA | player A |
pB | player B |
setA | games won by player A |
setB | games won by player B |
set_res | set result (1 if player A wins, 0 if player B wins) |
gameNo | game number in set |
serving | player serving |
p | probability of server winning a point on their first serve |
p2 | probability of server winning a point on their second serve |
firstServe | probability of first serve being in |
game_res | game result (1 if server wins, 0 if returner wins) |
server | number of points won by server in service game |
returner | number of points won by returner in service game |
simMatch
and simMatches
A look at the dataset returned by simMatch
and simMatches
, only a small number of simulations.
egMatch <- simMatch(sets = 3, finalSetTiebreak = TRUE, detail = TRUE,
pA = .78, pB = .70,
p2A = .56, firstServeA = .67,
p2B = .6, firstServeB = .7)
egMatches <- simMatches(n = 10, sets = 3,
pA = .78, pB = .70,
p2A = .56, firstServeA = .67,
p2B = .6, firstServeB = .7)
egMatch <- simDf(egMatch)
head(egMatch)
## playerA playerB mA mB result setNo pA pB setA setB set_res gameNo
## 1 A B 1 2 0 1 A B 4 6 0 1
## 2 A B 1 2 0 1 A B 4 6 0 2
## 3 A B 1 2 0 1 A B 4 6 0 3
## 4 A B 1 2 0 1 A B 4 6 0 4
## 5 A B 1 2 0 1 A B 4 6 0 5
## 6 A B 1 2 0 1 A B 4 6 0 6
## serving p p2 firstServe game_res server returner
## 1 A 0.78 0.56 0.67 1 5 3
## 2 B 0.70 0.60 0.70 1 4 2
## 3 A 0.78 0.56 0.67 1 9 7
## 4 B 0.70 0.60 0.70 1 8 6
## 5 A 0.78 0.56 0.67 1 4 0
## 6 B 0.70 0.60 0.70 1 4 1
egMatches <- simDf(egMatches)
head(egMatches)
## simNo playerA playerB mA mB result setNo pA pB setA setB set_res gameNo
## 1 1 A B 0 2 0 1 A B 4 6 0 1
## 2 1 A B 0 2 0 1 A B 4 6 0 2
## 3 1 A B 0 2 0 1 A B 4 6 0 3
## 4 1 A B 0 2 0 1 A B 4 6 0 4
## 5 1 A B 0 2 0 1 A B 4 6 0 5
## 6 1 A B 0 2 0 1 A B 4 6 0 6
## serving p p2 firstServe game_res server returner
## 1 A 0.78 0.56 0.67 1 4 2
## 2 B 0.70 0.60 0.70 1 4 2
## 3 A 0.78 0.56 0.67 1 4 1
## 4 B 0.70 0.60 0.70 1 4 1
## 5 A 0.78 0.56 0.67 1 4 0
## 6 B 0.70 0.60 0.70 1 4 1
The variables in each dataset are similar to those found in the returned datasets from simSet
, simSets
, simGame
and simGames
, a look at those variables:
variables | about |
---|---|
simNo | simulation number |
playerA | player A (who started the match serving) |
playerB | player B (who started the match returning) |
mA | sets won by player A |
mB | sets won by player B |
result | match result, (1 if player A wins, 0 otherwise) |
setNo | set number |
pA | player A (who started the set serving) |
pB | player B (who started the set returning) |
setA | games won by player A |
setB | games won by player B |
set_res | set result (1 if player A wins, 0 if player B wins) |
gameNo | game number in set |
serving | player serving |
p | probability of server winning a point on their first serve |
p2 | probability of server winning a point on their second serve |
firstServe | probability of first serve being in |
game_res | game result (1 if server wins, 0 if returner wins) |
server | number of points won by server in service game |
returner | number of points won by returner in service game |