Wrap long names over multiple lines so that they will look better on plots.

format_names_for_plotting(chars, width = 40, truncate_at = 80)

Arguments

chars

a character vector (or a variable that can be converted to one)

width

Positive integer giving target line width (in number of characters). A width less than or equal to 1 will put each word on its own line.

truncate_at

max character length

Value

a reformatted character vector of the same length as the input.

Examples

chars <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
  ac arcu semper erat porttitor egestas. Etiam sagittis, sapien at mattis."

format_names_for_plotting(chars)
#> [1] "Lorem ipsum dolor sit amet, consectetur\n  adipiscing elit. Integer ac arcu se..."