Example:
string = "abc|3g"
function(string)
Solution: --> "abc" "3g"
Is there any idea how to split in the way as showed in the example?
To split a string in R, use the strsplit() method. The strsplit() is a built-in R function that splits the string vector into sub-strings. The strsplit() method returns the list, where each list item resembles the item of input that has been split.
Method 1: Using strsplit() function strsplit() function is used to split the string based on some condition.
Details. Argument split will be coerced to character, so you will see uses with split = NULL to mean split = character(0) , including in the examples below. Note that splitting into single characters can be done via split = character(0) or split = "" ; the two are equivalent.
strsplit(string,split='|', fixed=TRUE)
This is the possible answer. Other solutions?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With