strs_slice | R Documentation |
strs_slice
extracts substrings from each element of a character vector,
specified by start and stop positions. It is similar to Python's slicing
syntax for strings, but it uses 1 indexing and stops are inclusive.
strs_slice(string, start = 1L, stop = -1L, ..., step = 1L)
string |
A character vector where each element is a string to slice. |
start |
An integerish scalar for the starting position for slicing (inclusive). |
stop |
An integerish scalar for the ending position for slicing (inclusive). |
... |
Used to force keyword argument usage of |
step |
An integer greater than 0 or equal to -1 for the step size. If -1 is provided, each string will be reversed after slicing operations. |
A character vector of the same length as string
, with each element
being the sliced substring.
strs_slice("hello world", 1, 5)
strs_slice("hello world", 7)
strs_slice("hello world", start = 7, stop = 11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.