I want to extract the first (or last) n characters of a string. This would be the equivalent to Excel's LEFT() and RIGHT(). A small example:
# create a string
a <- paste('left', 'right', sep = '')
a
# [1] "leftright"
I would like to produce b, a string which is equal to the first 4 letters of a:
b
# [1] "left"
What should I do?