split_line: Split a Character String Across 2 Lines

Description Usage Arguments Note Examples

View source: R/split_line.r

Description

This function splits a character string across two lines, keeping lines as even as possible. Replaces the middlemost " " (determined by string length) with "\n"; and does not perform replacement if lines would have words with 3 or fewer characters.

Usage

1

Arguments

text

A vector of character strings.

Note

To use with ggplot2 add scale_x_discrete(labels = split_line) to your ggobject.

Examples

1
2
split_line(c('Hello World!', 'Goodbye Cruel World', 'To Myself'))
# Returns: 'Hello\nWorld!' 'Goodbye\nCruel World' 'To Myself'

joshua-ruf/fidelis documentation built on July 20, 2019, 1:56 a.m.