In this tutorial you will learn about the R String Substring and its application with practical example.
R String Substring
The part of a string is termed as substring. In R, the substring() function is used to extract new string out of a string. The substring begins with the character at the start index and extends to the character at the end index.
Syntax:-
1 |
substring(str,startIndex,endIndex) |
Above is the general syntax of substring() function, here
str:- It is a vector input representing a string.
startIndex:- It is start position of the first character to be extracted.
endIndex:- It is the last position of the last character to be extracted.
Example:-
1 2 3 |
print("W3Adda - R Substring function.") result <- substring("Hello, W3Adda", 8, 13) print(result) |
Output:-