This function takes an input string and wraps it to lines of a specified width, breaking the string at word boundaries.
Examples
input_string <- "This is a long string that needs to be wrapped to fit within
a specified width."
wrapped_lines <- wrap_string(input_string, width = 30)
cat(wrapped_lines, sep = "\n")
#>
#> This is a long string that
#> needs to be wrapped to fit
#> within
#> a
#> specified width.