| StrSplit {DescTools} | R Documentation |
Split the Elements of a Character Vector
Description
Split the elements of a character vector x into substrings according to the matches to substring split within them.
This is a verbatim copy of the base R function strsplit, but with a split default of "" and returning a vector instead of a list, when x had the length 1.
Usage
StrSplit(x, split = "", fixed = FALSE, perl = FALSE, useBytes = FALSE)
Arguments
x |
character vector, each element of which is to be split. Other inputs, including a factor, will give an error. |
split |
character vector (or object which can be coerced to such)
containing regular expression(s) (unless |
fixed |
logical. If |
perl |
logical. Should Perl-compatible regexps be used? |
useBytes |
logical. If |
Details
See strsplit for the details.
Value
A list of the same length as x, the i-th element of which
contains the vector of splits of x[i].
If the length x was 1 a vecotor with the splits will be returned.
See Also
paste for the reverse,
grep and sub for string search and
manipulation; also nchar, substr.
‘regular expression’ for the details of the pattern specification.
Examples
noquote(StrSplit("A text I want to display with spaces"))
# the same as ...
noquote(strsplit("A text I want to display with spaces", NULL)[[1]])