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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…