format_type_sum: Format a type summary

View source: R/type.R

format_type_sumR Documentation

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, ...)

## Default S3 method:
format_type_sum(x, width, ...)

## S3 method for class '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

# 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)

pillar documentation built on March 31, 2023, 10:19 p.m.