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 concatenates strings to single string.
Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745900275, '3.14.4.171', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/strsplit(87): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78