str_out {pkgmaker}R Documentation

Formatting Utilities

Description

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

Usage

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

str_desc(object, exdent = 0L)

str_fun(object)

str_class(x, max = Inf, ...)

str_pkg(pkg, lib.loc = NULL)

str_md5sum(x)

str_hash(x, algo = "md5")

str_dim(x, dims = dim(x))

str_bs(x)

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

total

logical that indicates if the total number of elements should be appended to the formatted string as "'a', ..., 'z' (<N> total)".

object

an R object

exdent

extra indentation passed to str_wrap, and used if the output should spread over more than one lines.

...

other arguments passed to str_out.

pkg

package name

lib.loc

path to a library of R packages

algo

The algorithms to be used; currently available choices are md5, which is also the default, sha1, crc32, sha256, sha512, xxhash32, xxhash64, murmur32, spookyhash and blake3.

dims

a numeric vector of dimensions. Default is to use the input object dimensions (via function dims())

Value

a single character string

Functions

Author(s)

Renaud Gaujoux

str_bs was adapted from a proposal from Yihui Xie.

Examples


x <- letters[1:10]
str_out(x)
str_out(x, 8)
str_out(x, Inf)
str_out(x, quote=FALSE)
str_out(x, total = TRUE)

str_fun(install.packages)
str_class(matrix())

# Backspace substitution
str_bs("abc")
str_bs("abc\b")
str_bs("abc\b\b")
str_bs("abc\bd")
str_bs("abc\b\bde\b")

# more complex example
x <- "\bab\nc\bd\n\babc\b\bd"
cat(x, "\n")
y <- str_bs(x)
y
cat(y, "\n")


[Package pkgmaker version 0.32.10 Index]