I have some issues while working with text stings in R.
I have some string vector which consists of, combined, characters and numbers:
> a <- c("China ltd 123100","Morocco125312 Ytd")
> a
[1] "China ltd 123100" "Morocco125312 Ytd"
The thing is that every element of a
contains a sequence of 6 numbers and I need to extract first 3 numbers of every sequence.
Output should be:
[1] "123" "125"
I need to do this with basic R functions since I am not able to install packages. Can you please help me, have no ideas how to do this.