The “str_sub” Function in R
- Package: stringr 
- Purpose: To extract a substring from each element of a character vector based on position. 
- General Class: String Manipulation 
- Required Argument(s): 
- string: A character vector from which to extract substrings. 
- start: Starting position of the substring. 
- end: Ending position of the substring. 
- Notable Optional Arguments: 
- ...: Additional arguments influencing the extraction process, such as ignore_case to perform case-insensitive matching. 
- Example: 
- # Example usage 
 library(stringr)
 
 sentence <- "The quick brown fox jumps over the lazy dog."
 
 # Extract a substring from position 5 to 15 in the sentence
 substring_example <- str_sub(sentence, start = 5, end = 15)
 
 print(substring_example)
In this example, the str_sub function from the stringr package is used to extract a substring from position 5 to 15 in the character vector sentence. The result is a character vector with the extracted substrings.
 
                        