Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

convertToShortString

Converts any R object to a descriptive string so it can be used in messages.


Description

Atomics: If of length 0 or 1, they are basically printed as they are. Numerics are formated with num.format. If of length greater than 1, they are collapsed witd “,” and clipped. so they do not become excessively long. Expressions will be converted to plain text.

All others: Currently, only their class is simply printed like “<data.frame>”.

Lists: The mechanism above is applied (non-recursively) to their elements. The result looks like this: “a=1, <unamed>=2, b=<data.frame>, c=<list>”.

Usage

convertToShortString(x, num.format = "%.4g", clip.len = 15L)

Arguments

x

[any]
The object.

num.format

[character(1)]
Used to format numerical scalars via sprintf. Default is “%.4g”.

clip.len

[integer(1)]
Used clip atomic vectors via clipString. Default is 15.

Value

[character(1)].

Examples

convertToShortString(list(a = 1, b = NULL, "foo", c = 1:10))

BBmisc

Miscellaneous Helper Functions for B. Bischl

v1.11
BSD_2_clause + file LICENSE
Authors
Bernd Bischl [aut, cre], Michel Lang [aut], Jakob Bossek [aut], Daniel Horn [aut], Jakob Richter [aut], Dirk Surmann [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.