Description Usage Arguments Details Value See Also Examples
Group words in chunks of given length
1 2 3 |
x |
Vector of strings to be split and regrouped |
n |
Number of characters per chunk of regrouped words |
split |
Pattern on which to split strings in ‘x’ into words |
perl |
TRUE if ‘split’ and ‘special_sep’ should be interpreted as perl-style regular expressions. Takes precedence over ‘fixed’ |
fixed |
TRUE if ‘split’ and ‘special_sep’ should be interpreted as fixed strings |
sep |
Separator used when combining words into chunks |
special |
Pattern identifying words that should be combined in a special way (see Details) |
special_sep |
Separator used to combine two words if the first matches ‘special’ |
trim_leading |
If TRUE, leading whitespace will be removed from chunks |
trim_trailing |
If TRUE, trailing whitespace will be removed from chunks |
tol |
Chunks will be allowed to be ‘tol’ characters longer than ‘n’ if that makes their lengths more even in overall |
punct |
If TRUE, words consisting of a single punctuation mark will always be merged to the previous chunk |
The meaning of ‘word’ depends on the value of ‘split’. By default,
strings are split on whitespace resulting in a list of words in the
normal sense (maybe including some punctuation characters and the
like). Clever choice of ‘split’, ‘sep’, ‘special’, and
‘special_sep’ let's you obtain a variety of effects (see
wrap_lines
).
A list of character vectors where every character vector contains one or more chunks of words. Every chunk contains from 1 to ‘n + tol’ characters unless it contains a single word of length > ‘n’ in which case its length is the length of the word.
1 2 | s <- "The quick yellow-orange-brown fox jumps over the 3-year-old, lazy dog."
group_words(s, 10, split = "\\\\s+|(?<=-)", special = "-$")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.