View source: R/str_split_extract.R
str_split_extract | R Documentation |
Split up a string into pieces and extract the results using a specific index position. Mathematically, you can interpret it as follows:
Given a character string, S
, extract the element at a given position, k
, from the result of splitting S
by a given pattern, m
.
str_split_extract(string, pattern, position)
string |
Input vector. Either a character vector, or something coercible to one. |
pattern |
Pattern to look for. This may also contain regular expression. |
position |
Index position to return from the character vector. |
A character vector.
code <- c("HS-IB-EDE", "OG-OYO-CAS-0121", "NY-ILR-NIG-036")
str_split_extract(code, "-", 1)
str_split_extract(code, "-", 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.