strPart | R Documentation |
Wrapper for strsplit
. One defines the element of the string
to return after splitting, with option to convert back to a character vector
or leave as list. See strsplit
for further description of
most arguments.
strPart(x, part = 1, split = NULL, fixed = TRUE, returnVector = TRUE, ...)
x |
character vector, each element of which is to be split. Other inputs, including a factor, will give an error. |
part |
numeric. Part of string (between splits) to return. |
split |
character. The splitting character. See |
fixed |
logical. Default TRUE. See |
returnVector |
logical. Function relies on |
... |
Further arguments passed to |
vector or list of character strings
# make example text string
txtStr <- paste(LETTERS[1:10], 13:22, letters[11:20], sep = "_")
txtStr
strPart(x = txtStr, part = 1, split = "_")
strPart(x = txtStr, part = 2, split = "_")
strPart(x = txtStr, part = 3, split = "_")
strPart(x = txtStr, part = 3, split = "_", returnVector = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.