Skip to contents

Split text into multiple lines

Usage

split_line(text, chars = 40, lines = NULL)

Arguments

text

string

chars

integer; rough # of characters per line

lines

integer; desired # of lines

Value

text split into lines if longer than split_nchar

Examples

lipsum <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
writeLines(split_line(lipsum, chars = 50))
#> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
#> sed do eiusmod tempor incididunt ut labore
#> et dolore magna aliqua. Ut enim ad
#> minim veniam, quis nostrud exercitation ullamco laboris
#> nisi ut aliquip ex ea commodo consequat.
writeLines(split_line(lipsum, lines = 3))
#> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
#> incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
#> quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
writeLines(split_line("Short line of text!"))
#> Short line of text!
writeLines(split_line("Short line of text!", lines = 2))
#> Short line
#> of text!