Search notes:

R function: strsplit

strsplit( "Foo,Bar,Baz", ",")
# [[1]]
# [1] "Foo" "Bar" "Baz"

strsplit(c("Foo,Bar,Baz", "One,Two,Three"), ",")
# [[1]]
# [1] "Foo" "Bar" "Baz"
# 
# [[2]]
# [1] "One"   "Two"   "Three"

strsplit( "Foo,Bar,Baz", ",")[[1]][2]
# [1] "Bar"
Github repository about-r, path: /functions/strsplit/simple.R

Returning a list

strsplit returns a list, not a vector:
splits <- strsplit('a list of words', ' ')
typeof(splits)
#
# [1] "list"
Github repository about-r, path: /functions/strsplit/list.R
The reason that strsplit returns a list is that a vector of strings can be passed as first argument and still be distinguished in the returned list:
splits <- strsplit(c('foo bar baz', 'one two three four'), ' ')
length(splits)
#
# 2

splits[[2]][3]
#
# [1] "three"
Github repository about-r, path: /functions/strsplit/list-2.R

Regular expression patterns

Unless the parameter fixed is set to TRUE (the default being FALSE) , the second parameter is a regular expression which is used to split the string:
strsplit('42abc99def12345ghi', r'{[[:alpha:]]+}')
#
# [1] "42"    "99"    "12345"
Github repository about-r, path: /functions/strsplit/regexp.R

See also

String related R functions
paste concatentes strings to single string.
Index to (some) R functions

Index