str_split_fixed {stringr} | R Documentation |
Split up a string into a fixed number of pieces.
str_split_fixed(string, pattern, n)
string |
input character vector |
pattern |
pattern to split up string by. See regex for
description. If NA , returns original string. If "" splits
into individual characters. |
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. |
character matrix with n
columns.
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)