format_type_sum

0th

Percentile

Format a type summary

Called on values returned from type_sum() for defining the description in the capital. Implement this method for a helper class for custom formatting, and return an object of this helper class from your type_sum() implementation. See examples.

Usage
format_type_sum(x, width, ...)

# S3 method for default 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.

...

Unused, for extensibility.

Aliases
  • format_type_sum
  • format_type_sum.default
Examples
# NOT RUN {
format_type_sum(1, NULL)
pillar(1)

type_sum.accel <- function(x) {
  structure("kg m/s^2", width = 8, class = "type_sum_accel")
}
format_type_sum.type_sum_accel <- function(x, width, ...) {
  if (!is.null(width) && width < attr(x, "width")) {
    x <- substr(x, 1, width)
  }
  style_subtle(x)
}
accel <- structure(9.81, class = "accel")
pillar(accel)
# }
Documentation reproduced from package pillar, version 1.3.1, License: GPL-3

Community examples

Looks like there are no examples yet.