Skip to contents

str_to() converts an R object to a character string. It is a slightly more flexible alternative to base::toString().

str_trim() wraps base::strtrim() and further adds a ... suffix to each trimmed element.

str_wrap() wraps base::strwrap() and ensures a character string is returned.

Usage

str_to(x, ...)

# Default S3 method
str_to(x, quote_values = FALSE, last_sep = ", or ", ...)

str_trim(x = character(), width = 80L)

str_wrap(x = character(), width = 80L)

Arguments

x

Any R object for str_to(). A character vector otherwise.

...

Further arguments passed to, or from other methods.

quote_values

A non-NA logical value. Should elements of x be quoted?

last_sep

A non-empty and non-NA character string separating the last and penultimate elements.

width

A non-NA integer value. The target width for individual elements of x. str_trim() takes 3 more characters into account for the suffix it inserts (...).

Value

str_to() and str_wrap() return a character string.

str_trim() returns a character vector having the same length as x.

Details

str_to() concatenates all elements with ", ", except for the last one. See argument last_sep.

str_wrap() preserves existing paragraph separators ("\n\n").

See also

Other utility functions: format_vector(), stops(), vapply_1l()