ID EN
Miscellaneous

toString

R Base 3.6.2

This is a helper function for format to produce a single character string describing an R object.

Syntax

R
toString(x, &#8230;)<p></p><p># S3 method for default
toString(x, width = NULL, &#8230;)</p>

Arguments

Parameter Description
x The object to be converted.
width Suggestion for the maximum field width. Values of NULL or 0 indicate no maximum. The minimum value accepted is 6 and smaller values are taken as 6.
&#8230; Optional arguments passed to or from methods.

Return Value

A character vector of length 1 is returned.

Details

This is a generic function for which methods can be written: only the default method is described here. Most methods should honor the width argument to specify the maximum display width (as measured by nchar(type = "width")) of the result. The default method first converts x to character and then concatenates the elements separated by ", ". If width is supplied and is not NULL, the default method returns the first width - 4 characters of the result with .... appended, if the full result would use more than width characters.

Examples

Example
R
# NOT RUN {
x <- c("a", "b", "aaaaaaaaaaa")
toString(x)
toString(x, width = 8)
# }

See Also

format