I'm creating some R scripts. In one of them, I would like to write formatted text enclosed in a box to a png. I don't know how many lines of text there are, or what the length of the longest line is until I get into the R script, but I want to keep the formatting of the line and have the text fairly tightly enclosed. When I use a plot and a textbox, the plot comes with a large amount of graphical baggage and undesired behavior.
Is there anything that displays text on the device area that
- does not require a plot,
- wraps lines if they exceed a desired width, and
- tightly surrounds the final text with a box?
You can use
ggtext::geom_textbox()in conjunction withtheme_void():You’ll likely need to play with font size, box size, and plot size.