Wrap all elements in a vector
wrapVector(x, width = 0.9 * getOption("width"), sep = "\n", ...)
The character vector
The number of
The glue with which to combine the new lines
Other arguments are passed to strwrap()
.
A character vector
res <- wrapVector(
c(
"This is a sentence ready for wrapping",
"So is this one, although it's a bit longer"
),
width = 10
);
print(res);
#> [1] "This is a\nsentence\nready for\nwrapping"
#> [2] "So is\nthis one,\nalthough\nit's a\nbit\nlonger"
cat(res, sep="\n");
#> This is a
#> sentence
#> ready for
#> wrapping
#> So is
#> this one,
#> although
#> it's a
#> bit
#> longer