trunc_at | R Documentation |
This method takes as its argument x
an object that represents a sequence of
character data, such as an object of class tokens
, and truncates it at the
position where a match for the argument pattern
is found. Currently it is
only implemented for tokens
objects.
trunc_at(x, pattern, ...) ## S3 method for class 'tokens' trunc_at( x, pattern, keep_this = FALSE, last_match = FALSE, from_end = FALSE, ... )
x |
An object that represents a sequence of character data. |
pattern |
A regular expression. |
... |
Additional arguments. |
keep_this |
Logical. Whether the matching token itself should be kept.
If |
last_match |
Logical. In case there are several matching tokens, if
|
from_end |
Logical. If If |
A truncated version of x
.
(toks <- tokenize('This is a first sentence . This is a second sentence .', re_token_splitter = '\\s+')) trunc_at(toks, re("[.]")) trunc_at(toks, re("[.]"), last_match = TRUE) trunc_at(toks, re("[.]"), last_match = TRUE, from_end = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.