Description Usage Arguments Value Examples
The input is a category specification such as "2 1 3 4 -4". The output is a list with named elements that maps the original categories (which are interpreted as string variables onto sequential integers that run from 0 to M, where there are M+1 categories. The curly brackets indicate that categories "3" and "4" should be collapsed together to form a single, final category. For the category specification ([cat_spec]) "2 1 3 4 -4", the mapping between original and final categories is:
"2" -> 0 "1" -> 1 "3" -> 2 "4" -> 2 "-4" -> 3
Note how the string variable "-4" is the final category, even though it would be the first variable were it interpreted as the number -4.
1 | parse_cat_spec(cat_spec)
|
cat_spec |
The category specification (e.g., "2 1 3 4 -4") |
A list that maps the original string categories onto final integer categories
1 2 3 | # Call parse_cat_spec to create the category mapping
cat_map <- yada::parse_cat_spec("2 1 {3 4} -4")
print(cat_map)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.