string_repr: Short string representation for R objects

View source: R/string_repr.R

string_reprR Documentation

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 class ''function''
string_repr(x, width = 32L, ...)

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

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

## Default S3 method:
string_repr(x, width = 32L, ...)

Arguments

x

Any R object.

width

a scalar integer

...

passed on to methods

Value

a scalar character

Examples

string_repr(iris)
string_repr(LETTERS)
string_repr(LETTERS, 10)

lgr documentation built on Sept. 6, 2022, 1:05 a.m.