strSplit | R Documentation |
Split the elements of a character vector into a matrix
strSplit(x, split, fixed = TRUE, n = Inf)
x |
|
split |
|
fixed |
|
n |
|
matrix
.
Character matrix split into columns.
Updated 2023-09-22.
Infinite splits: strsplit()
.
Finite splits: gregexpr()
, substr()
.
stringi::stri_split_fixed()
.
stringr::str_split_fixed()
.
## Infinite number of fixed splits.
x <- c("a__b__c", "d__e__f", "g__h__i")
mat <- strSplit(x = x, split = "__", fixed = TRUE, n = Inf)
print(mat)
## Infinite number of regex splits.
x <- c("a_b_c_d", "e_f__g___h", "i__j__k__l")
mat <- strSplit(x = x, split = "_+", fixed = FALSE, n = Inf)
print(mat)
## Finite number of fixed splits.
x <- c("a__b__c", "d__e__f", "g__h__i")
mat <- strSplit(x = x, split = "__", fixed = TRUE, n = 2L)
print(mat)
## Finite number of regex splits.
x <- c("a_b_c_d", "e_f__g___h", "i__j__k__l")
mat <- strSplit(x = x, split = "_+", fixed = FALSE, n = 2L)
print(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.