s <- "This can be considered as very long string!"
# string is shorter than max.length, so returned as is
format_string(s, 60)
# string is shortened to as many words that result in
# a string of maximum 20 chars
format_string(s, 20)
Run the code above in your browser using DataLab