I need to extract the 1st 2 characters in a string to later create bin plot distribution. vector:
x <- c("75 to 79", "80 to 84", "85 to 89")
I have gotten this far:
substrRight <- function(x, n){
substr(x, nchar(x)-n, nchar(x))
}
invoke function
substrRight(x, 1)
Response
[1] "79""84""89"
Need to prints the last 2 characters not the first.
[1] "75""80""85"