![]() |
VOOZH | about |
strsplit() method in R Programming Language is used to split the string by using a delimiter.
Syntax: strsplit(string, split, fixed)
Parameters:
- string: Input vector or string.
- split: It is a character of string to being split.
- fixed: Match the split or use the regular expression.
Return: Returns the list of words or sentences after split.
Here, we are using strsplit() along with delimiter, delimiter is a character of an existing string to being removed from the string and display out.
Output:
[1] "Geeks" "For" "Geeks"
Here, we are using regular expressions in delimiter to split the string.
Output:
[1] "Geeks" "For" "Geeks"
We can also manipulate with date using strsplit(), only we need to understand the date formatting, for example in this date( 2-07-2020) following the same pattern (-), so we can remove them using delimiter along with "-".
Output:
[[1]] [1] "2" "07" "2020" [[2]] [1] "5" "07" "2020" [[3]] [1] "6" "07" "2020" [[4]] [1] "7" "07" "2020" [[5]] [1] "8" "07" "2020"