Skip to content

Commit

Permalink
forward to format() for classed numerics, closes #88
Browse files Browse the repository at this point in the history
- Numeric values with a `"class"` attribute are now formatted using `format()` if the `pillar_shaft()` method is not implemented for that class (#88).
  • Loading branch information
krlmlr committed Feb 20, 2018
1 parent 6abe8ed commit acb12b9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/shaft.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ pillar_shaft.logical <- function(x, ...) {
#' larger than 1 will potentially show more significant figures than this
#' but they will be greyed out.
pillar_shaft.numeric <- function(x, ..., sigfig = getOption("pillar.sigfig", 3)) {
if (!is.null(attr(x, "class"))) {
ret <- format(x)
return(new_pillar_shaft_simple(ret, width = get_extent(ret), align = "left"))
}

dec <- format_decimal(x, ..., sigfig = sigfig)
sci <- format_scientific(x, ..., sigfig = sigfig)

Expand Down

0 comments on commit acb12b9

Please sign in to comment.