Split up a string into a fixed number of pieces.
pattern should be
a single pattern, i.e. a character vector of length one.
str_split_fixed(string, pattern, n)
- input character vector
- pattern to split up by, as defined by a
POSIX regular expression. See the ``Extended Regular
Expressions'' section of
regexfor details. If
NA, returns original string. If
- number of pieces to return. Default (Inf) uses all possible split positions. If n is greater than the number of pieces, the result will be padded with empty strings.
- character matrix with
str_split for variable number of splits
fruits <- c( "apples and oranges and pears and bananas", "pineapples and mangos and guavas" ) str_split_fixed(fruits, "and ", 3) str_split_fixed(fruits, "and ", 4)
Looks like there are no examples yet.