From 6505b3986f96993cd06ade14c52d91cf00881194 Mon Sep 17 00:00:00 2001 From: Ben Raymond Date: Fri, 15 Mar 2024 20:21:48 +1100 Subject: [PATCH] adjust point_id and scores around ends of sets to be consistent with pre-1.7 versions v1.7.1 --- DESCRIPTION | 2 +- R/read_dv.R | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9a57603..75a19f0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: datavolley Title: Reading and Analyzing DataVolley Scout Files -Version: 1.7.0 +Version: 1.7.1 Authors@R: c(person("Ben", "Raymond", email = "ben@untan.gl", role = c("aut", "cre")), person("Adrien", "Ickowicz", role = "aut"), person("Tyler", "Widdison", role = "aut"), diff --git a/R/read_dv.R b/R/read_dv.R index 60e8e2d..8fa42ea 100644 --- a/R/read_dv.R +++ b/R/read_dv.R @@ -398,7 +398,7 @@ read_dv <- function(filename, insert_technical_timeouts=TRUE, do_warn=FALSE, do_ temp_end_of_set <- grepl("^\\*\\*[[:digit:]]set", out$plays$code, ignore.case = TRUE) sideout_scoring <- grepl("sideout", out$meta$match$regulation) for (k in seq_len(nrow(out$plays))[-1]) { - if (temp_point[k-1] || temp_timeout[k] || temp_timeout[k-1] || temp_end_of_set[k-1]) { ## timeout[k-1] otherwise the following play does not start with a new point_id. Also temp_end_of_set[k-1] so that new sets start with reset scores + if (temp_point[k-1] || temp_timeout[k] || temp_timeout[k-1]) { ## timeout[k-1] otherwise the following play does not start with a new point_id pid <- pid + 1 } else if (sideout_scoring && temp_setterpos[k]) { ## in sideout scoring, we won't see points assigned unless the team is serving, but we still see the *z or az code @@ -520,14 +520,13 @@ read_dv <- function(filename, insert_technical_timeouts=TRUE, do_warn=FALSE, do_ temp_home_team_score <- scores$home_team_score temp_visiting_team_score <- scores$visiting_team_score - temp_home_team_score[1] <- temp_visiting_team_score[1] <- 0L ## start with zeros ## will still have NA scores for timeouts and technical timeouts, patch NAs where we can temp_pt <- out$plays$point for (k in seq_len(nrow(out$plays))[-1]) { - if (grepl(">LUp", out$plays$code[k], ignore.case = TRUE)) { - ## the lineup codes at the start of a set should have zero team scores - temp_home_team_score[k] <- 0L - temp_visiting_team_score[k] <- 0L + if (grepl("^\\*\\*[[:digit:]]set", out$plays$code[k], ignore.case = TRUE)) { + ## make end-of-set row have the same as the preceding scores + if (is.na(temp_home_team_score[k])) temp_home_team_score[k] <- temp_home_team_score[k-1] + if (is.na(temp_visiting_team_score[k])) temp_visiting_team_score[k] <- temp_visiting_team_score[k-1] } else { if (is.na(temp_home_team_score[k]) & !temp_pt[k]) { temp_home_team_score[k] <- temp_home_team_score[k-1]