RcappeR

Calculates percentage of runners beaten

Usage

rnrs_btn(pos)

Arguments

param details
pos finishing positions

Details

This is best used with the power of the dplyr package, to calculate the percentage of runners beaten across numerous races in the same dataframe.

Example Use

The gulfstream dataset included in the package can show the usage of this function best. That dataset contains races over 6 and 8 furlongs, on dirt and turf. We’ll assess the percentage of runners beaten according to starting gate (post position, draw, etc), for races over the 6 furlong dirt course.

library(dplyr)

data(gulfstream)

gulfstream %>%
    filter(dist == 6, surf == "dirt") %>%
    group_by(date, race) %>%
    mutate(pct_btn = rnrs_btn(pos)) %>%
    ungroup() %>%
    group_by(gate) %>%
    summarise(pct_btn = mean(pct_btn))
## Source: local data frame [12 x 2]
## 
##     gate   pct_btn
##    (int)     (dbl)
## 1      1 0.5439744
## 2      2 0.5138462
## 3      3 0.5100000
## 4      4 0.5235897
## 5      5 0.4763462
## 6      6 0.4619737
## 7      7 0.5255000
## 8      8 0.4652577
## 9      9 0.4498413
## 10    10 0.4688889
## 11    11 0.5066667
## 12    12 0.4330769