1 | initial version |
You can apply the strsplit()
function with the keep.tail = TRUE
argument to keep the last empty string. Here's an example:
string <- "one|two|three|"
result <- strsplit(string, split = "\\|", fixed = TRUE, keep.tail = TRUE)
In this case, result
will be a list with one element, which is a character vector with four elements: "one", "two", "three", and an empty string.