Skip to content

Commit

Permalink
use scores at start of each rally, not the end v0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondben committed Nov 9, 2024
1 parent 918bf5a commit a7d03a9
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ovva
Title: A Shiny App for Volleyball Video Analysis
Version: 0.13.0
Version: 0.13.1
Authors@R: c(person(given = "Adrien", family = "Ickowicz", role = c("aut", "cre"), email = "[email protected]"),
person(given = "Ben", family = "Raymond", role = "aut"),
person("openvolley.org", role = "org"))
20 changes: 19 additions & 1 deletion R/internal_utils.R
Original file line number Diff line number Diff line change
@@ -117,7 +117,25 @@ preprocess_data <- function(x, data_type = "indoor") {
TRUE ~ .data$skill_type))
## NA skilltype causes problems, if we have multiple skills selected then it will filter out the missing skilltype (e.g. all blocks, usually)
x$skilltype[is.na(x$skilltype) & !is.na(x$skill) & !(x$skill %in% c("Timeout", "Technical timeout", "Substitution"))] <- "no value"
x
## use scores at start of point
if (!isTRUE(check_scores_start_of_point(x))) {
## regenerate those columns
x <- x %>% group_by(.data$match_id) %>%
mutate(home_score_start_of_point = pmax(ifelse(.data$point_won_by %eq% .data$home_team, as.integer(.data$home_team_score - 1L), as.integer(.data$home_team_score)), 0L),
visiting_score_start_of_point = pmax(ifelse(.data$point_won_by %eq% .data$visiting_team, as.integer(.data$visiting_team_score - 1L), as.integer(.data$visiting_team_score)), 0L)) %>% ungroup
}
x$home_team_score <- x$home_score_start_of_point
x$visiting_team_score <- x$visiting_score_start_of_point
x
}

## check whether we have scores at the start of the point - for historical reasons, these columns might be absent from some files
check_scores_start_of_point <- function(x) {
if (!all(c("home_score_start_of_point", "visiting_score_start_of_point") %in% names(x))) return(FALSE)
## the columns exist, but there is still the possibility that some matches have these values populated and some do not
idxh <- which(!is.na(x$home_team_score))
idxv <- which(!is.na(x$home_visiting_score))
!any(is.na(x$home_score_start_of_point[idxh])) && !any(is.na(x$visiting_score_start_of_point[idxv]))
}

## identify whether a given string looks like a youtube video ID

0 comments on commit a7d03a9

Please sign in to comment.