trim_each_part | R Documentation |
Split string elements in character vector or words in a string and abbreviate to specified number of characters.
trim_each_part(v, split = ",", trim_x = 3, paste_back = T)
v |
A character vector. |
split |
Character delimiter to split by. Note: escape characters still apply, e.g. for ".", split = "\." |
trim_x |
Number, indicating the number of characters for each part (that is, length of truncated output string). |
paste_back |
Logical - paste the split elements back together? |
The abbreviated charactere elements
trim_each_part("abbreviate this", sep = " ")
z <- paste(rep("high", 4), rep(c("low", "intermediate"), each = 2), sep = "/")
# [1] "high/low" "high/low" "high/intermediate" "high/intermediate"
trim_each_part(paste(x, y, sep = "/"), split = "/")
# [1] "hig/low" "hig/low" "hig/int" "hig/int"
trim_each_part(z, split = "/", trim_x = 2)
# [1] "hi/lo" "hi/lo" "hi/in" "hi/in"
trim_each_part(z, split = "/", paste_back = F)
# [1] "hig" "low" "hig" "low" "hig" "int" "hig" "int"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.