Learn R Programming

lgr (version 0.4.4)

string_repr: Short string representation for R objects

Description

This is inspired by the python function repr and produces a short string representation of any R object that is suitable for logging and error messages. It is a generic so you can implement methods for custom S3 objects.

Usage

string_repr(x, width = 32, ...)

# S3 method for `function` string_repr(x, width = 32L, ...)

# S3 method for data.frame string_repr(x, width = 32L, ...)

# S3 method for matrix string_repr(x, width = 32L, ...)

# S3 method for default string_repr(x, width = 32L, ...)

Value

a scalar character

Arguments

x

Any R object.

width

a scalar integer

...

passed on to methods

Examples

Run this code
string_repr(iris)
string_repr(LETTERS)
string_repr(LETTERS, 10)

Run the code above in your browser using DataLab