pillar (version 1.9.0)

format_type_sum: Format a type summary

Description

Called on values returned from type_sum() for defining the description in the capital.

Usage

format_type_sum(x, width, ...)

# S3 method for default format_type_sum(x, width, ...)

# S3 method for AsIs format_type_sum(x, width, ...)

Arguments

x

A return value from type_sum()

width

The desired total width. If the returned string still is wider, it will be trimmed. Can be NULL.

...

Arguments passed to methods.

Details

Two methods are implemented by default for this generic: the default method, and the method for the "AsIs" class. Return I("type") from your type_sum() implementation to format the type without angle brackets. For even more control over the formatting, implement your own method.

Examples

Run this code
# Default method: show the type with angle brackets
format_type_sum(1, NULL)
pillar(1)

# AsIs method: show the type without angle brackets
type_sum.accel <- function(x) {
  I("kg m/s^2")
}

accel <- structure(9.81, class = "accel")
pillar(accel)

Run the code above in your browser using DataLab