autoline: New Line Feed for Long Strings (Wrapper)

View source: R/other_functions.R

autolineR Documentation

New Line Feed for Long Strings (Wrapper)

Description

Add a break or new line without breaking words. Automatically, the function can detect your plot's width and will dynamically set an auto width. You can adjust the relation (rel) parameter for different fonts and sizes until perfect harmony found. Quite similar to stringr::str_wrap but, if the text vector is a factor, the levels will be kept in order and transformed.

Usage

autoline(text, top = "auto", rel = 9)

Arguments

text

Character or factor vector.

top

Integer. How many characters aprox. should be on each line?

rel

Numeric. Relation of pixels and characters per line

Value

Character. String (vector) including some \n within.

See Also

Other Tools: bind_files(), bring_api(), chr2num(), db_download(), db_upload(), export_plot(), export_results(), files_functions(), font_exists(), formatColoured(), formatHTML(), get_credentials(), glued(), grepm(), h2o_selectmodel(), haveInternet(), image_metadata(), importxlsx(), ip_data(), json2vector(), list_cats(), listfiles(), mail_send(), markdown2df(), move_files(), msplit(), myip(), quiet(), read.file(), statusbar(), tic(), try_require(), updateLares(), warnifnot(), what_size()

Examples

cat(autoline("This is a long text that may not fit into a single line", 8))

text <- factor(c("First value", "Second value", "First value"),
  levels = c("First value", "Second value")
)
autoline(text, 1)

path <- file.path(R.home("doc"), "THANKS")
text <- paste(readLines(path), collapse = " ")
cat(autoline(text))

lares documentation built on Nov. 5, 2023, 1:09 a.m.