- 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"
Advertisements