Splitting Strings in R programming - strsplit() method Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report strsplit() method in R Programming Language is used to split the string by using a delimiter. strsplit() Syntax: 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. Splitting Strings in R language ExampleExample 1: Using strsplit() function with delimiter 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. R # R program to split a string # Given String gfg < - "Geeks For Geeks" # Using strsplit() method answer < - strsplit(gfg, " ") print(answer) Output: [1] "Geeks" "For" "Geeks"Example 2: strsplit() function with Regular Expression delimiter Here, we are using regular expressions in delimiter to split the string. R # R program to split a string # Given String gfg <- "Geeks9For2Geeks" # Using strsplit() method answer <- strsplit(gfg, split = "[0-9]+") print(answer) Output: [1] "Geeks" "For" "Geeks"Example 3: Splitting the dates using strsplit() function in R 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 "-". R string_date<-c("2-07-2020","5-07-2020","6-07-2020", "7-07-2020","8-07-2020") result<-strsplit(string_date,split = "-") print(result) 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" Comment More infoAdvertise with us Next Article Splitting Strings in R programming - strsplit() method J jitender_1998 Follow Improve Article Tags : R Language Similar Reads How to find SubString in R programming? In this article, we are going to see how to find substring in R programming language. R provides different ways to find substrings. These are: Using substr() methodUsing str_detect() methodUsing grep() methodMethod 1: Using substr() method Find substring in R using substr() method in R Programming 2 min read Create Repetitions of a String in R Programming - strrep() Function strrep() Function in R Language is used to create specified number of repetitions of a specified string. Syntax: strrep(string, n) Parameter: string: specified string n: number of repetitions Example 1: Python3 1== # R Program to illustrate # the use of strrep function # String to be repeated x < 1 min read Trim a String to a Specified Display Width in R Programming - strtrim() Function strtrim() function in R Language is used to trim a string to a specified display width. Syntax: strtrim(x, width) Parameters: x: character vector width: specified width Example 1: Python3 1== # R program to trim a string # to specified width # Creating a vector x1 <- "GeeksforGeeks" x2 1 min read 8 Coding Style Tips for R Programming R is an open-source programming language that is widely used as a statistical software and data analysis tool. R generally comes with the Command-line interface. R is available across widely used platforms like Windows, Linux, and macOS. Also, the R programming language is the latest cutting-edge to 5 min read String Concatenation in R Programming String concatenation is a way of appending two or more strings into a single string whether it is character by character or using some special character end to end. There are many ways to perform string concatenation. Example: Input: str1 = 'Geeks' str2 = 'for' str3 = 'Geeks' Output: 'GeeksforGeeks 3 min read Like