text2mapping: Convenient shorthand for specifying mappings with text strings
Description
Convenient shorthand for specifying mappings with text strings
Usage
text2mapping(
  text,
  file = NULL,
  sep = "|",
  flip = FALSE,
  convert.na = TRUE,
  numericWherePossible = TRUE,
  ...
)
Arguments
- text
- A multi-line string specifying a mapping with 2 columns (see examples). 
- file
- If - textis missing, read from this file instead.
 
- sep
- Character used as column separator. 
- flip
- If - TRUE, flip the column order to To, From (default- FALSE).
 
- convert.na
- If - TRUE, the string- "NA"will be converted to- NA.
 
- numericWherePossible
- If - TRUE, the mapping will return a- numericvector if the codomain contains only numbers.
 
- ...
- Further arguments passed to - mapping().
 
Examples
Run this codef <- text2mapping("
L | Low
M | Medium
H | High
")
f(warpbreaks$tension)
Run the code above in your browser using DataLab