Skip to content

Commit

Permalink
change the print output for unit, trt, and record
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Oct 15, 2023
1 parent a3783a1 commit e00a732
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions R/rcrds.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pillar_shaft.edbl_rcrd <- function(x, ...) {
out <- rep(dup_symbol(), n)
loc <- match(unique(uvals), uvals)
out[loc] <- fill_symbol()
new_pillar_shaft_simple(out, align = "right")
new_pillar_shaft_simple(out, align = "right", min_width = 8)
} else {
pillar::pillar_shaft(unclass(x))
}
Expand All @@ -339,7 +339,7 @@ as.character.edbl_rcrd <- function(x, ...) {
#' @importFrom vctrs vec_ptype_abbr
#' @export
vec_ptype_abbr.edbl_rcrd <- function(x, ...) {
"rcrd"
paste0("R(", number_si_prefix(length(unique(attr(x, "unit_values")))), ")")
}

#' @importFrom vctrs vec_ptype_full
Expand Down
4 changes: 2 additions & 2 deletions R/trts.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ set_trts <- function(.edibble = design(), ...,
#' @export
pillar_shaft.edbl_trt <- function(x, ...) {
out <- format(x)
new_pillar_shaft_simple(out, align = "right", min_width = 10)
new_pillar_shaft_simple(out, align = "right", min_width = 8)
}

#' @importFrom vctrs vec_ptype_abbr
#' @export
vec_ptype_abbr.edbl_trt <- function(x, ...) {
paste0("trt(", number_si_prefix(nlevels(x)), ")")
paste0("T(", number_si_prefix(nlevels(x)), ")")
}

#' @importFrom vctrs vec_ptype_full
Expand Down
4 changes: 2 additions & 2 deletions R/units.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ set_units <- function(.edibble = design(), ...,
#' @importFrom vctrs vec_ptype_abbr
#' @export
vec_ptype_abbr.edbl_unit <- function(x, ...) {
paste0("unit(", number_si_prefix(nlevels(x)), ")")
paste0("U(", number_si_prefix(nlevels(x)), ")")
}
#' @importFrom vctrs vec_ptype_full
#' @export
Expand Down Expand Up @@ -145,6 +145,6 @@ vec_cast.edbl_fct.character <- function(x, to, ...) new_edibble_fct(x)
#' @export
pillar_shaft.edbl_unit <- function(x, ...) {
out <- format(x)
new_pillar_shaft_simple(out, align = "right", min_width = 11)
new_pillar_shaft_simple(out, align = "right", min_width = 8)
}

0 comments on commit e00a732

Please sign in to comment.