Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stringbreak

Insert "\n" after the k'th character in a string. This IS vectorized, so can receive just one or many character strings in a vector.


Description

If a string is long, insert linebreak "\n"

Usage

stringbreak(x, k = 20)

Arguments

x

Character string.

k

Number of characters after which to insert "\n". Default is 20

Details

If x is not a character string, x is returned without alteration. And without a warning

Value

Character with "\n" inserted

Author(s)

Paul Johnson <pauljohn@ku.edu>

Examples

x <- "abcdef ghijkl mnopqrs tuvwxyz abc def ghi jkl mno pqr stv"
stringbreak(x, 10)
stringbreak(x, 20)
stringbreak(x, 25)
x <- c("asdf asdfjl asfdjkl asdfjklasdfasd", "qrweqwer qwerqwerjklqw erjqwe")
stringbreak(x, 5)

kutils

Project Management Tools

v1.70
GPL-2
Authors
Paul Johnson [aut, cre], Benjamin Kite [aut], Charles Redmon [aut], Jared Harpole [ctb], Kenna Whitley [ctb], Po-Yi Chen [ctb], Shadi Pirhosseinloo [ctb]
Initial release
2020-04-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.