truncate character string in r code example Example: truncate string in r library(stringr) str_sub('', 1, 3)