swim_place: Add places to swimming results

View source: R/swim_place.R

swim_placeR Documentation

Add places to swimming results

Description

Places are awarded on the basis of time, with fastest (lowest) time winning. Ties are placed as ties (both athletes get 2nd etc.)

Usage

swim_place(
  df,
  time_col = Finals,
  max_place = NULL,
  event_type = "ind",
  max_relays_per_team = 1,
  keep_nonscoring = TRUE,
  verbose = TRUE
)

Arguments

df

a data frame with results from swim_parse, including only swimming results (not diving)

time_col

the name of a column in df containing times on which to place (order) performances. Default is Finals

max_place

highest place value that scores

event_type

either "ind" for individual or "relay" for relays

max_relays_per_team

an integer value denoting the number of relays a team may score (usually 1)

keep_nonscoring

are athletes in places greater than max_place be retained in the data frame. Either TRUE or FALSE

verbose

should warning messages be posted. Default is TRUE and should rarely be changed.

Value

a data frame modified so that places have been appended based on swimming time

See Also

swim_place is a helper function used inside of results_score

Examples

  df <- data.frame(Place = c(1, 1, 1),
               Name = c("Sally Swimfast", "Bonnie Bubbles", "Kylie Kicker"),
               Team = c("KVAC", "UBAM", "MERC"),
               Event = rep("Women 200 Freestyle", 3),
               Prelims = c("2:00.00", "1:59.99", "2:01.50"),
               Finals = c("1:58.00", "1:59.50", "2:00.50"),
               Meet = c("Summer 2021", "Fall 2020", "Champs 2020"))

df %>%
  swim_place()

df %>%
  swim_place(time_col = Prelims)

df %>%
  swim_place(time_col = "Prelims")


gpilgrim2670/SwimmeR documentation built on March 26, 2023, 5:05 p.m.