pv_recode | R Documentation |
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)
x |
data.frame or tibble: a peranavolley object as returned by |
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 |
log_changes |
logical: if |
A copy of x
with new values applied
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.