You can either use substring function or use str_pad to get the fixed length of value. For this, you need to convert number to string and vice Versa after truncating operation
> substring(number, ll, hl) where ll and hl are lower and higher index.
> str <- "hello this is my first program"
> str_trunc(str,15,side = "right",ellipsis = "")
 "hello this is m"