chop2plot: Chops a long character object into separate lines for adding...

Description Usage Arguments Value Note

Description

Breaks a long character object into separate lines at specific characters

Usage

1
2
chop2plot(str, width, char.break = " ", char.break.keep = FALSE,
  cex = 1)

Arguments

str

The string to format

width

The maximum width of any single line in inches

char.break

The character where the string should be broken

char.break.keep

Whether to keep the char.break character when the string gets broken. T/F

cex

The character expansion factor that will be used to display the text

Value

A two-item character vector containing [1] the formatted character string with \n inserted and [2] number of lines

Note

This function is designed to break up a potentially long character object that is going to be added to a plot either as a title or text. Line breaks will be inserted so that the string will wrap appropriately at width inches when plotted with cex character expansion factor.

The character object will be broken at the char.break characters such that each line will be <= width when plotted. Breaks are replaced with carriage returns. If char.break.keep is TRUE, the break character will be kept, otherwise it will be removed. If no occurrence of the /codechar.break is available, the line will be chopped at the last character that fits.


tlocoh documentation built on May 2, 2019, 5:27 p.m.