- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to extract characters from a string in R?
We can use stri_sub function in stringi package.
Example
> x<- "TutorialsPoint is the largest online library for best tutorials" > x [1] "TutorialsPoint is the largest online library for best tutorials" > library(stringi) > stri_sub(x,1,9) [1] "Tutorials" > stri_sub(x,1,-20) [1] "TutorialsPoint is the largest online library" > stri_sub(x,-14,-1) [1] "best tutorials" > stri_sub(x,-41,-1) [1] "largest online library for best tutorials"
- Related Articles
- How to extract first two characters from a string in R?
- How to extract initial, last, or middle characters from a string in R?
- How to extract words from a string vector in R?
- How to extract the first n characters from a string using Java?
- How to extract the last n characters from a string using Java?
- How to extract string before slash from a vector in R?
- Extract only characters from given string in Python
- Extract string vector elements up to a fixed number of characters in R.
- How to extract number from string in R data frame?
- Python program to extract characters in given range from a string list
- How to extract all string values from a vector in R with maximum lengths?
- How to extract numbers from a string in Python?
- How to extract date from a string in Python?
- How to extract the split string elements in R?
- How to extract the last 4 characters from NSString?

Advertisements