Formatting Utilities

Usage

str_out(x, max = 3L, quote = is.character(x), use.names = FALSE, sep = ", ")

str_desc(object, exdent = 0L)

str_fun(object)

Arguments

x
character vector
max
maximum number of values to appear in the list. If x has more elements than max, a "..." suffix is appended.
quote
a logical indicating whether the values should be quoted with single quotes (defaults) or not.
use.names
a logical indicating whether names should be added to the list as NAME=VAL, ... or not (default).
sep
separator character
object
an R object
exdent
extra indentation passed to str_wrap, and used if the output should spread over more than one lines.

Value

a single character string

Description

str_out formats character vectors for use in show methods or error/warning messages.

str_desc builds formatted string from a list of complex values.

str_fun extracts and formats a function signature. It typically formats the output capture.output(args(object)).

Examples

x <- letters[1:10]
str_out(x)
[1] "'a', 'b', ..., 'j'"
str_out(x, 8)
[1] "'a', 'b', 'c', 'd', 'e', 'f', 'g', ..., 'j'"
str_out(x, Inf)
[1] "'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'"
str_out(x, quote=FALSE)
[1] "a, b, ..., j"
str_fun(install.packages)
[1] "function (pkgs, lib, repos = getOption(\"repos\"), contriburl = contrib.url(repos, \n type), method, available = NULL, destdir = NULL, dependencies = NA, \n type = getOption(\"pkgType\"), configure.args = getOption(\"configure.args\"), \n configure.vars = getOption(\"configure.vars\"), clean = FALSE, \n Ncpus = getOption(\"Ncpus\", 1L), verbose = getOption(\"verbose\"), \n libs_only = FALSE, INSTALL_opts, quiet = FALSE, keep_outputs = FALSE, \n ...) "