str_split_fixed

0th

Percentile

Split up a string into a fixed number of pieces.

Vectorised over string. pattern should be a single pattern, i.e. a character vector of length one.

Keywords
character
Usage
str_split_fixed(string, pattern, n)
Arguments
string
input character vector
pattern
pattern to split up by, as defined by a POSIX regular expression. See the ``Extended Regular Expressions'' section of regex for details. If NA, returns original string. If ""
n
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.
Value

  • character matrix with n columns.

See Also

str_split for variable number of splits

Aliases
  • str_split_fixed
Examples
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)
Documentation reproduced from package stringr, version 0.6.2, License: GPL-2

Community examples

Looks like there are no examples yet.