Description Usage Arguments Details Value Author(s) See Also Examples
Strings are shortened by replacing characters from the middle of the string with a separator.
1 | ShortenStrings(strings, max.len=40, end.len=floor(max.len/2), sep='...')
|
strings |
A string of characters, or an array of strings. |
max.len |
The maximum length of the string. Must be at least |
end.len |
The length of the string retained after the separator. |
sep |
A separator that will be used to replace the middle of the string. |
If the input string is longer than max.len
, then the string is shortened as follows.
First, leading and trailing whitespace is removed. If the string is still longer
than max.len
then a start length is computed as:
start.len = max.len - end.len - str_length(sep)
Characters after start.len
and before end.len
are replaced with sep
.
If end.len
is too large (as in the third example below) then it is silently
reset to the largest allowable value given sep
and max.len
.
A single string or an array of strings with the same length as strings
.
Justin Hemann <support@causata.com>
1 2 3 4 5 6 7 8 9 10 11 12 | # only leading / trailing whitespace is removed
ShortenStrings(' abcdefghijklmnopqrstuvwxyz ', max.len=26)
# the middle is replaced with ...
ShortenStrings(' abcdefghijklmnopqrstuvwxyz ', max.len=20)
# the beginning is replaced with ...
# note that end.len is too long, it is silently set to 17 here.
ShortenStrings(' abcdefghijklmnopqrstuvwxyz ', max.len=20, end.len=20)
# the end is replaced with ...
ShortenStrings(' abcdefghijklmnopqrstuvwxyz ', max.len=20, end.len=0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.