strsplit {base} | R Documentation |
Split the strings in x
into substrings according to the
presence of substring split
within them.
strsplit(x, split)
x |
character vector, to be split. |
split |
character string containing a regular expression to use
as ``split''. If empty matches occur, in particular if split
has length 0, x is split into single characters. If
split is a vector, it is re-cycled along x . |
A list of length length(x)
the i
-th element of which
contains the vector of splits of x[i]
.
paste
for the reverse,
grep
and sub
for string search and
manipulation; further nchar
, substr
.
noquote(strsplit("A text I want to display with spaces", NULL)[[1]]) x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech") # split x on the letter e strsplit(x,"e") unlist(strsplit("a.b.c", ".")) ## [1] "" "" "" "" "" ## Note that `split' is a regexp! ## If you really want to split on `.', use unlist(strsplit("a.b.c", "\\.")) ## [1] "a" "b" "c"