I have a set of strings such as
x <- c("xxx", "xxx xxx", "xxx xxxx xxx", "xxx xxxx xxx xxxxxx")
and I want to wrap each so that they fall over two lines, with the breaks where there are spaces, roughly in the middle of the strings, i.e. an output such as
"xxx" "xxx\nxxx" "xxx\nxxxx xxx" "xxx xxxx\nxxx xxxxxx"
I thought strwrap
would work, but I cannot figure out how set a width that does will avoid outputs straying on to a third line