modify_label_pieces | R Documentation |
Typical piece
s include "noun" or a preposition,
such as "in" or "from".
See RCLabels::prepositions
for additional examples.
This argument may be a single string or a character vector.
modify_label_pieces(
labels,
piece,
mod_map,
prepositions = RCLabels::prepositions_list,
inf_notation = TRUE,
notation = RCLabels::bracket_notation,
choose_most_specific = FALSE
)
labels |
A vector of row or column labels in which pieces will be modified. |
piece |
The piece (or pieces) of the row or column label that will be modified. |
mod_map |
A modification map. See details. |
prepositions |
A list of prepositions, used to detect prepositional phrases.
Default is |
inf_notation |
A boolean that tells whether to infer notation for |
notation |
The notation type to be used when extracting prepositions.
Default is |
choose_most_specific |
A boolean that tells whether the most specific
notation is selected when more than one notation match.
Default is |
This function modifies pieces of row and column labels
according to label_map
that defines "one or many to one" relationships.
This function is useful for aggregations.
For example, replacing nouns can be done by
modify_label_pieces(labels, piece = "noun", label_map = list(new_noun = c("a", "b", "c"))
.
The string "new_noun" will replace any of "a", "b", or "c"
when they appear as nouns in a row or column label.
See examples for details.
The mod_map
argument should consist of a
named list of character vectors in which names indicate
strings to be inserted and values indicate
values that should be replaced.
The sense is new = old
or new = olds
,
where "new" is the new name (the replacement) and
"old"/"olds" is/are a string/vector of strings,
any one of which will be replaced by "new".
Note piece
can be "pref"/"suff" or "noun"/"prepositions"
If any piece
is "pref" or "suff",
all pieces are assumed to be a prefix or a suffix.
If non of the piece
s are "pref" or "suff",
all piece
s are assumed to be nouns or prepositions,
such as "in" or "from".
See RCLabels::prepositions
for additional examples.
This argument may be a single string or a character vector.
labels
with replacements according to piece
and mod_map
.
# Simple case
modify_label_pieces("a [of b in c]",
piece = "noun",
mod_map = list(new_noun = c("a", "b")))
# Works with a vector or list of labels
modify_label_pieces(c("a [of b in c]", "d [-> e in f]"),
piece = "noun",
mod_map = list(new_noun = c("d", "e")))
# Works with multiple items in the mod_map
modify_label_pieces(c("a [of b in c]", "d [-> e in f]"),
piece = "noun",
mod_map = list(new_noun1 = c("a", "b", "c"),
new_noun2 = c("d", "e", "f")))
# Works with multiple pieces to be modified
modify_label_pieces(c("a [of b in c]", "d [-> e in f]"),
piece = c("noun", "in"),
mod_map = list(new_noun = c("a", "b", "c"),
new_in = c("c", "f")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.