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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-03 09:24:22 +0000
Seen: 11 times
Last updated: May 03 '23
How to give an <svg> element a double border using CSS when there is no style attribute present?
Why does the fixed position interfere with the functionality of overflow hidden?
How can I customize the Swiper Element v9 in ionic 6 with stylish design?
What is the method of using relative position in CSS?
What is a more effective method to verify the type of an Array containing elements of any type?
What is the method for placing an element beside a relative element?