Notes:

  • the rules are applied in order, so that a row in x that matches multiple rows in remap$conditions will have the first matching row applied to it. Similarly, if remap is provided as a list of remaps, then these will be applied in order and only the first matching one will be applied to any given row

pv_recode(x, remap, log_changes = FALSE)

Arguments

x

data.frame or tibble: a peranavolley object as returned by pv_read, or the plays component thereof

remap

list: a remapping is defined by a list with two data.frames. The data.frame named "conditions" defines the conditions to match on, and the one named "values" provides the new values to use. See the example provided and link{pv_tas_remap} for another. The remap parameter to pv_recode can be provided as one such remapping, or it can be provided as a list of remappings (i.e. a list of lists). In this case the list should be named, and those names will be used in the "changes" attribute (see log_changes)

log_changes

logical: if TRUE, the returned object will have a "changes" attribute describing the changes that were made

Value

A copy of x with new values applied

Examples

## read file x <- pv_read(pv_example_file()) ## construct the remapping my_remap <- list(conditions = data.frame(attack_code = c("1", NA_character_, "4", "5"), start_zone = c(NA, 3, 2, 2), stringsAsFactors = FALSE), values = data.frame(attack_code = c("X1", "Z3", "X6", "V6"), stringsAsFactors = FALSE)) ## meaning that: any attack with attack_code 1 will be recoded as an "X1" attack ## any attack from start_zone 3 will be recoded as an "Z3" attack ## any attack from start_zone 2 with attack_code 4 will be recoded as an "X6" attack ## any attack from start_zone 2 with attack_code 5 will be recoded as an "V6" attack x <- pv_recode(x, remap = my_remap)