split string in r code example

Example 1: line split r

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"

Example 2: r string split

str_split(string, pattern, n = Inf, simplify = FALSE)

str_split_fixed(string, pattern, n)

str_split_n(string, pattern, n)

Tags:

Misc Example