I am lookin for an efficient way to reduce a large sentence to a specific length and ending on an entire word.
For example reduce each sentence to max 24 characters and end on whole word.
fruits <- c(
"apples and oranges and pears and bananas",
"pineapples and mangos and guavas"
)
to "apples and oranges and", "pineapples and mangos"