Description Usage Arguments Examples
A wrapper around paste
that does some simple cleaning appropriate for
prose sentences. It
trims leading and trailing whitespace
collapses runs of whitespace into a single space
appends a period (.
) if there is no terminal punctuation
mark (.
, ?
, or !
)
removes spaces preceding punctuation characters: .?!,;:
collapses sequences of punctuation marks (.?!,;:
) (possibly
separated by spaces), into a single punctuation mark.
The first punctuation mark of the sequence is used, with
priority given to terminal punctuation marks .?!
if present
makes sure a space or end-of-string follows every one of
.?!,;:
, with an exception for the special case of .,:
followed by a digit, indicating the punctuation is decimal period,
number separator, or time delimiter
capitalizes the first letter of each sentence (start-of-string or
following a .?!
)
1 |
... |
passed on to |
1 2 3 4 5 6 7 8 9 10 11 12 | compare <- function(x) cat(sprintf(' in: "%s"\nout: "%s"\n', x, sentence(x)))
compare("capitilized and period added")
compare("whitespace:added ,or removed ; like this.and this")
compare("periods and commas in numbers like 1,234.567 are fine !")
compare("colons can be punctuation or time : 12:00 !")
compare("only one punctuation mark at a time!.?,;")
compare("The first mark ,; is kept;,,with priority for terminal marks ;,.")
# vectorized like paste()
sentence(
"The", c("first", "second", "third"), "letter is", letters[1:3],
parens("uppercase:", sngl_quote(LETTERS[1:3])), ".")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.