One parameter substring():
> substring(v, first = 1, last = 3)
[1] "god" "jur" "goo"
as well as version R, substr()
> substr(v, start = 1, stop = 3)
[1] "god" "jur" "goo"
Note the different names for the desired start and last characters.
Since both of these functions are vectorized, there is no need for apply()friends here either .
source
share