Replaces every whole-word old label with the new label of the same site, all at once (so Site A -> Site B together with
Site B -> Site A is fine). For a data frame, column names and every character or factor column are relabelled; numbers are not
touched and rows keep their order.
Usage
relabel_sites(x, old_labels, new_labels)
Arguments
- x
A character vector or a data frame.
- old_labels, new_labels
Site key -> label mappings (named vectors or lists, or paths to mapping files) covering the same sites.
Value
x with the labels swapped.
Examples
old <- c(north = "Site A", south = "Site B")
new <- c(north = "Site B", south = "Site A")
relabel_sites(c("Site A", "Site B: 0.71"), old, new)
#> [1] "Site B" "Site A: 0.71"