diff --git a/.Rbuildignore b/.Rbuildignore index 2b44321c9..3242e5cd2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -25,3 +25,4 @@ ^\.lintr$ _cache$ ^\.vscode$ +^vignettes/.*\.html$ diff --git a/.github/workflows/R-CMD-check-dev.yaml b/.github/workflows/R-CMD-check-dev.yaml index b7bdd9301..a819e0b3f 100644 --- a/.github/workflows/R-CMD-check-dev.yaml +++ b/.github/workflows/R-CMD-check-dev.yaml @@ -2,16 +2,18 @@ # Can't be run as part of commits on: schedule: - - cron: '5 0 * * *' + - cron: '5 0 * * *' # only run on main branch push: - paths: - - ".github/workflows/R-CMD-check-dev.yaml" + branches: + - "cran-*" + tags: + - "v*" name: rcc dev jobs: matrix: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -235,12 +237,13 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.R_LIBS_USER }} - key: ubuntu-18.04-r-dev-release-${{ matrix.package }}-${{steps.date.outputs.date}} - restore-keys: ubuntu-18.04-r-dev-release-${{ matrix.package }}- + key: ubuntu-20.04-r-dev-release-${{ matrix.package }}-1-${{steps.date.outputs.date}} + restore-keys: ubuntu-20.04-r-dev-release-${{ matrix.package }}-1- - name: Install system dependencies if: runner.os == 'Linux' run: | + sudo apt-get update -y while read -r cmd do eval sudo $cmd diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ea27b8d6b..d15825871 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -33,7 +33,7 @@ jobs: fail-fast: false # Ensure that the "cancel" workflow gets a chance to run quickly, even if we just pushed # Need to figure out how to smoke-test - max-parallel: 6 + max-parallel: 5 matrix: config: - { os: macOS-latest, r: 'release' } @@ -56,10 +56,6 @@ jobs: - {os: ubuntu-, os-version: 18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} # End custom: R 3.4 - # Begin custom: R 3.3 - - {os: ubuntu-, os-version: 18.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - # End custom: R 3.3 - # Begin custom: matrix elements # End custom: matrix elements env: @@ -118,6 +114,7 @@ jobs: - name: Install system dependencies if: runner.os == 'Linux' run: | + sudo apt-get update -y while read -r cmd do eval sudo $cmd diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 246ebc62d..2ef0bdf5e 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -92,6 +92,7 @@ jobs: - name: Install system dependencies if: runner.os == 'Linux' run: | + sudo apt-get update -y while read -r cmd do eval sudo $cmd diff --git a/.github/workflows/revdep.yaml b/.github/workflows/revdep.yaml index 59f0aed9b..a4b063fe0 100644 --- a/.github/workflows/revdep.yaml +++ b/.github/workflows/revdep.yaml @@ -2,7 +2,7 @@ on: push: branches: - - "revdep*" + - "revdep*" # never run automatically on main branch name: revdep @@ -112,6 +112,7 @@ jobs: - name: Install system dependencies if: runner.os == 'Linux' run: | + sudo apt-get update -y Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "18.04")); package <- "${{ matrix.package }}"; deps <- tools::package_dependencies(package, which = "Suggests")[[1]]; lapply(c(package, deps), function(x) { writeLines(remotes::system_requirements("ubuntu", "18.04", package = x)) })' | sort | uniq > .github/deps.sh cat .github/deps.sh sudo sh < .github/deps.sh diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 555737cd2..1bd2592e5 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -66,6 +66,7 @@ jobs: - name: Install system dependencies if: runner.os == 'Linux' run: | + sudo apt-get update -y while read -r cmd do eval sudo $cmd diff --git a/DESCRIPTION b/DESCRIPTION index 249d2ae2d..4a22a2172 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: pillar Title: Coloured Formatting for Columns -Version: 1.6.1.9002 +Version: 1.6.4.9000 Authors@R: c(person(given = "Kirill", family = "M\u00fcller", @@ -50,7 +50,7 @@ VignetteBuilder: knitr Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.1.9001 +RoxygenNote: 7.1.2 Config/testthat/edition: 3 Config/testthat/parallel: true Config/testthat/start-first: @@ -60,6 +60,3 @@ Config/testthat/start-first: ctl_colonnade, ctl_colonnade_1, ctl_colonnade_2 -Remotes: - r-lib/rlang#1243, - renkun-ken/formattable#154 diff --git a/NAMESPACE b/NAMESPACE index 83d77dec4..a4d1a739e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -148,10 +148,10 @@ export(tbl_format_setup) export(tbl_sum) export(type_sum) import(ellipsis) -import(lifecycle) import(rlang) importFrom(fansi,strip_sgr) importFrom(fansi,substr2_ctl) +importFrom(lifecycle,deprecate_soft) importFrom(utf8,utf8_width) importFrom(utils,head) importFrom(utils,str) diff --git a/NEWS.md b/NEWS.md index 96c914ae9..3b5ba8bae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,21 +1,67 @@ -# pillar 1.6.1.9002 +# pillar 1.6.4.9000 -- Using `attr(exact = TRUE)` everywhere. -- `is_vector_s3()` is no longer generic (#181). +- Same as previous version. -# pillar 1.6.1.9001 +# pillar 1.6.4 -- Fix internal logic around `vec_proxy()` and `vec_restore()` (#316). +## Bug fixes + +- Fix printing for some tibbles where a fixed-width column is followed by a column with variable width (#366). +- Avoid nested backtick blocks in vignette. + +## Breaking changes + +- `num()` requires an integerish `digits` argument (#362). + +## Documentation + +- Link to tibble vignettes and documentation pages. + + +# pillar 1.6.3 + +- Avoid blanket import for lifecycle package for compatibility with upcoming rlang (#368, @romainfrancois). + + +# pillar 1.6.2 + +## Options + +- Options `pillar.print_max`, `pillar.print_min`, `pillar.width` and `pillar.max_extra_cols` are now queried before the corresponding `tibble.` or `dplyr.` options are consulted, the latter will be soft-deprecated in pillar v2.0.0 (#353). +- New `pillar.bidi` option. When active, control characters are inserted to improve display of data with right-to-left text (#333). +- The new `pillar.max_footer_lines` option (default: 7) allows controlling the maximum number of footer lines shown. It is applied in addition to the existing `tibble.max_extra_cols` option (#263). + +## Formatting + +- If a column doesn't make use of all horizontal width offered to it, the excess width is distributed over other columns (#331). +- Improved allocation of free space in multi-tier tables with `getOption("tibble.width") > getOption("width")` (#344). +- All pillars are shown with their true horizontal extent, irrespective of the indicated `width`. This simplifies the implementation of custom `pillar_shaft()` methods (#347). + +## Features + +- `num()` gains `extra_sigfig` argument to automatically show more significant figures for numbers of the same magnitude with subtle differences (#97). +- `print.tbl()` and `format.tbl()` support the `max_extra_cols` and `max_footer_lines` arguments that override the corresponding options (#360). +- `print.tbl()` and `format.tbl()` maps the now deprecated `n_extra` argument to `max_extra_cols` for consistency (#360). + +## Bug fixes + +- Avoid mangling of duplicate column names in footer (#332). - Fix warning with zero of type `bit64::integer64()` (#319). -- Fix documentation on usage of `vctrs::vec_proxy()` and `vctrs::vec_restore()` (#322). +## Documentation -# pillar 1.6.1.9000 +- All package options are now documented in `?pillar_options` (#339). +- `obj_sum()` no longer calls `type_sum()` for vectors since pillar v1.6.1, this is now documented (#321). +- Fix documentation on usage of `vctrs::vec_proxy()` and `vctrs::vec_restore()` (#322). -- Same as previous version. +## Internal + +- Using `attr(exact = TRUE)` everywhere. +- `is_vector_s3()` is no longer generic (#181). +- Fix internal logic around `vec_proxy()` and `vec_restore()` (#316). # pillar 1.6.1 diff --git a/R/aaa-options.R b/R/aaa-options.R new file mode 100644 index 000000000..d4615b643 --- /dev/null +++ b/R/aaa-options.R @@ -0,0 +1,47 @@ +make_option_impl <- function(getter, option_name = NULL, env = caller_env()) { + getter_body <- enexpr(getter) + + if (is.null(option_name)) { + # Assuming that the call is getOption() + option_name <- getter_body[[2]] + stopifnot(is.character(option_name)) + } + name <- sub(paste0(utils::packageName(env), "."), "", option_name, fixed = TRUE) + getter_name <- paste0("get_", utils::packageName(env), "_option_", name) + local_setter_name <- paste0("local_", utils::packageName(env), "_option_", name) + setter_name <- paste0("set_", utils::packageName(env), "_option_", name) + + local_setter_body <- expr( + { + out <- !!call2("local_options", !!option_name := sym("value"), .frame = sym("env")) + !!call2(getter_name) + invisible(out[[1]]) + } + ) + + setter_body <- expr( + { + out <- !!call2("options", !!option_name := sym("value")) + !!call2(getter_name) + invisible(out[[1]]) + } + ) + + body <- expr({ + if (missing(!!sym("value"))) { + if (!missing(local)) { + abort("Can't pass `local` argument if `value` is missing.") + } + !!getter_body + } else if (local) !!local_setter_body + else !!setter_body + }) + + args <- pairlist2(value = , local = FALSE, env = quote(caller_env())) + + assign(getter_name, new_function(list(), getter_body, env = env), env) + assign(local_setter_name, new_function(args[c(1, 3)], local_setter_body, env = env), env) + assign(setter_name, new_function(args[1], setter_body, env = env), env) + + new_function(args, body, env = env) +} diff --git a/R/ctl_colonnade.R b/R/ctl_colonnade.R index dfb41a85e..820792365 100644 --- a/R/ctl_colonnade.R +++ b/R/ctl_colonnade.R @@ -31,43 +31,76 @@ ctl_colonnade <- function(x, has_row_id = TRUE, width = NULL, controller = new_t compound_pillar <- combine_pillars(pillars) col_widths <- colonnade_get_width_2(compound_pillar, tier_widths) + tiers <- split(seq_len(nrow(col_widths)), col_widths$tier) + + flat_tiers <- map(tiers, function(tier) { + pillars <- col_widths$pillar[tier] + widths <- col_widths$width[tier] + max_widths <- col_widths$max_widths[tier] + pillar_format_tier(pillars, widths, max_widths) + }) + if (!is.null(rowid)) { rowid_pillar <- rowidformat2(rowid, names(pillars[[1]]), has_star = identical(has_row_id, "*")) + rowid_formatted <- list(pillar_format_parts_2(rowid_pillar, rowid_width)$aligned[[1]]) + flat_tiers <- map(flat_tiers, function(.x) c(rowid_formatted, .x)) + } - col_widths_rowid <- as_tbl(data_frame( - tier = unique(col_widths$tier), - id = 0L, - width = rowid_width, - pillar = list(rowid_pillar) - )) + out <- map(flat_tiers, format_colonnade_tier_2, bidi = get_pillar_option_bidi()) - col_widths <- vec_rbind(col_widths_rowid, col_widths) - } + extra_cols <- as.list(x)[seq2(length(pillars) + 1L, nc)] + new_colonnade_body(out, extra_cols = extra_cols) +} - tiers <- split(seq_len(nrow(col_widths)), col_widths$tier) +pillar_format_tier <- function(pillars, widths, max_widths) { + # First pass: formatting with the allocated width + formatted <- map2(pillars, widths, pillar_format_parts_2) + + extents <- map_int(formatted, `[[`, "max_extent") + extra <- sum(widths - extents) + + # Second pass: trying to use the remaining width, starting at the left + if (extra > 0) { + for (col_idx in which(widths < max_widths)) { + new_formatted <- pillar_format_parts_2(pillars[[col_idx]], min(widths[[col_idx]] + extra, max_widths[[col_idx]])) + delta <- new_formatted$max_extent - formatted[[col_idx]]$max_extent + if (delta > 0) { + formatted[[col_idx]] <- new_formatted + extra <- extra - delta + if (extra <= 0) { + break + } + } + col_idx <- col_idx + 1L + } + } - flat_tiers <- map(tiers, function(tier) { - map2( - col_widths$pillar[tier], - col_widths$width[tier], - pillar_format_parts_2 - ) + map(formatted, function(.x) { + .x$aligned[[1]] }) +} - out <- map(flat_tiers, format_colonnade_tier_2) - - extra_cols <- x[seq2(length(pillars) + 1L, nc)] - new_colonnade_body(out, extra_cols = extra_cols) +# Reference: https://www.w3.org/International/questions/qa-bidi-unicode-controls +fsi <- function(x) { + paste0("\u2068", x, "\u2069") } -format_colonnade_tier_2 <- function(x) { - "!!!!!DEBUG format_colonnade_tier_2(`v(x)`)" +lro <- function(x) { + paste0("\u202d", x, "\u202c") +} +format_colonnade_tier_2 <- function(x, bidi = FALSE) { if (length(x) == 0) { return(character()) } - exec(paste, !!!x) + if (bidi) { + x <- map(x, fsi) + out <- exec(paste, !!!x) + lro(out) + } else { + exec(paste, !!!x) + } } new_colonnade_body <- function(x, extra_cols) { @@ -84,32 +117,32 @@ colonnade_get_width_2 <- function(compound_pillar, tier_widths) { "!!!!!DEBUG colonnade_get_width_2(`v(tier_widths)`)" #' @details - #' Pillars may be distributed over multiple tiers if - #' `width > getOption("width")`. In this case each tier is at most - #' `getOption("width")` characters wide. The very first step of formatting - #' is to determine how many tiers are shown at most, and the width of each - #' tier. - col_widths_df <- colonnade_compute_tiered_col_widths_2(compound_pillar, tier_widths) + #' Each pillar indiacates its maximum and minimum width. + min_max_widths <- colonnade_get_min_max_widths(compound_pillar) + #' + #' Pillars may be distributed over multiple tiers according to their width + #' if `width > getOption("width")`. + #' In this case each tier is at most `getOption("width")` characters wide. + #' The very first step of formatting is to determine + #' how many tiers are shown at most, + #' and the width of each tier. + col_widths_df <- colonnade_compute_tiered_col_widths_df(min_max_widths$max_width, min_max_widths$min_width, tier_widths) + # col_widths_df <- data.frame(id = numeric(), widths = numeric(), tier = numeric()) #' Remaining space is then distributed proportionally to pillars that do not #' use their desired width. - colonnade_distribute_space_df(col_widths_df, tier_widths) -} - -colonnade_compute_tiered_col_widths_2 <- function(compound_pillar, tier_widths) { - "!!!!!DEBUG colonnade_compute_tiered_col_widths_2(`v(tier_widths)`)" + out <- colonnade_distribute_space_df(col_widths_df, tier_widths) + # out <- data.frame(id = numeric(), widths = numeric(), tier = numeric()) - max_tier_width <- max(tier_widths) + # FIXME: Defer split of compound pillars + out$pillar <- map(out$id, get_sub_pillar, x = compound_pillar) - max_widths <- exec(pmax, !!!unname(map(compound_pillar, get_cell_widths))) - max_widths <- pmin(max_widths, max_tier_width) - - min_widths <- exec(pmax, !!!unname(map(compound_pillar, get_cell_min_widths))) - min_widths <- pmin(min_widths, max_tier_width) + new_tbl(out) +} - ret <- colonnade_compute_tiered_col_widths_df(max_widths, min_widths, tier_widths) +colonnade_get_min_max_widths <- function(compound_pillar) { + max_width <- exec(pmax, !!!unname(map(compound_pillar, get_cell_widths))) + min_width <- exec(pmax, !!!unname(map(compound_pillar, get_cell_min_widths))) - pillars <- map(ret$id, get_sub_pillar, x = compound_pillar) - ret$pillar <- pillars - new_tbl(ret) + new_tbl(list(min_width = min_width, max_width = max_width)) } diff --git a/R/ctl_pillar.R b/R/ctl_pillar.R index 9aaff966d..1acec5689 100644 --- a/R/ctl_pillar.R +++ b/R/ctl_pillar.R @@ -173,7 +173,7 @@ format.pillar <- function(x, width = NULL, ...) { width <- sum(widths) - length(widths) + 1L } - new_vertical(pillar_format_parts_2(x, width)) + new_vertical(pillar_format_parts_2(x, width)$aligned[[1]]) } #' @export diff --git a/R/ctl_pillar_component.R b/R/ctl_pillar_component.R index 3701356aa..cbcac87a0 100644 --- a/R/ctl_pillar_component.R +++ b/R/ctl_pillar_component.R @@ -54,7 +54,7 @@ pillar_component <- function(x) { } get_cell_widths <- function(x) { - # FIXME: Choose different name to avoid confusion with get_width()? + # FIXME: Choose different name to avoid confusion with get_width()? attr(x, "width", exact = TRUE) } @@ -101,11 +101,17 @@ pillar_get_min_widths <- function(x) { } pillar_format_parts_2 <- function(x, width) { - "!!!!!DEBUG pillar_format_parts_2(`v(width)`)" - + # Code is repeated in ctl_colonnade formatted <- map(x, function(.x) format(.x[[1]], width = width)) - alignment <- attr(formatted[["data"]], "align", exact = TRUE) %||% "left" + align <- attr(formatted[["data"]], "align", exact = TRUE) %||% "left" + + flat <- unlist(formatted) + extent <- get_extent(flat) + aligned <- align_impl(flat, min(width, max(extent)), align, " ", extent) - align(unlist(formatted), width = width, align = alignment) + new_tbl(list( + formatted = list(formatted), align = align, flat = list(flat), + max_extent = max(extent), aligned = list(aligned) + )) } diff --git a/R/extent.R b/R/extent.R index 975e4cb1e..e6956dce2 100644 --- a/R/extent.R +++ b/R/extent.R @@ -55,6 +55,10 @@ align <- function(x, width = NULL, align = c("left", "right"), space = " ") { if (is.null(width)) { width <- max(extent) } + align_impl(x, width, align, space, extent) +} + +align_impl <- function(x, width, align, space, extent) { spaces <- pmax(width - extent, 0L) if (align == "left") { paste0(x, strrep(space, spaces)) diff --git a/R/glimpse.R b/R/glimpse.R index d8a97c1d5..e8f612987 100644 --- a/R/glimpse.R +++ b/R/glimpse.R @@ -16,8 +16,9 @@ #' `data.frames`, and a default method that calls [str()]. #' #' @param x An object to glimpse at. -#' @param width Width of output: defaults to the setting of the option -#' `tibble.width` (if finite) or the width of the console. +#' @param width Width of output: defaults to the setting of the +#' `width` [option][pillar_options] (if finite) +#' or the width of the console. #' @param ... Unused, for extensibility. #' @return x original x is (invisibly) returned, allowing `glimpse()` to be #' used within a data pipe line. @@ -34,10 +35,10 @@ glimpse <- function(x, width = NULL, ...) { #' @export glimpse.tbl <- function(x, width = NULL, ...) { - width <- get_width_glimpse(width) - if (!is.finite(width)) { + if (!is.null(width) && !is.finite(width)) { abort("`width` must be finite.") } + width <- get_width_glimpse(width) cli::cat_line("Rows: ", big_mark(nrow(x))) diff --git a/R/multi.R b/R/multi.R index 5f099bd74..b416c28d0 100644 --- a/R/multi.R +++ b/R/multi.R @@ -124,10 +124,6 @@ new_empty_col_sentinel <- function(type) { #' #' @keywords internal #' @export -#' @examples -#' long_string <- list(paste(letters, collapse = " ")) -#' squeeze(colonnade(long_string), width = 40) -#' squeeze(colonnade(long_string), width = 20) squeeze <- function(x, width = NULL, ...) { deprecate_soft("1.5.0", "pillar::squeeze()") @@ -157,7 +153,7 @@ squeeze_impl <- function(x, width = NULL, ...) { } col_widths <- colonnade_get_width(x, width, rowid_width) - col_widths_shown <- col_widths[col_widths$tier != 0, ] + col_widths_shown <- col_widths[!safe_is_na(col_widths$tier), ] indexes <- split(seq_along(col_widths_shown$tier), col_widths_shown$tier) out <- map(indexes, function(i) { @@ -245,8 +241,6 @@ knit_print_squeezed_colonnade_tier <- function(x) { #' @inheritParams ellipsis::dots_used #' @keywords internal #' @export -#' @examples -#' extra_cols(squeeze(colonnade(list(a = 1:3, b = 4:6), width = 8))) extra_cols <- function(x, ...) { deprecate_soft("1.5.0", "pillar::extra_cols()") @@ -307,7 +301,7 @@ colonnade_get_width <- function(x, width, rowid_width) { init_cols <- min(length(x$data), sum(floor((tier_widths + 1L) / (MIN_PILLAR_WIDTH + 1L)))) capitals <- map2(x$data[seq_len(init_cols)], x$names[seq_len(init_cols)], pillar_capital) init_col_widths_df <- colonnade_compute_tiered_col_widths(capitals, tier_widths) - pillar_shown <- init_col_widths_df$id[init_col_widths_df$tier != 0L] + pillar_shown <- init_col_widths_df$id[!safe_is_na(init_col_widths_df$tier)] if (length(pillar_shown) < init_cols) { # (Include one more pillar to indicate that the data is too wide.) pillar_shown <- c(pillar_shown, pillar_shown[length(pillar_shown)] + 1L) @@ -342,7 +336,7 @@ colonnade_compute_tiered_col_widths <- function(pillars, tier_widths) { max_tier_width <- max(tier_widths) max_widths <- pmin(map_int(map(pillars, get_widths), max), max_tier_width) - min_widths <- map_int(map(pillars, get_min_widths), max) + min_widths <- pmin(map_int(map(pillars, get_min_widths), max), max_widths) ret <- colonnade_compute_tiered_col_widths_df(max_widths, min_widths, tier_widths) ret$pillar <- pillars @@ -355,6 +349,12 @@ colonnade_compute_tiered_col_widths <- function(pillars, tier_widths) { colonnade_compute_tiered_col_widths_df <- function(max_widths, min_widths, tier_widths) { "!!!!!DEBUG colonnade_compute_tiered_col_widths_df(`v(tier_widths)`)" + max_tier_width <- max(tier_widths) + + # Safety: + max_widths <- pmin(max_widths, max_tier_width) + min_widths <- pmin(min_widths, max_tier_width) + id <- seq_along(max_widths) col_df <- data.frame(id, max_widths, min_widths, row.names = NULL) @@ -377,36 +377,59 @@ colonnade_compute_tiered_col_widths_df <- function(max_widths, min_widths, tier_ } #' Otherwise, some tiers from the start - #' will contain pillars with their maximum width, and the remaining tiers - #' contain pillars with their minimum width. - #' We determine the cut point where minimum and maximum assignment - #' agree. + #' will contain pillars with their maximum width, + #' one tier will contain some pillars with maximum and some with minimum width, + #' and the remaining tiers contain pillars with their minimum width only. + #' + #' For this, we compute a "reverse minimum assignment". min_fit_rev <- distribute_pillars_rev(col_df$min_widths, tier_widths) - cut_point <- max(min(which(c(max_fit$tier == min_fit_rev$tier))), 1L) - cut_point_tier <- max_fit$tier[[cut_point]] - - min_fit_cut <- distribute_pillars_offset( - col_df$min_widths, - tier_widths, - cut_point, - cut_point_tier - ) - - combined_fit <- rbind( - max_fit[seq_len(cut_point - 1L), ], - min_fit_cut - ) + combined_fit <- combine_pillar_distributions(max_fit, min_fit_rev, tier_widths) combined_fit$max_widths <- col_df$max_widths combined_fit } +#' @rdname colonnade +#' @usage NULL +#' @aliases NULL +combine_pillar_distributions <- function(max_fit, min_fit_rev, tier_widths) { + #' @details + #' We determine the cut point where minimum and maximum assignment + #' agree. + #' The following strategy is applied: + #' + #' 1. First, we determine the tier in which the cut point lies. + #' This is the first instance of a column that ends up in the same tier + #' for both minimum and maximum assignment. + cut_point_tier <- max_fit$tier[min(which(max_fit$tier == min_fit_rev$tier))] + #' 2. A set of candidate cut points is derived. + cut_point_candidates <- which(max_fit$tier == cut_point_tier) + #' 3. We consult the column offsets. The last column where the minimum assignment + #' has a greater or equal offset than the maximum assignment is our latest + #' cut point. + cut_point_candidate_idx <- which(max_fit$offset_after[cut_point_candidates] <= min_fit_rev$offset_after[cut_point_candidates]) + if (length(cut_point_candidate_idx) > 0) { + cut_point <- cut_point_candidates[max(cut_point_candidate_idx)] + } else { + #' If no such column exists, the cut point is the column just before our + #' first candidate. + cut_point <- cut_point_candidates[[1]] - 1L + } + + #' 4. Finally, we combine maximum and minimum reverse fits at the cut point. + #' We don't need to redistribute anything here. + max_fit_cut <- max_fit[seq_len(cut_point), ] + min_fit_cut <- min_fit_rev[seq2(cut_point + 1L, nrow(min_fit_rev)), ] + rbind(max_fit_cut, min_fit_cut) +} + #' @rdname colonnade #' @usage NULL #' @aliases NULL distribute_pillars <- function(widths, tier_widths) { - tier <- integer(length(widths)) + tier <- rep(NA_integer_, length(widths)) + offset_after <- rep(NA_integer_, length(widths)) current_tier <- 1L current_x <- 0L @@ -428,33 +451,36 @@ distribute_pillars <- function(widths, tier_widths) { } tier[[i]] <- current_tier - current_x <- current_x + widths[[i]] + 1L + current_x <- current_x + widths[[i]] + offset_after[[i]] <- current_x + current_x <- current_x + 1L } - data_frame(id = seq_along(widths), width = widths, tier = tier) + data_frame(id = seq_along(widths), tier = tier, width = widths, offset_after = offset_after) } distribute_pillars_rev <- function(widths, tier_widths) { ret <- distribute_pillars(rev(widths), rev(tier_widths)) - ret[2:3] <- ret[rev(seq_along(widths)), 2:3] - ret$tier <- length(tier_widths) + 1L - ret$tier - ret -} + ret[2:4] <- ret[rev(seq_along(widths)), 2:4] + tier <- length(tier_widths) + 1L - ret$tier + ret$tier <- tier -distribute_pillars_offset <- function(widths, tier_widths, - widths_offset, tier_widths_offset) { - fit_cut <- distribute_pillars( - widths[seq2(widths_offset, length(widths))], - tier_widths[seq2(tier_widths_offset, length(tier_widths))] - ) - fit_cut$id <- fit_cut$id + (widths_offset - 1L) - fit_cut$tier <- fit_cut$tier + (tier_widths_offset - 1L) - fit_cut + splits <- unname(split(seq_along(tier), tier)) + tier_widths <- tier_widths[seq_along(splits)] + + new_offset_after <- unlist(map2(splits, tier_widths, function(.x, .y) { + new_offset_after <- cumsum(ret$width[.x] + 1) + new_offset_after - max(new_offset_after) + .y + })) + + ret$offset_after <- c(new_offset_after, rep(NA_integer_, sum(is.na(tier)))) + + ret } all_pillars_fit <- function(tier_df) { rows <- nrow(tier_df) - rows == 0 || tier_df$tier[[nrow(tier_df)]] != 0 + rows == 0 || !safe_any_na(tier_df$tier[[nrow(tier_df)]]) } #' @rdname colonnade @@ -464,7 +490,6 @@ colonnade_distribute_space_df <- function(col_widths_df, tier_widths) { "!!!!!DEBUG colonnade_distribute_space_df(`v(tier_widths)`)" col_widths_split <- split(col_widths_df, col_widths_df$tier) - if (any(col_widths_df$tier == 0)) tier_widths <- c(NA, tier_widths) tier_widths <- tier_widths[seq_along(col_widths_split)] col_widths_apply <- map2(col_widths_split, tier_widths, function(x, width) { x$width <- x$width + colonnade_distribute_space(x$width, x$max_widths, width) diff --git a/R/num.R b/R/num.R index c9901d051..75c01c31c 100644 --- a/R/num.R +++ b/R/num.R @@ -40,9 +40,12 @@ #' using exponents that are a multiple of three. #' - `"si"`: Use SI notation, prefixes between `1e-24` and `1e24` are supported. #' @param fixed_exponent -#' Use the same fixed_exponent for all numbers in scientific, engineering or SI notation. +#' Use the same exponent for all numbers in scientific, engineering or SI notation. #' `-Inf` uses the smallest, `+Inf` the largest fixed_exponent present in the data. -#' The default is to use varying fixed_exponents. +#' The default is to use varying exponents. +#' @param extra_sigfig +#' If `TRUE`, increase the number of significant digits if the data consists of +#' numbers of the same magnitude with subtle differences. #' @export #' @examples #' # Display as a vector @@ -97,13 +100,23 @@ #' scilarge = num(10^(-7:6) * 123, notation = "sci", fixed_exponent = 3), #' scimax = num(10^(-7:6) * 123, notation = "sci", fixed_exponent = Inf) #' ) +#' +#' #' Extra significant digits +#' tibble::tibble( +#' default = num(100 + 1:3 * 0.001), +#' extra1 = num(100 + 1:3 * 0.001, extra_sigfig = TRUE), +#' extra2 = num(100 + 1:3 * 0.0001, extra_sigfig = TRUE), +#' extra3 = num(10000 + 1:3 * 0.00001, extra_sigfig = TRUE) +#' ) num <- function(x, ..., sigfig = NULL, digits = NULL, label = NULL, scale = NULL, notation = c("fit", "dec", "sci", "eng", "si"), - fixed_exponent = NULL) { + fixed_exponent = NULL, + extra_sigfig = NULL) { stopifnot(is.numeric(x)) + stopifnot(is.null(digits) || is_integerish(digits)) check_dots_empty() # FIXME: math and arith should also work for integers @@ -121,7 +134,8 @@ num <- function(x, ..., label = label, scale = scale, notation = notation, - fixed_exponent = fixed_exponent + fixed_exponent = fixed_exponent, + extra_sigfig = extra_sigfig ) # FIXME: Include class(x) to support subclassing/mixin? @@ -234,7 +248,8 @@ set_num_opts <- function(x, ..., sigfig = NULL, digits = NULL, label = NULL, scale = NULL, notation = c("fit", "dec", "sci", "eng", "si"), - fixed_exponent = NULL) { + fixed_exponent = NULL, + extra_sigfig = NULL) { check_dots_empty() @@ -254,6 +269,10 @@ set_num_opts <- function(x, ..., abort("Must set `label` if `scale` is provided.") } + if (!is.null(digits) && !is.null(extra_sigfig)) { + abort("Incompatible arguments: `extra_sigfig` and `digits`.") + } + pillar_attr <- structure( list( sigfig = sigfig, @@ -261,7 +280,8 @@ set_num_opts <- function(x, ..., label = label, scale = scale, notation = notation, - fixed_exponent = fixed_exponent + fixed_exponent = fixed_exponent, + extra_sigfig = extra_sigfig ), class = c("pillar_num_attr", "pillar_vctr_attr", "tibble_vec_attr") ) @@ -281,6 +301,7 @@ format.pillar_num_attr <- function(x, ...) { sigfig <- x$sigfig digits <- x$digits label <- x$label + extra_sigfig <- x$extra_sigfig if (!is.null(digits)) { if (digits >= 0) { @@ -290,6 +311,12 @@ format.pillar_num_attr <- function(x, ...) { } } else if (!is.null(sigfig)) { out <- paste0(class, ":", sigfig) + + if (isTRUE(extra_sigfig)) { + out <- paste0(out, "*") + } + } else if (isTRUE(extra_sigfig)) { + out <- paste0(class, "*") } else { out <- class } diff --git a/R/options.R b/R/options.R new file mode 100644 index 000000000..bac6e24c8 --- /dev/null +++ b/R/options.R @@ -0,0 +1,202 @@ +#' Package options +#' +#' Options that affect display of tibble-like output. +#' +#' These options can be set via [options()] and queried via [getOption()]. +#' For this, add a `pillar.` prefix (the package name and a dot) to the option name. +#' Example: for an option `foo`, use `options(pillar.foo = value)` to set it +#' and `getOption("pillar.foo")` to retrieve the current value. +#' An option value of `NULL` means that the default is used. +#' +#' @format NULL +#' +#' @examples +#' # Default setting: +#' getOption("pillar.sigfig") +#' pillar(1.234567) +#' +#' # Change for the duration of the session: +#' old <- options(pillar.sigfig = 6) +#' pillar(1.234567) +#' +#' # Change back to the original value: +#' options(old) +#' pillar(1.234567) +#' +#' # Local scope: +#' local({ +#' rlang::local_options(pillar.sigfig = 6) +#' pillar(1.234567) +#' }) +#' pillar(1.234567) +#' @section Options for the pillar package: +pillar_options <- list2( + #' - `print_max`: Maximum number of rows printed, default: `20`. + #' Set to \code{Inf} to always print all rows. + #' For compatibility reasons, `getOption("tibble.print_max")` and + #' `getOption("dplyr.print_max")` are also consulted, + #' this will be soft-deprecated in pillar v2.0.0. + print_max = make_option_impl( + getOption("pillar.print_max", default = tibble_opt("print_max", 20L)) + ), + #' - `print_min`: Number of rows printed if the table has more than + #' `print_max` rows, default: `10`. + #' For compatibility reasons, `getOption("tibble.print_min")` and + #' `getOption("dplyr.print_min")` are also consulted, + #' this will be soft-deprecated in pillar v2.0.0. + print_min = make_option_impl( + getOption("pillar.print_min", default = tibble_opt("print_min", 10L)) + ), + #' - `width`: Output width. Default: `NULL` + #' (use `getOption("width")`). + #' This can be larger than `getOption("width")`, in this case the output + #' of the table's body is distributed over multiple tiers for wide tibbles. + #' For compatibility reasons, `getOption("tibble.width")` and + #' `getOption("dplyr.width")` are also consulted, + #' this will be soft-deprecated in pillar v2.0.0. + width = make_option_impl( + getOption("pillar.width", default = tibble_opt("width", getOption("width"))) + ), + #' - `max_footer_lines`: The maximum number of lines in the footer, + #' default: `7`. Set to `Inf` to turn off truncation of footer lines. + #' The `max_extra_cols` option still limits + #' the number of columns printed. + max_footer_lines = make_option_impl( + getOption("pillar.max_footer_lines", default = 7L) + ), + #' - `max_extra_cols`: The maximum number of columns printed in the footer, + #' default: `100`. Set to `Inf` to show all columns. + #' Set the more predictable `max_footer_lines` to control the number + #' of footer lines instead. + max_extra_cols = make_option_impl( + getOption("pillar.max_extra_cols", default = tibble_opt("max_extra_cols", 100L)) + ), + #' - `bold`: Use bold font, e.g. for column headers? This currently + #' defaults to `FALSE`, because many terminal fonts have poor support for + #' bold fonts. + bold = make_option_impl( + getOption("pillar.bold", default = FALSE) + ), + #' - `subtle`: Use subtle style, e.g. for row numbers and data types? + #' Default: `TRUE`. + subtle = make_option_impl( + getOption("pillar.subtle", default = TRUE) + ), + #' - `subtle_num`: Use subtle style for insignificant digits? Default: + #' `FALSE`, is also affected by the `subtle` option. + subtle_num = make_option_impl( + getOption("pillar.subtle_num", default = FALSE) + ), + #' - `neg`: Highlight negative numbers? Default: `TRUE`. + neg = make_option_impl( + getOption("pillar.neg", default = TRUE) + ), + #' - `sigfig`: The number of significant digits that will be printed and + #' highlighted, default: `3`. Set the `subtle` option to `FALSE` to + #' turn off highlighting of significant digits. + sigfig = make_option_impl(option_name = "pillar.sigfig", { + sigfig <- getOption("pillar.sigfig", default = 3L) + if (!is.numeric(sigfig) || length(sigfig) != 1 || sigfig < 1L) { + inform("Option pillar.sigfig must be a positive number greater or equal 1. Resetting to 3.") + sigfig <- 3L + set_pillar_option_sigfig(sigfig) + } + sigfig + }), + #' - `min_title_chars`: The minimum number of characters for the column + #' title, default: `15`. Column titles may be truncated up to that width to + #' save horizontal space. Set to `Inf` to turn off truncation of column + #' titles. + min_title_chars = make_option_impl( + getOption("pillar.min_title_chars", default = 15L) + ), + #' - `min_chars`: The minimum number of characters wide to + #' display character columns, default: `3`. Character columns may be + #' truncated up to that width to save horizontal space. Set to `Inf` to + #' turn off truncation of character columns. + min_chars = make_option_impl(option_name = "pillar.min_chars", { + min_chars <- getOption("pillar.min_chars", default = 3L) + if (!is.numeric(min_chars) || length(min_chars) != 1 || min_chars < 3L) { + inform("Option pillar.min_chars must be a nonnegative number greater or equal 3. Resetting to 3.") + min_chars <- 3L + set_pillar_option_min_chars(min_chars) + } + min_chars + }), + #' - `max_dec_width`: The maximum allowed width for decimal notation, + #' default: `13`. + max_dec_width = make_option_impl( + getOption("pillar.max_dec_width", default = 13L) + ), + #' - `bidi`: Set to `TRUE` for experimental support for bidirectional scripts. + #' Default: `FALSE`. When this option is set, "left right override" + #' and "first strong isolate" + #' [Unicode controls](https://www.w3.org/International/questions/qa-bidi-unicode-controls) + #' are inserted to ensure that text appears in its intended direction + #' and that the column headings correspond to the correct columns. + bidi = make_option_impl( + getOption("pillar.bidi", default = FALSE) + ), +) + +tibble_opt <- function(x, default) { + x_tibble <- paste0("tibble.", x) + res <- getOption(x_tibble) + if (!is.null(res)) { + return(res) + } + + x_dplyr <- paste0("dplyr.", x) + res <- getOption(x_dplyr) + if (!is.null(res)) { + return(res) + } + + default +} + +get_width_print <- function(width) { + if (!is.null(width)) { + return(width) + } + + get_pillar_option_width() +} + +get_width_glimpse <- function(width) { + width <- get_width_print(width) + + if (is.finite(width)) { + width + } else { + getOption("width") + } +} + +get_n_print <- function(n, rows) { + if (!is.null(n) && n >= 0) { + return(n) + } + + if (is.na(rows) || rows > get_pillar_option_print_max()) { + get_pillar_option_print_min() + } else { + rows + } +} + +get_max_extra_cols <- function(max_extra_cols) { + if (!is.null(max_extra_cols) && max_extra_cols >= 0) { + return(max_extra_cols) + } + + get_pillar_option_max_extra_cols() +} + +get_max_footer_lines <- function(max_footer_lines) { + if (!is.null(max_footer_lines) && max_footer_lines >= 0) { + return(max_footer_lines) + } + + get_pillar_option_max_footer_lines() +} diff --git a/R/pillar-package.R b/R/pillar-package.R index 3d24e05d6..f6067e237 100644 --- a/R/pillar-package.R +++ b/R/pillar-package.R @@ -7,33 +7,10 @@ #' using the full range of colours provided by modern terminals. #' Provides various generics for making every aspect of the display customizable. #' -#' @details -#' See [pillar()] for formatting a single column, -#' and [print.tbl()] for formatting data-frame-like objects. -#' -#' @section Package options: -#' -#' - `pillar.bold`: Use bold font, e.g. for column headers? This currently -#' defaults to `FALSE`, because many terminal fonts have poor support for -#' bold fonts. -#' - `pillar.subtle`: Use subtle style, e.g. for row numbers and data types? -#' Default: `TRUE`. -#' - `pillar.subtle_num`: Use subtle style for insignificant digits? Default: -#' `FALSE`, is also affected by the `pillar.subtle` option. -#' - `pillar.neg`: Highlight negative numbers? Default: `TRUE`. -#' - `pillar.sigfig`: The number of significant digits that will be printed and -#' highlighted, default: `3`. Set the `pillar.subtle` option to `FALSE` to -#' turn off highlighting of significant digits. -#' - `pillar.min_title_chars`: The minimum number of characters for the column -#' title, default: `15`. Column titles may be truncated up to that width to -#' save horizontal space. Set to `Inf` to turn off truncation of column -#' titles. -#' - `pillar.min_chars`: The minimum number of characters wide to -#' display character columns, default: `0`. Character columns may be -#' truncated up to that width to save horizontal space. Set to `Inf` to -#' turn off truncation of character columns. -#' - `pillar.max_dec_width`: The maximum allowed width for decimal notation, -#' default 13. +#' @seealso +#' - [pillar()] for formatting a single column, +#' - [print.tbl()] for formatting data-frame-like objects, +#' - [pillar_options] for a list of package options. #' #' @examples #' pillar(1:3) diff --git a/R/shaft-.R b/R/shaft-.R index 6432a16fa..f3d285ed1 100644 --- a/R/shaft-.R +++ b/R/shaft-.R @@ -134,30 +134,30 @@ pillar_shaft.numeric <- function(x, ..., sigfig = NULL) { sigfig %||% pillar_attr$sigfig, pillar_attr$digits, pillar_attr$notation, - pillar_attr$fixed_exponent + pillar_attr$fixed_exponent, + pillar_attr$extra_sigfig ) } -pillar_shaft_number <- function(x, sigfig, digits, notation, fixed_exponent) { +pillar_shaft_number <- function(x, sigfig, digits, notation, fixed_exponent, extra_sigfig) { if (!is.null(digits)) { if (!is.numeric(digits) || length(digits) != 1) { abort("`digits` must be a number.") } } if (is.null(sigfig)) { - sigfig <- getOption("pillar.sigfig", 3) - if (!is.numeric(sigfig) || length(sigfig) != 1 || sigfig < 1L) { - inform("Option pillar.sigfig must be a positive number greater or equal 1. Resetting to 1.") - sigfig <- 1L - options(pillar.sigfig = sigfig) - } + sigfig <- get_pillar_option_sigfig() + } + + if (isTRUE(extra_sigfig)) { + sigfig <- sigfig + compute_extra_sigfig(x) } if (is.null(notation) || notation == "fit") { dec <- split_decimal(x, sigfig = sigfig, digits = digits) sci <- split_decimal(x, sigfig = sigfig, digits = digits, sci_mod = 1, fixed_exponent = fixed_exponent) - max_dec_width <- getOption("pillar.max_dec_width", 13) + max_dec_width <- get_pillar_option_max_dec_width() dec_width <- get_width(dec) "!!!!!!DEBUG `v(dec_width)`" @@ -207,7 +207,7 @@ pillar_shaft_number <- function(x, sigfig, digits, notation, fixed_exponent) { # registered in .onLoad() pillar_shaft.integer64 <- function(x, ..., sigfig = NULL) { - pillar_shaft_number(x, sigfig, digits = NULL, notation = NULL, fixed_exponent = NULL) + pillar_shaft_number(x, sigfig, digits = NULL, notation = NULL, fixed_exponent = NULL, extra_sigfig = NULL) } # registered in .onLoad() @@ -281,12 +281,7 @@ pillar_shaft.character <- function(x, ..., min_width = NULL) { # determine width based on width of characters in the vector if (is.null(min_chars)) { - min_chars <- getOption("pillar.min_chars", 3L) - if (!is.numeric(min_chars) || length(min_chars) != 1 || min_chars < 3L) { - inform("Option pillar.min_chars must be a nonnegative number greater or equal 3. Resetting to 3.") - min_chars <- 3L - options(pillar.min_chars = min_chars) - } + min_chars <- get_pillar_option_min_chars() } pillar_shaft(new_vertical(out), ..., min_width = min_chars, na_indent = na_indent, shorten = pillar_attr$shorten) diff --git a/R/sigfig.R b/R/sigfig.R index a271f41af..74f5d792e 100644 --- a/R/sigfig.R +++ b/R/sigfig.R @@ -236,6 +236,19 @@ compute_min_sigfig <- function(x) { ret } +compute_extra_sigfig <- function(x) { + x <- sort(abs(x)) + delta <- diff(x) + x <- x[-1] + + keep <- which((delta != 0) & is.finite(delta)) + if (length(keep) == 0) { + return(0) + } + + ceiling(log10(max(x[keep] / delta[keep]))) - 1 +} + LOG_10 <- log(10) compute_exp <- function(x, sigfig, digits) { diff --git a/R/styles.R b/R/styles.R index dd9f784e5..1d488c08b 100644 --- a/R/styles.R +++ b/R/styles.R @@ -14,16 +14,16 @@ keep_empty <- function(fun) { #' Functions that allow implementers of formatters for custom data types to #' maintain a consistent style with the default data types. #' -#' `style_subtle()` is affected by the `pillar.subtle` option. +#' `style_subtle()` is affected by the `subtle` [option][pillar_options]. #' #' @param x The character vector to style. #' @export -#' @seealso [pillar-package] for a list of options +#' @seealso [pillar_options] for a list of options #' @examples #' style_subtle("text") style_subtle <- keep_empty(function(x) { force(x) - if (isTRUE(getOption("pillar.subtle", TRUE))) { + if (isTRUE(get_pillar_option_subtle())) { crayon_grey_0.6(x) } else { x @@ -32,14 +32,15 @@ style_subtle <- keep_empty(function(x) { #' @rdname style_subtle #' @details -#' `style_subtle_num()` is affected by the `pillar.subtle_num` option, which is -#' `FALSE` by default. +#' `style_subtle_num()` is affected by the +#' `subtle_num` [option][pillar_options], +#' which is `FALSE` by default. #' #' @export #' @examples #' style_subtle_num(0.01 * 1:3, c(TRUE, FALSE, TRUE)) style_subtle_num <- function(x, negative) { - if (isTRUE(getOption("pillar.subtle_num", FALSE))) { + if (isTRUE(get_pillar_option_subtle_num())) { style_subtle(x) } else { ifelse(negative, style_neg(x), x) @@ -48,7 +49,7 @@ style_subtle_num <- function(x, negative) { style_hint <- keep_empty(function(x) { force(x) - if (isTRUE(getOption("pillar.subtle", TRUE))) { + if (isTRUE(get_pillar_option_subtle())) { crayon_grey_0.8(x) } else { x @@ -60,14 +61,15 @@ style_spark_na <- function(x) { } #' @details -#' `style_bold()` is affected by the `pillar.bold` option. +#' `style_bold()` is affected by the `bold` [option][pillar_options], +#' which is `FALSE` by default. #' #' @rdname style_subtle #' @export #' @examples #' style_bold("Petal.Width") style_bold <- keep_empty(function(x) { - if (isTRUE(getOption("pillar.bold", FALSE))) { + if (isTRUE(get_pillar_option_bold())) { crayon_bold(x) } else { x @@ -83,14 +85,14 @@ style_na <- function(x) { } #' @details -#' `style_neg()` is affected by the `pillar.neg` option. +#' `style_neg()` is affected by the `pillar.neg` [option][pillar_options]. #' #' @rdname style_subtle #' @export #' @examples #' style_neg("123") style_neg <- keep_empty(function(x) { - if (isTRUE(getOption("pillar.neg", TRUE))) { + if (isTRUE(get_pillar_option_neg())) { crayon_red(x) } else { x diff --git a/R/tbl-format-footer.R b/R/tbl-format-footer.R index a3071a8d3..63961fa0b 100644 --- a/R/tbl-format-footer.R +++ b/R/tbl-format-footer.R @@ -116,17 +116,19 @@ wrap_footer <- function(footer, setup) { # When asking for width = 80, use at most 79 characters max_extent <- setup$width - 1L - # FIXME: Make n_tiers configurable - tier_widths <- get_footer_tier_widths(footer, max_extent, n_tiers = Inf) + tier_widths <- get_footer_tier_widths( + footer, max_extent, + setup$max_footer_lines + ) # show optuput even if too wide widths <- pmin(get_extent(footer), max_extent - 4L) wrap <- colonnade_compute_tiered_col_widths_df(widths, widths, tier_widths) # truncate output that doesn't fit - wrap <- wrap[wrap$tier != 0, ] + truncated <- anyNA(wrap$tier) split <- split(footer[wrap$id], wrap$tier) - if (nrow(wrap) < length(footer) && length(split) > 0) { + if (truncated && length(split) > 0) { split[[length(split)]] <- c(split[[length(split)]], cli::symbol$ellipsis) } split <- imap(split, function(x, y) c("#", if (y == 1) cli::symbol$ellipsis else " ", x)) diff --git a/R/tbl-format-setup.R b/R/tbl-format-setup.R index ae0b3b268..9be0f80e6 100644 --- a/R/tbl-format-setup.R +++ b/R/tbl-format-setup.R @@ -43,11 +43,17 @@ #' Extra arguments to [print.tbl()] or [format.tbl()]. #' @param n #' Actual number of rows to print. -#' No [option]s should be considered by implementations of this method. +#' No [options][pillar_options] should be considered +#' by implementations of this method. #' @param max_extra_cols #' Number of columns to print abbreviated information for, #' if the width is too small for the entire tibble. -#' No [option]s should be considered by implementations of this method. +#' No [options][pillar_options] should be considered +#' by implementations of this method. +#' @param max_footer_lines +#' Maximum number of lines for the footer. +#' No [options][pillar_options] should be considered +#' by implementations of this method. #' #' @return #' An object that can be passed as `setup` argument to @@ -56,7 +62,8 @@ #' @examplesIf rlang::is_installed("palmerpenguins") #' tbl_format_setup(palmerpenguins::penguins) tbl_format_setup <- function(x, width = NULL, ..., - n = NULL, max_extra_cols = NULL) { + n = NULL, max_extra_cols = NULL, + max_footer_lines = NULL) { "!!!!DEBUG tbl_format_setup()" width <- get_width_print(width) @@ -64,15 +71,19 @@ tbl_format_setup <- function(x, width = NULL, ..., n <- get_n_print(n, nrow(x)) max_extra_cols <- get_max_extra_cols(max_extra_cols) + max_footer_lines <- get_max_footer_lines(max_footer_lines) # Calls UseMethod("tbl_format_setup"), # allows using default values in S3 dispatch - out <- tbl_format_setup_(x, width, ..., n = n, max_extra_cols = max_extra_cols) + out <- tbl_format_setup_( + x, width, ..., + n = n, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines + ) return(out) UseMethod("tbl_format_setup") } -tbl_format_setup_ <- function(x, width, ..., n, max_extra_cols) { +tbl_format_setup_ <- function(x, width, ..., n, max_extra_cols, max_footer_lines) { UseMethod("tbl_format_setup") } @@ -84,7 +95,7 @@ tbl_format_setup_ <- function(x, width, ..., n, max_extra_cols) { #' @rdname tbl_format_setup #' @export tbl_format_setup.tbl <- function(x, width, ..., - n, max_extra_cols) { + n, max_extra_cols, max_footer_lines) { "!!!!DEBUG tbl_format_setup.tbl()" # Number of rows @@ -148,7 +159,8 @@ tbl_format_setup.tbl <- function(x, width, ..., rows_missing = rows_missing, rows_total = rows, extra_cols = extra_cols, - extra_cols_total = extra_cols_total + extra_cols_total = extra_cols_total, + max_footer_lines = max_footer_lines ) } @@ -177,11 +189,13 @@ tbl_format_setup.tbl <- function(x, width, ..., #' as a character vector of formatted column names and types. #' @param extra_cols_total The total number of columns, may be larger than #' `length(extra_cols)`. +#' @param max_footer_lines The maximum number of lines in the footer. #' #' @keywords internal new_tbl_format_setup <- function(x, df, width, tbl_sum, body, rows_missing, rows_total, - extra_cols, extra_cols_total) { + extra_cols, extra_cols_total, + max_footer_lines) { trunc_info <- list( x = x, df = df, @@ -191,7 +205,8 @@ new_tbl_format_setup <- function(x, df, width, tbl_sum, body, rows_missing = rows_missing, rows_total = rows_total, extra_cols = extra_cols, - extra_cols_total = extra_cols_total + extra_cols_total = extra_cols_total, + max_footer_lines = max_footer_lines ) structure(trunc_info, class = "pillar_tbl_format_setup") diff --git a/R/tbl-format.R b/R/tbl-format.R index 886f87f99..0361a2d99 100644 --- a/R/tbl-format.R +++ b/R/tbl-format.R @@ -1,55 +1,64 @@ #' Formatting of tbl objects #' -#' @description -#' These functions and methods are responsible for printing objects -#' of the `"tbl"` class, which includes [tibble][tibble::tibble]s -#' and dbplyr lazy tables. -#' See [tibble::formatting] for user level documentation, -#' and `vignette("customization")` for details. -#' -#' While it is possible to implement a custom [format()] or [print()] method -#' for your tibble-like objects, it should never be necessary -#' if your class inherits from `"tbl"`. -#' In this case, the default methods offer many customization options -#' at every level of detail. -#' This means you only need to override or extend implementations for the parts -#' that need change. -#' -#' The output uses color and highlighting according to the `"cli.num_colors"` option. -#' Set it to `1` to suppress colored and highlighted output. -#' -#' @seealso -#' -#' - [tbl_format_setup()] for preparing an object for formatting -#' -#' @param x Object to format or print. -#' @param ... Passed on to [tbl_format_setup()]. -#' @param n Number of rows to show. If `NULL`, the default, will print all rows -#' if less than option `tibble.print_max`. Otherwise, will print -#' `tibble.print_min` rows. -#' @param width Width of text output to generate. This defaults to `NULL`, which -#' means use `getOption("tibble.width")` or (if also `NULL`) -#' `getOption("width")`; the latter displays only the columns that fit on one -#' screen. You can also set `options(tibble.width = Inf)` to override this -#' default and always print all columns. -#' @param n_extra Number of extra columns to print abbreviated information for, -#' if the width is too small for the entire tibble. If `NULL`, the default, -#' the value of the [`tibble.max_extra_cols`][tibble::tibble-package] option is used. +#' See [tibble::formatting] for details. #' #' @name format_tbl #' @export -#' @examples -#' print(vctrs::new_data_frame(list(a = 1), class = "tbl")) -print.tbl <- function(x, width = NULL, ..., n = NULL, n_extra = NULL) { - writeLines(format(x, width = width, ..., n = n, n_extra = n_extra)) +#' @keywords internal +print.tbl <- function(x, width = NULL, ..., n = NULL, max_extra_cols = NULL, + max_footer_lines = NULL) { + print_tbl( + x, width, ..., + n = n, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines + ) +} + +print_tbl <- function(x, width = NULL, ..., + n_extra = NULL, + n = NULL, max_extra_cols = NULL, max_footer_lines = NULL) { + + if (!is.null(n_extra)) { + deprecate_soft( + "1.6.2", "pillar::print(n_extra = )", "pillar::print(max_extra_cols = )", + user_env = caller_env(2) + ) + if (is.null(max_extra_cols)) { + max_extra_cols <- n_extra + } + } + + writeLines(format( + x, width = width, ..., + n = n, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines + )) invisible(x) } #' @export #' @rdname format_tbl -format.tbl <- function(x, width = NULL, ..., n = NULL, n_extra = NULL) { +format.tbl <- function(x, width = NULL, ..., + n = NULL, max_extra_cols = NULL, max_footer_lines = NULL) { + format_tbl( + x, width, ..., + n = n, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines + ) +} + +format_tbl <- function(x, width = NULL, ..., + n_extra = NULL, + n = NULL, max_extra_cols = NULL, max_footer_lines = NULL) { check_dots_empty(action = signal) + if (!is.null(n_extra)) { + deprecate_soft( + "1.6.2", "pillar::format(n_extra = )", "pillar::format(max_extra_cols = )", + user_env = caller_env(2) + ) + if (is.null(max_extra_cols)) { + max_extra_cols <- n_extra + } + } + # Reset local cache for each new output force(x) num_colors(forget = TRUE) @@ -57,7 +66,8 @@ format.tbl <- function(x, width = NULL, ..., n = NULL, n_extra = NULL) { setup <- tbl_format_setup(x, width = width, ..., n = n, - max_extra_cols = n_extra + max_extra_cols = max_extra_cols, + max_footer_lines = max_footer_lines ) header <- tbl_format_header(x, setup) diff --git a/R/testthat.R b/R/testthat.R index 7066e5456..09ce62a5e 100644 --- a/R/testthat.R +++ b/R/testthat.R @@ -63,6 +63,7 @@ expect_known_display <- function(object, file, ..., width = 80L, crayon = TRUE) num_colors(forget = TRUE) }) + testthat::local_edition(2) testthat::expect_known_output(print(eval_tidy(object)), file, update = TRUE, width = width) } # nocov end diff --git a/R/tibble-opt.R b/R/tibble-opt.R deleted file mode 100644 index 12a7116c1..000000000 --- a/R/tibble-opt.R +++ /dev/null @@ -1,72 +0,0 @@ -## user-facing docs kept in `formatting` topic; see utils-format.R -## Exception: tibble.view_max, in `tibble-package` -op.tibble <- list( - tibble.print_max = 20L, - tibble.print_min = 10L, - tibble.width = NULL, - tibble.max_extra_cols = 100L -) - -tibble_opt <- function(x, dplyr = TRUE) { - x_tibble <- paste0("tibble.", x) - res <- getOption(x_tibble) - if (!is.null(res)) { - return(res) - } - - if (dplyr) { - x_dplyr <- paste0("dplyr.", x) - res <- getOption(x_dplyr) - if (!is.null(res)) { - return(res) - } - } - - op.tibble[[x_tibble]] -} - -get_width_print <- function(width) { - if (!is.null(width)) { - return(width) - } - - width <- tibble_opt("width") - if (!is.null(width)) { - return(width) - } - - getOption("width") -} - -get_width_glimpse <- function(width) { - if (!is.null(width)) { - return(width) - } - - width <- tibble_opt("width") - if (!is.null(width) && is.finite(width)) { - return(width) - } - - getOption("width") -} - -get_n_print <- function(n, rows) { - if (!is.null(n) && n >= 0) { - return(n) - } - - if (is.na(rows) || rows > tibble_opt("print_max")) { - tibble_opt("print_min") - } else { - rows - } -} - -get_max_extra_cols <- function(max_extra_cols) { - if (!is.null(max_extra_cols) && max_extra_cols >= 0) { - return(max_extra_cols) - } - - tibble_opt("max_extra_cols") -} diff --git a/R/title.R b/R/title.R index 6096986c4..370412752 100644 --- a/R/title.R +++ b/R/title.R @@ -33,7 +33,7 @@ new_pillar_title <- function(x, ...) { } get_min_title_width <- function(width) { - title_chars <- getOption("pillar.min_title_chars", 15) + title_chars <- get_pillar_option_min_title_chars() if (!is.numeric(title_chars) || length(title_chars) != 1 || title_chars < 0) { stop("Option pillar.min_title_chars must be a nonnegative number", call. = FALSE) } diff --git a/R/type-sum.R b/R/type-sum.R index c2928e2f5..fa34c8a41 100644 --- a/R/type-sum.R +++ b/R/type-sum.R @@ -67,11 +67,13 @@ vec_ptype_abbr.pillar_empty_col <- function(x, ...) { } #' @description -#' `obj_sum()` also includes the size of the object if [vctrs::vec_is()] -#' is `TRUE`. +#' `obj_sum()` also includes the size (but not the shape) of the object +#' if [vctrs::vec_is()] is `TRUE`. #' It should always return a string (a character vector of length one). +#' As of pillar v1.6.1, the default method forwards to [vctrs::vec_ptype_abbr()] +#' for vectors and to [type_sum()] for other objects. +#' Previous versions always forwarded to [type_sum()]. #' -#' @keywords internal #' @examples #' obj_sum(1:10) #' obj_sum(matrix(1:10)) diff --git a/R/type.R b/R/type.R index dafe22f72..ea974e21b 100644 --- a/R/type.R +++ b/R/type.R @@ -76,6 +76,7 @@ format_full_pillar_type <- function(x) { #' type_sum.accel <- function(x) { #' I("kg m/s^2") #' } +#' #' accel <- structure(9.81, class = "accel") #' pillar(accel) format_type_sum <- function(x, width, ...) { @@ -86,6 +87,11 @@ format_type_sum <- function(x, width, ...) { UseMethod("format_type_sum") } +# https://github.com/r-lib/pkgdown/issues/1540 +type_sum.accel <- function(x) { + I("kg m/s^2") +} + #' @export #' @rdname format_type_sum format_type_sum.default <- function(x, width, ...) { diff --git a/R/utils.R b/R/utils.R index 72f740849..3e52c1307 100644 --- a/R/utils.R +++ b/R/utils.R @@ -112,3 +112,15 @@ v <- function(x) { expr <- rlang::expr_deparse(substitute(x), width = Inf) paste0(expr, " = ", rlang::expr_deparse(x, width = 80)[[1]]) } + +# Needed for R 3.4 and earlier +safe_is_na <- function(x) { + if (is.null(x)) { + return(logical()) + } + is.na(x) +} + +safe_any_na <- function(x) { + anyNA(x) +} diff --git a/R/zzz.R b/R/zzz.R index 3e464b5a1..567bd8638 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -2,7 +2,7 @@ #' @import rlang #' @import ellipsis -#' @import lifecycle +#' @importFrom lifecycle deprecate_soft #' @importFrom vctrs data_frame #' @importFrom vctrs new_data_frame #' @importFrom vctrs obj_print_footer @@ -58,6 +58,11 @@ NULL debug_info() } + # https://github.com/r-lib/pkgdown/issues/1540 + if (Sys.getenv("IN_PKGDOWN") != "") { + register_s3_method("pillar", "type_sum", "accel") + } + invisible() } diff --git a/TODO.md b/TODO.md index 837e8d065..3cbb70221 100644 --- a/TODO.md +++ b/TODO.md @@ -2,29 +2,46 @@ ## Next steps -- revdepcheck for adding ellipsis to methods +- Pass `max_footer_lines` to `print.tbl()`, rethink option name +- Test all options - Milestone: +- CRAN release +- triage issues + +- documentation cleanup from : + - relink digits vignette, shorten numbers vignette, replace ?num, ?char and print.tbl() with internal stubs +- expand list columns + +- revdepcheck for adding ellipsis to methods - Focus columns at their native position, with ... or subtle vertical pipe inbetween (1 char wide) + - Easiest if focus columns are moved to the beginning - Get extra width? -- Discuss: - - Add convenience arguments to `print.tbl()`? - Breaking changes - Wide character + list column: why does the character column take up all the space? - `tibble(a = strrep("1234567890", 100), b = list(tibble(a = letters)))` + - Because the minimum character width is used here; this is just the default shaft. We can show only the type if there's lack of space and build a custom pillar shaft + - Abbreviate list columns at the left? - Redundant information goes up into the header - call `type_sum()` on the pillar shaft -- if it returns `NULL` (as in the default method) call it on the vector - Search for `new_pillar_type()` - Maybe it's easier to recompute in `type_sum()` and `vec_ptype_abbr()` - not sure, problems dealing with truncated vs. actual length - Avoid showing dimensions twice in `obj_sum()`, use `vec_ptype_abbr()` (with default handling of non-vctrs things) and not `type_sum()` + - Is this done already? - Shorter list columns: - - Abbreviate list columns at the left: +- Prototype - Multi-stage (hierarchical) output for packed data frames + - Challenging with tiers + - Show number of columns in the parent stage? + - If too wide; also show ellipsis + - Perhaps show column names in footer? + - Can we agree that a packed data frame never spans multiple tiers? - Show column names that are abbreviated in full - - Packed data frames and matrices: if too wide, show ellipsis + - With their index if non-consecutive - Tick column title in extra columns + - It should be? - Second backtick if column name is abbreviated, - Simplify matrix formatting to format like an array: - Show number of rows if known @@ -32,7 +49,9 @@ - `format_glimpse()` uses `pillar_shaft()` for numbers - Reduce minimum width to 1 - Show time zone for times: + - refer to clock? - Class for numbers of same magnitude but with subtle differences? + - Subtle coloring for repetitive parts? - Highlight equal parts of a string column - `shorten = "unique"`? - `shorten = "front"`: right-align? diff --git a/_pkgdown.yml b/_pkgdown.yml index 23c8d0779..6b4ef3224 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -6,7 +6,6 @@ reference: Override or extend these methods if you want to customize the appearance of your tibble-like object. contents: - - format_tbl - tbl_format_setup - tbl_format_header - tbl_format_body @@ -28,7 +27,7 @@ reference: - format_type_sum - title: Styling desc: > - For consistent output of different data types. + For consistent output. contents: - starts_with("style_") - align @@ -36,13 +35,14 @@ reference: - new_ornament - new_pillar_title - new_pillar_type + - dim_desc - title: Vector classes contents: - num - char - title: Miscellaneous contents: - - dim_desc + - pillar_options - pillar-package navbar: @@ -61,7 +61,7 @@ navbar: href: index.html options: text: Options - href: "reference/pillar-package.html#package-options" + href: "reference/pillar_options.html" reference: text: Reference href: reference/index.html @@ -74,10 +74,6 @@ navbar: articles: text: Articles menu: - - text: Controlling display of numbers - href: articles/numbers.html - - text: "Significant figures and scientific notation" - href: articles/digits.html - text: Custom formatting href: articles/extending.html - text: 'Printing a tibble: Control and data flow' diff --git a/cran-comments.md b/cran-comments.md index 5032e2d28..0bd49ec80 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,15 +1,16 @@ -pillar 1.6.1 +pillar 1.6.4 ## Cran Repository Policy -- [x] Reviewed CRP last edited 2021-04-25. +- [x] Reviewed CRP last edited 2021-09-25. ## R CMD check results -- [x] Checked locally, R 4.0.5 -- [x] Checked on CI system, R 4.0.5 +- [x] Checked locally, R 4.1.1 +- [x] Checked on CI system, R 4.1.1 - [x] Checked on win-builder, R devel ## Current CRAN check results -- [x] Checked on 2021-05-16, no problems found. +- [x] Checked on 2021-10-17, problems found: https://cran.r-project.org/web/checks/check_results_pillar.html +- [x] WARN: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-patched-linux-x86_64, r-release-linux-x86_64, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-x86_64, r-devel-windows-x86_64-gcc10-UCRT, r-release-windows-ix86+x86_64, r-oldrel-windows-ix86+x86_64: fixed vignette building errors diff --git a/man/colonnade.Rd b/man/colonnade.Rd index c296992ce..55dc051d8 100644 --- a/man/colonnade.Rd +++ b/man/colonnade.Rd @@ -49,10 +49,28 @@ Otherwise, if the maximum width is too wide, the same test is carried out with the minimum width. If this is still too wide, this is the resulting fit. Otherwise, some tiers from the start -will contain pillars with their maximum width, and the remaining tiers -contain pillars with their minimum width. +will contain pillars with their maximum width, +one tier will contain some pillars with maximum and some with minimum width, +and the remaining tiers contain pillars with their minimum width only. + +For this, we compute a "reverse minimum assignment". + We determine the cut point where minimum and maximum assignment agree. +The following strategy is applied: +\enumerate{ +\item First, we determine the tier in which the cut point lies. +This is the first instance of a column that ends up in the same tier +for both minimum and maximum assignment. +\item A set of candidate cut points is derived. +\item We consult the column offsets. The last column where the minimum assignment +has a greater or equal offset than the maximum assignment is our latest +cut point. +If no such column exists, the cut point is the column just before our +first candidate. +\item Finally, we combine maximum and minimum reverse fits at the cut point. +We don't need to redistribute anything here. +} Fitting pillars into tiers is very similar to a word-wrapping algorithm. In a loop, new tiers are opened if the current tier overflows. diff --git a/man/extra_cols.Rd b/man/extra_cols.Rd index c16c0de5f..e9b75dbc2 100644 --- a/man/extra_cols.Rd +++ b/man/extra_cols.Rd @@ -23,7 +23,4 @@ Formatting a \link{colonnade} object may lead to some columns being omitted due to width restrictions. This method returns a character vector that describes each of the omitted columns. } -\examples{ -extra_cols(squeeze(colonnade(list(a = 1:3, b = 4:6), width = 8))) -} \keyword{internal} diff --git a/man/format_tbl.Rd b/man/format_tbl.Rd index 944eb0b81..d21f85029 100644 --- a/man/format_tbl.Rd +++ b/man/format_tbl.Rd @@ -6,52 +6,25 @@ \alias{format.tbl} \title{Formatting of tbl objects} \usage{ -\method{print}{tbl}(x, width = NULL, ..., n = NULL, n_extra = NULL) +\method{print}{tbl}( + x, + width = NULL, + ..., + n = NULL, + max_extra_cols = NULL, + max_footer_lines = NULL +) -\method{format}{tbl}(x, width = NULL, ..., n = NULL, n_extra = NULL) -} -\arguments{ -\item{x}{Object to format or print.} - -\item{width}{Width of text output to generate. This defaults to \code{NULL}, which -means use \code{getOption("tibble.width")} or (if also \code{NULL}) -\code{getOption("width")}; the latter displays only the columns that fit on one -screen. You can also set \code{options(tibble.width = Inf)} to override this -default and always print all columns.} - -\item{...}{Passed on to \code{\link[=tbl_format_setup]{tbl_format_setup()}}.} - -\item{n}{Number of rows to show. If \code{NULL}, the default, will print all rows -if less than option \code{tibble.print_max}. Otherwise, will print -\code{tibble.print_min} rows.} - -\item{n_extra}{Number of extra columns to print abbreviated information for, -if the width is too small for the entire tibble. If \code{NULL}, the default, -the value of the \code{\link[tibble:tibble-package]{tibble.max_extra_cols}} option is used.} +\method{format}{tbl}( + x, + width = NULL, + ..., + n = NULL, + max_extra_cols = NULL, + max_footer_lines = NULL +) } \description{ -These functions and methods are responsible for printing objects -of the \code{"tbl"} class, which includes \link[tibble:tibble]{tibble}s -and dbplyr lazy tables. -See \link[tibble:formatting]{tibble::formatting} for user level documentation, -and \code{vignette("customization")} for details. - -While it is possible to implement a custom \code{\link[=format]{format()}} or \code{\link[=print]{print()}} method -for your tibble-like objects, it should never be necessary -if your class inherits from \code{"tbl"}. -In this case, the default methods offer many customization options -at every level of detail. -This means you only need to override or extend implementations for the parts -that need change. - -The output uses color and highlighting according to the \code{"cli.num_colors"} option. -Set it to \code{1} to suppress colored and highlighted output. -} -\examples{ -print(vctrs::new_data_frame(list(a = 1), class = "tbl")) -} -\seealso{ -\itemize{ -\item \code{\link[=tbl_format_setup]{tbl_format_setup()}} for preparing an object for formatting -} +See \link[tibble:formatting]{tibble::formatting} for details. } +\keyword{internal} diff --git a/man/format_type_sum.Rd b/man/format_type_sum.Rd index edd96c341..2864f31ee 100644 --- a/man/format_type_sum.Rd +++ b/man/format_type_sum.Rd @@ -40,6 +40,7 @@ pillar(1) type_sum.accel <- function(x) { I("kg m/s^2") } + accel <- structure(9.81, class = "accel") pillar(accel) } diff --git a/man/glimpse.Rd b/man/glimpse.Rd index b2b61774d..e5f306f11 100644 --- a/man/glimpse.Rd +++ b/man/glimpse.Rd @@ -9,8 +9,9 @@ glimpse(x, width = NULL, ...) \arguments{ \item{x}{An object to glimpse at.} -\item{width}{Width of output: defaults to the setting of the option -\code{tibble.width} (if finite) or the width of the console.} +\item{width}{Width of output: defaults to the setting of the +\code{width} \link[=pillar_options]{option} (if finite) +or the width of the console.} \item{...}{Unused, for extensibility.} } diff --git a/man/new_tbl_format_setup.Rd b/man/new_tbl_format_setup.Rd index fe6b9b5cb..e34a31aa5 100644 --- a/man/new_tbl_format_setup.Rd +++ b/man/new_tbl_format_setup.Rd @@ -13,7 +13,8 @@ new_tbl_format_setup( rows_missing, rows_total, extra_cols, - extra_cols_total + extra_cols_total, + max_footer_lines ) } \arguments{ @@ -40,6 +41,8 @@ as a character vector of formatted column names and types.} \item{extra_cols_total}{The total number of columns, may be larger than \code{length(extra_cols)}.} + +\item{max_footer_lines}{The maximum number of lines in the footer.} } \description{ The object returned from the default method of \code{\link[=tbl_format_setup]{tbl_format_setup()}} diff --git a/man/num.Rd b/man/num.Rd index b78b13a24..b40ccb28c 100644 --- a/man/num.Rd +++ b/man/num.Rd @@ -13,7 +13,8 @@ num( label = NULL, scale = NULL, notation = c("fit", "dec", "sci", "eng", "si"), - fixed_exponent = NULL + fixed_exponent = NULL, + extra_sigfig = NULL ) set_num_opts( @@ -24,7 +25,8 @@ set_num_opts( label = NULL, scale = NULL, notation = c("fit", "dec", "sci", "eng", "si"), - fixed_exponent = NULL + fixed_exponent = NULL, + extra_sigfig = NULL ) } \arguments{ @@ -60,9 +62,12 @@ using exponents that are a multiple of three. \item \code{"si"}: Use SI notation, prefixes between \code{1e-24} and \code{1e24} are supported. }} -\item{fixed_exponent}{Use the same fixed_exponent for all numbers in scientific, engineering or SI notation. +\item{fixed_exponent}{Use the same exponent for all numbers in scientific, engineering or SI notation. \code{-Inf} uses the smallest, \code{+Inf} the largest fixed_exponent present in the data. -The default is to use varying fixed_exponents.} +The default is to use varying exponents.} + +\item{extra_sigfig}{If \code{TRUE}, increase the number of significant digits if the data consists of +numbers of the same magnitude with subtle differences.} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} @@ -135,6 +140,14 @@ tibble::tibble( scilarge = num(10^(-7:6) * 123, notation = "sci", fixed_exponent = 3), scimax = num(10^(-7:6) * 123, notation = "sci", fixed_exponent = Inf) ) + +#' Extra significant digits +tibble::tibble( + default = num(100 + 1:3 * 0.001), + extra1 = num(100 + 1:3 * 0.001, extra_sigfig = TRUE), + extra2 = num(100 + 1:3 * 0.0001, extra_sigfig = TRUE), + extra3 = num(10000 + 1:3 * 0.00001, extra_sigfig = TRUE) +) \dontshow{\}) # examplesIf} } \seealso{ diff --git a/man/pillar-package.Rd b/man/pillar-package.Rd index 301d38a09..7ded9af2c 100644 --- a/man/pillar-package.Rd +++ b/man/pillar-package.Rd @@ -11,37 +11,6 @@ Formats tabular data in columns or rows using the full range of colours provided by modern terminals. Provides various generics for making every aspect of the display customizable. } -\details{ -See \code{\link[=pillar]{pillar()}} for formatting a single column, -and \code{\link[=print.tbl]{print.tbl()}} for formatting data-frame-like objects. -} -\section{Package options}{ - -\itemize{ -\item \code{pillar.bold}: Use bold font, e.g. for column headers? This currently -defaults to \code{FALSE}, because many terminal fonts have poor support for -bold fonts. -\item \code{pillar.subtle}: Use subtle style, e.g. for row numbers and data types? -Default: \code{TRUE}. -\item \code{pillar.subtle_num}: Use subtle style for insignificant digits? Default: -\code{FALSE}, is also affected by the \code{pillar.subtle} option. -\item \code{pillar.neg}: Highlight negative numbers? Default: \code{TRUE}. -\item \code{pillar.sigfig}: The number of significant digits that will be printed and -highlighted, default: \code{3}. Set the \code{pillar.subtle} option to \code{FALSE} to -turn off highlighting of significant digits. -\item \code{pillar.min_title_chars}: The minimum number of characters for the column -title, default: \code{15}. Column titles may be truncated up to that width to -save horizontal space. Set to \code{Inf} to turn off truncation of column -titles. -\item \code{pillar.min_chars}: The minimum number of characters wide to -display character columns, default: \code{0}. Character columns may be -truncated up to that width to save horizontal space. Set to \code{Inf} to -turn off truncation of character columns. -\item \code{pillar.max_dec_width}: The maximum allowed width for decimal notation, -default 13. -} -} - \examples{ pillar(1:3) pillar(c(1, 2, 3)) @@ -49,13 +18,11 @@ pillar(factor(letters[1:3]), title = "letters") colonnade(iris[1:3, ]) } \seealso{ -Useful links: \itemize{ - \item \url{https://pillar.r-lib.org/} - \item \url{https://github.com/r-lib/pillar} - \item Report bugs at \url{https://github.com/r-lib/pillar/issues} +\item \code{\link[=pillar]{pillar()}} for formatting a single column, +\item \code{\link[=print.tbl]{print.tbl()}} for formatting data-frame-like objects, +\item \link{pillar_options} for a list of package options. } - } \author{ \strong{Maintainer}: Kirill Müller \email{krlmlr+r@mailbox.org} diff --git a/man/pillar_options.Rd b/man/pillar_options.Rd new file mode 100644 index 000000000..c601a9dfc --- /dev/null +++ b/man/pillar_options.Rd @@ -0,0 +1,98 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/options.R +\docType{data} +\name{pillar_options} +\alias{pillar_options} +\title{Package options} +\usage{ +pillar_options +} +\description{ +Options that affect display of tibble-like output. +} +\details{ +These options can be set via \code{\link[=options]{options()}} and queried via \code{\link[=getOption]{getOption()}}. +For this, add a \code{pillar.} prefix (the package name and a dot) to the option name. +Example: for an option \code{foo}, use \code{options(pillar.foo = value)} to set it +and \code{getOption("pillar.foo")} to retrieve the current value. +An option value of \code{NULL} means that the default is used. +} +\section{Options for the pillar package}{ + +\itemize{ +\item \code{print_max}: Maximum number of rows printed, default: \code{20}. +Set to \code{Inf} to always print all rows. +For compatibility reasons, \code{getOption("tibble.print_max")} and +\code{getOption("dplyr.print_max")} are also consulted, +this will be soft-deprecated in pillar v2.0.0. +\item \code{print_min}: Number of rows printed if the table has more than +\code{print_max} rows, default: \code{10}. +For compatibility reasons, \code{getOption("tibble.print_min")} and +\code{getOption("dplyr.print_min")} are also consulted, +this will be soft-deprecated in pillar v2.0.0. +\item \code{width}: Output width. Default: \code{NULL} +(use \code{getOption("width")}). +This can be larger than \code{getOption("width")}, in this case the output +of the table's body is distributed over multiple tiers for wide tibbles. +For compatibility reasons, \code{getOption("tibble.width")} and +\code{getOption("dplyr.width")} are also consulted, +this will be soft-deprecated in pillar v2.0.0. +\item \code{max_footer_lines}: The maximum number of lines in the footer, +default: \code{7}. Set to \code{Inf} to turn off truncation of footer lines. +The \code{max_extra_cols} option still limits +the number of columns printed. +\item \code{max_extra_cols}: The maximum number of columns printed in the footer, +default: \code{100}. Set to \code{Inf} to show all columns. +Set the more predictable \code{max_footer_lines} to control the number +of footer lines instead. +\item \code{bold}: Use bold font, e.g. for column headers? This currently +defaults to \code{FALSE}, because many terminal fonts have poor support for +bold fonts. +\item \code{subtle}: Use subtle style, e.g. for row numbers and data types? +Default: \code{TRUE}. +\item \code{subtle_num}: Use subtle style for insignificant digits? Default: +\code{FALSE}, is also affected by the \code{subtle} option. +\item \code{neg}: Highlight negative numbers? Default: \code{TRUE}. +\item \code{sigfig}: The number of significant digits that will be printed and +highlighted, default: \code{3}. Set the \code{subtle} option to \code{FALSE} to +turn off highlighting of significant digits. +\item \code{min_title_chars}: The minimum number of characters for the column +title, default: \code{15}. Column titles may be truncated up to that width to +save horizontal space. Set to \code{Inf} to turn off truncation of column +titles. +\item \code{min_chars}: The minimum number of characters wide to +display character columns, default: \code{3}. Character columns may be +truncated up to that width to save horizontal space. Set to \code{Inf} to +turn off truncation of character columns. +\item \code{max_dec_width}: The maximum allowed width for decimal notation, +default: \code{13}. +\item \code{bidi}: Set to \code{TRUE} for experimental support for bidirectional scripts. +Default: \code{FALSE}. When this option is set, "left right override" +and "first strong isolate" +\href{https://www.w3.org/International/questions/qa-bidi-unicode-controls}{Unicode controls} +are inserted to ensure that text appears in its intended direction +and that the column headings correspond to the correct columns. +} +} + +\examples{ +# Default setting: +getOption("pillar.sigfig") +pillar(1.234567) + +# Change for the duration of the session: +old <- options(pillar.sigfig = 6) +pillar(1.234567) + +# Change back to the original value: +options(old) +pillar(1.234567) + +# Local scope: +local({ + rlang::local_options(pillar.sigfig = 6) + pillar(1.234567) +}) +pillar(1.234567) +} +\keyword{datasets} diff --git a/man/squeeze.Rd b/man/squeeze.Rd index e0807547c..eddcf715c 100644 --- a/man/squeeze.Rd +++ b/man/squeeze.Rd @@ -12,9 +12,4 @@ It returns an object suitable for printing and formatting at a fixed width with additional information about omitted columns, which can be retrieved via \code{\link[=extra_cols]{extra_cols()}}. } -\examples{ -long_string <- list(paste(letters, collapse = " ")) -squeeze(colonnade(long_string), width = 40) -squeeze(colonnade(long_string), width = 20) -} \keyword{internal} diff --git a/man/style_subtle.Rd b/man/style_subtle.Rd index c1117c358..dc23f22be 100644 --- a/man/style_subtle.Rd +++ b/man/style_subtle.Rd @@ -32,14 +32,16 @@ Functions that allow implementers of formatters for custom data types to maintain a consistent style with the default data types. } \details{ -\code{style_subtle()} is affected by the \code{pillar.subtle} option. +\code{style_subtle()} is affected by the \code{subtle} \link[=pillar_options]{option}. -\code{style_subtle_num()} is affected by the \code{pillar.subtle_num} option, which is -\code{FALSE} by default. +\code{style_subtle_num()} is affected by the +\code{subtle_num} \link[=pillar_options]{option}, +which is \code{FALSE} by default. -\code{style_bold()} is affected by the \code{pillar.bold} option. +\code{style_bold()} is affected by the \code{bold} \link[=pillar_options]{option}, +which is \code{FALSE} by default. -\code{style_neg()} is affected by the \code{pillar.neg} option. +\code{style_neg()} is affected by the \code{pillar.neg} \link[=pillar_options]{option}. } \examples{ style_num( @@ -58,5 +60,5 @@ style_na("NA") style_neg("123") } \seealso{ -\link{pillar-package} for a list of options +\link{pillar_options} for a list of options } diff --git a/man/tbl_format_setup.Rd b/man/tbl_format_setup.Rd index 049a5a6f3..f60dd8e66 100644 --- a/man/tbl_format_setup.Rd +++ b/man/tbl_format_setup.Rd @@ -5,9 +5,16 @@ \alias{tbl_format_setup.tbl} \title{Set up formatting} \usage{ -tbl_format_setup(x, width = NULL, ..., n = NULL, max_extra_cols = NULL) +tbl_format_setup( + x, + width = NULL, + ..., + n = NULL, + max_extra_cols = NULL, + max_footer_lines = NULL +) -\method{tbl_format_setup}{tbl}(x, width, ..., n, max_extra_cols) +\method{tbl_format_setup}{tbl}(x, width, ..., n, max_extra_cols, max_footer_lines) } \arguments{ \item{x}{An object.} @@ -18,11 +25,17 @@ This argument is mandatory for all implementations of this method.} \item{...}{Extra arguments to \code{\link[=print.tbl]{print.tbl()}} or \code{\link[=format.tbl]{format.tbl()}}.} \item{n}{Actual number of rows to print. -No \link{option}s should be considered by implementations of this method.} +No \link[=pillar_options]{options} should be considered +by implementations of this method.} \item{max_extra_cols}{Number of columns to print abbreviated information for, if the width is too small for the entire tibble. -No \link{option}s should be considered by implementations of this method.} +No \link[=pillar_options]{options} should be considered +by implementations of this method.} + +\item{max_footer_lines}{Maximum number of lines for the footer. +No \link[=pillar_options]{options} should be considered +by implementations of this method.} } \value{ An object that can be passed as \code{setup} argument to diff --git a/man/type_sum.Rd b/man/type_sum.Rd index d629948ff..21c5cea98 100644 --- a/man/type_sum.Rd +++ b/man/type_sum.Rd @@ -23,9 +23,12 @@ and variants have been implemented.} occur in a data frame should return a string with four or less characters. For most inputs, the argument is forwarded to \code{\link[vctrs:vec_ptype_full]{vctrs::vec_ptype_abbr()}}. -\code{obj_sum()} also includes the size of the object if \code{\link[vctrs:vec_assert]{vctrs::vec_is()}} -is \code{TRUE}. +\code{obj_sum()} also includes the size (but not the shape) of the object +if \code{\link[vctrs:vec_assert]{vctrs::vec_is()}} is \code{TRUE}. It should always return a string (a character vector of length one). +As of pillar v1.6.1, the default method forwards to \code{\link[vctrs:vec_ptype_full]{vctrs::vec_ptype_abbr()}} +for vectors and to \code{\link[=type_sum]{type_sum()}} for other objects. +Previous versions always forwarded to \code{\link[=type_sum]{type_sum()}}. \code{size_sum()} is called by \code{obj_sum()} to format the size of the object. It should always return a string (a character vector of length one), diff --git a/tests/testthat/_snaps/ctl_colonnade.md b/tests/testthat/_snaps/ctl_colonnade.md index 2a70e5337..fcd34f973 100644 --- a/tests/testthat/_snaps/ctl_colonnade.md +++ b/tests/testthat/_snaps/ctl_colonnade.md @@ -807,3 +807,21 @@ named list() +# filling unused width (#331) + + Code + data + Output + # A data frame: 1 x 3 + month sentences blah + + 1 January a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I~ + Code + options(width = 60) + print(data) + Output + # A data frame: 1 x 3 + month sentences blah + + 1 January a b c d~ A B C D E F G H I J K L M N O P Q R S T~ + diff --git a/tests/testthat/_snaps/ctl_colonnade_1.md b/tests/testthat/_snaps/ctl_colonnade_1.md index f55fa8bcb..4710c9b04 100644 --- a/tests/testthat/_snaps/ctl_colonnade_1.md +++ b/tests/testthat/_snaps/ctl_colonnade_1.md @@ -1,11 +1,13 @@ # strings with varying widths Code - options(width = 59) ctl_colonnade(df_str[c(12L, 33L, 36L, 7L, 41L, 3L, 18L, 23L, 13L, 44L, 14L, 16L, 25L, 21L, 19L, 45L, 43L, 29L, 1L, 30L, 22L, 27L, 15L, 47L, 28L, 31L, 10L, 50L, 4L, 40L, 42L, 8L, 6L, 9L, 24L, 48L, 38L, 37L, 34L, 49L, 46L, 2L, 32L, 35L, - 39L, 11L, 17L, 5L, 26L, 20L)], width = 1382) + 39L, 11L, 17L, 5L, 26L, 20L)], width = { + options(width = 59) + 1382 + }) Output $body `12` `33` @@ -74,22 +76,24 @@ `37` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefg - `34` `49` `46` `2` `32` `35` `39` `11` `17` - - 1 Abcde~ Abcde~ Abcde~ Ab Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `5` `26` `20` - - 1 Abcde AbcdefghijAbcdefghijAbcdef AbcdefghijAbcdefghij + `34` `49` `46` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcd Abcdefghij~ Abcdefghi~ + `2` `32` `35` `39` `11` `17` `5` `26` `20` + + 1 Ab Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde Abcd~ Abcd~ $extra_cols named list() Code - options(width = 54) ctl_colonnade(df_str[c(40L, 28L, 7L, 16L, 48L, 6L, 21L, 1L, 20L, 17L, 47L, 45L, 29L, 41L, 49L, 34L, 4L, 39L, 18L, 36L, 26L, 38L, 10L, 8L, 5L, 15L, 44L, 24L, 46L, 14L, 25L, 27L, 3L, 37L, 35L, 12L, 9L, 13L, 22L, 33L, 42L, 11L, 19L, 50L, - 23L, 30L, 32L, 2L, 43L, 31L)], width = 837) + 23L, 30L, 32L, 2L, 43L, 31L)], width = { + options(width = 54) + 837 + }) Output $body `40` @@ -125,31 +129,33 @@ `49` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghi - `34` `4` `39` `18` `36` `26` `38` `10` - - 1 Abcde~ Abcd Abcdef~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `8` `5` `15` `44` `24` `46` `14` `25` - - 1 Abcde~ Abcde Abcde~ Abcdef~ Abcd~ Abcde~ Abcd~ Abcd~ - `27` `3` `37` `35` `12` `9` `13` `22` - - 1 Abcde~ Abc Abcdef~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ - `33` `42` `11` `19` `50` `23` `30` `32` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `2` `43` `31` - - 1 Ab AbcdefghijAbcdefghijAbcde~ AbcdefghijAbcdefgh~ + `34` `4` `39` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcd Abcd Abcdefghij~ + `18` `36` `26` `38` `10` `8` `5` `15` + + 1 Abcde~ Abcdef~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde Abcd~ + `44` `24` `46` `14` `25` `27` `3` `37` + + 1 Abcdef~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abc Abcd~ + `35` `12` `9` `13` `22` `33` `42` `11` + + 1 Abcdef~ Abcde~ Abcd~ Abcd~ Abcd~ Abcde~ Abcde~ Abcd~ + `19` `50` `23` `30` `32` `2` `43` `31` + + 1 Abcde~ Abcdef~ Abcde~ Abcde~ Abcd~ Ab Abcd~ Abcd~ $extra_cols named list() Code - options(width = 32) ctl_colonnade(df_str[c(47L, 42L, 4L, 46L, 9L, 34L, 19L, 39L, 8L, 32L, 36L, 12L, 29L, 5L, 15L, 11L, 31L, 27L, 33L, 28L, 43L, 6L, 13L, 22L, 14L, 16L, 35L, 50L, 38L, 7L, 23L, 45L, 40L, 3L, 2L, 24L, 41L, 10L, 30L, 25L, 17L, 26L, 48L, 37L, - 49L, 1L, 18L, 21L, 44L, 20L)], width = 455) + 49L, 1L, 18L, 21L, 44L, 20L)], width = { + options(width = 32) + 455 + }) Output $body `47` @@ -170,43 +176,45 @@ `34` 1 AbcdefghijAbcdefghijAbcdefghi~ - `19` `39` `8` `32` `36` + `19` `39` `8` `32` + + 1 Abcdef~ Abcdefg~ Abcd~ Abcdef~ + `36` `12` `29` `5` `15` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `29` `5` `15` `11` - - 1 Abcde~ Abcd~ Abcde Abcd~ Abcd~ - `31` `27` `33` `28` `43` + 1 Abcde~ Abcd~ Abcd~ Abcde Abcd~ + `11` `31` `27` `33` `28` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `6` `13` `22` `14` `16` + `43` `6` `13` `22` `14` - 1 Abcdef Abcd~ Abcd~ Abcd~ Abcd~ - `35` `50` `38` `7` `23` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `16` `35` `50` `38` `7` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `45` `40` `3` `2` `24` + `23` `45` `40` `3` `2` - 1 Abcde~ Abcd~ Abc Ab Abcd~ - `41` `10` `30` `25` `17` + 1 Abcde~ Abcd~ Abcd~ Abc Ab + `24` `41` `10` `30` `25` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `26` `48` `37` `49` `1` + `17` `26` `48` `37` `49` - 1 Abcde~ Abcd~ Abcd~ Abcd~ A - `18` `21` `44` `20` - - 1 Abcdef~ Abcdef~ Abcdef~ Abcde~ + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `1` `18` `21` `44` `20` + + 1 A Abcde~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 55) ctl_colonnade(df_str[c(41L, 4L, 25L, 31L, 8L, 22L, 19L, 10L, 29L, 21L, 34L, 5L, 26L, 36L, 47L, 46L, 2L, 24L, 27L, 39L, 28L, 43L, 32L, 30L, 48L, 44L, 6L, 20L, 13L, 15L, 18L, 42L, 9L, 12L, 37L, 45L, 16L, 40L, 11L, 14L, 38L, 1L, 7L, 3L, - 23L, 35L, 50L, 17L, 49L, 33L)], width = 855) + 23L, 35L, 50L, 17L, 49L, 33L)], width = { + options(width = 55) + 855 + }) Output $body `41` `4` @@ -245,28 +253,30 @@ `39` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghi - `28` `43` `32` `30` `48` `44` `6` `20` `13` + `28` `43` `32` + + 1 AbcdefghijAbcdefghijAbcdefgh AbcdefghijAb~ Abcdefghi~ + `30` `48` `44` `6` `20` `13` `15` `18` `42` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `15` `18` `42` `9` `12` `37` `45` `16` `40` + `9` `12` `37` `45` `16` `40` `11` `14` `38` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `11` `14` `38` `1` `7` `3` `23` `35` `50` + `1` `7` `3` `23` `35` `50` `17` `49` `33` - 1 Abcd~ Abcd~ Abcd~ A Abcd~ Abc Abcd~ Abcd~ Abcd~ - `17` `49` `33` - - 1 Abcdefghij~ AbcdefghijAbcdefghijAb~ AbcdefghijAbcdef~ + 1 A Abcd~ Abc Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 54) ctl_colonnade(df_str[c(27L, 22L, 9L, 23L, 16L, 19L, 25L, 31L, 44L, 1L, 28L, 46L, 12L, 20L, 43L, 37L, 5L, 2L, 18L, 41L, 26L, 33L, 11L, 49L, 24L, 35L, 4L, 47L, 30L, 7L, 34L, 3L, 32L, 42L, 10L, 45L, 38L, 39L, 48L, 14L, 6L, 17L, 36L, 50L, - 40L, 13L, 8L, 21L, 15L, 29L)], width = 552) + 40L, 13L, 8L, 21L, 15L, 29L)], width = { + options(width = 54) + 552 + }) Output $body `27` `22` @@ -287,31 +297,33 @@ `28` 1 AbcdefghijAbcdefghijAbcdefgh - `46` `12` `20` `43` `37` `5` `2` `18` - - 1 Abcdef~ Abcde~ Abcd~ Abcde~ Abcde~ Abcde Ab Abcd~ - `41` `26` `33` `11` `49` `24` `35` `4` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd - `47` `30` `7` `34` `3` `32` `42` `10` - - 1 Abcdef~ Abcde~ Abcde~ Abcd~ Abc Abcd~ Abcde~ Abcd~ - `45` `38` `39` `48` `14` `6` `17` `36` - - 1 Abcde~ Abcde~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ - `50` `40` `13` `8` `21` `15` `29` - - 1 Abcdefgh~ Abcdefg~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ + `46` `12` `20` `43` `37` `5` `2` + + 1 Abcdefgh~ Abcde~ Abcde~ Abcdefg~ Abcdef~ Abcde Ab + `18` `41` `26` `33` `11` `49` `24` `35` + + 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ + `4` `47` `30` `7` `34` `3` `32` `42` + + 1 Abcd Abcdef~ Abcde~ Abcde~ Abcd~ Abc Abcd~ Abcde~ + `10` `45` `38` `39` `48` `14` `6` `17` + + 1 Abcde~ Abcdef~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ Abcd~ + `36` `50` `40` `13` `8` `21` `15` `29` + + 1 Abcde~ Abcdef~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 49) ctl_colonnade(df_str[c(32L, 24L, 18L, 25L, 26L, 13L, 33L, 2L, 50L, 38L, 37L, 16L, 27L, 9L, 28L, 49L, 34L, 15L, 17L, 35L, 22L, 47L, 3L, 21L, 23L, 41L, 5L, 1L, 14L, 46L, 30L, 31L, 44L, 4L, 7L, 40L, 43L, 12L, 29L, 8L, 36L, 45L, 11L, - 20L, 10L, 6L, 19L, 48L, 39L, 42L)], width = 1031) + 20L, 10L, 6L, 19L, 48L, 39L, 42L)], width = { + options(width = 49) + 1031 + }) Output $body `32` @@ -368,28 +380,30 @@ `23` 1 AbcdefghijAbcdefghijAbc - `41` `5` `1` `14` `46` `30` `31` `44` + `41` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijA + `5` `1` `14` `46` `30` `31` `44` `4` - 1 Abcd~ Abcde A Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `4` `7` `40` `43` `12` `29` `8` `36` + 1 Abcde A Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd + `7` `40` `43` `12` `29` `8` `36` `45` - 1 Abcd Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `45` `11` `20` `10` `6` `19` `48` `39` + 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `11` `20` `10` `6` `19` `48` `39` `42` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `42` - - 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb $extra_cols named list() Code - options(width = 38) ctl_colonnade(df_str[c(44L, 34L, 49L, 9L, 15L, 16L, 1L, 10L, 40L, 29L, 26L, 22L, 4L, 43L, 20L, 17L, 46L, 33L, 35L, 32L, 2L, 12L, 8L, 37L, 23L, 39L, 7L, 18L, 36L, 42L, 6L, 30L, 19L, 25L, 5L, 21L, 47L, 50L, 28L, 11L, 31L, 14L, 24L, 27L, - 45L, 41L, 38L, 3L, 13L, 48L)], width = 429) + 45L, 41L, 38L, 3L, 13L, 48L)], width = { + options(width = 38) + 429 + }) Output $body `44` @@ -404,40 +418,42 @@ `9` `15` 1 Abcdefghi AbcdefghijAbcde - `16` `1` `10` `40` `29` `26` + `16` `1` `10` + + 1 AbcdefghijAbcdef A Abcdefghij + `40` `29` `26` `22` `4` `43` - 1 Abcde~ A Abcd~ Abcd~ Abcd~ Abcd~ - `22` `4` `43` `20` `17` `46` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd Abcd~ + `20` `17` `46` `33` `35` `32` - 1 Abcde~ Abcd Abcd~ Abcd~ Abcd~ Abcd~ - `33` `35` `32` `2` `12` `8` - - 1 Abcde~ Abcd~ Abcd~ Ab Abcd~ Abcd~ - `37` `23` `39` `7` `18` `36` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `2` `12` `8` `37` `23` `39` + + 1 Ab Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `7` `18` `36` `42` `6` `30` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `42` `6` `30` `19` `25` `5` + `19` `25` `5` `21` `47` `50` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcde - `21` `47` `50` `28` `11` `31` + 1 Abcde~ Abcd~ Abcde Abcd~ Abcd~ Abcd~ + `28` `11` `31` `14` `24` `27` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `14` `24` `27` `45` `41` `38` + `45` `41` `38` `3` `13` `48` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `3` `13` `48` - - 1 Abc Abcdefgh~ AbcdefghijAbcdefghi~ + 1 Abcde~ Abcd~ Abcd~ Abc Abcd~ Abcd~ $extra_cols named list() Code - options(width = 54) ctl_colonnade(df_str[c(21L, 26L, 8L, 22L, 41L, 24L, 13L, 5L, 47L, 37L, 4L, 42L, 19L, 34L, 11L, 43L, 38L, 3L, 33L, 20L, 31L, 2L, 18L, 48L, 27L, 44L, 9L, 35L, 30L, 6L, 49L, 10L, 1L, 16L, 46L, 29L, 12L, 14L, 45L, 36L, 15L, 39L, 50L, 23L, - 17L, 28L, 7L, 32L, 40L, 25L)], width = 633) + 17L, 28L, 7L, 32L, 40L, 25L)], width = { + options(width = 54) + 633 + }) Output $body `21` `26` @@ -461,31 +477,33 @@ `42` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb - `19` `34` `11` `43` `38` `3` `33` `20` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abc Abcd~ Abcd~ - `31` `2` `18` `48` `27` `44` `9` `35` - - 1 Abcde~ Ab Abcde~ Abcdef~ Abcd~ Abcde~ Abcd~ Abcd~ - `30` `6` `49` `10` `1` `16` `46` `29` - - 1 Abcde~ Abcdef Abcdef~ Abcd~ A Abcd~ Abcde~ Abcd~ - `12` `14` `45` `36` `15` `39` `50` `23` - - 1 Abcde~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcde~ Abcd~ - `17` `28` `7` `32` `40` `25` - - 1 Abcdef~ Abcdefgh~ Abcde~ Abcdefg~ Abcdefghi~ Abcdef~ + `19` `34` `11` `43` `38` `3` + + 1 AbcdefghijAbcdefghi Abcde~ Abcde~ Abcde~ Abcd~ Abc + `33` `20` `31` `2` `18` `48` `27` `44` + + 1 Abcde~ Abcde~ Abcde~ Ab Abcd~ Abcde~ Abcd~ Abcde~ + `9` `35` `30` `6` `49` `10` `1` `16` + + 1 Abcde~ Abcdef~ Abcde~ Abcd~ Abcde~ Abcd~ A Abcd~ + `46` `29` `12` `14` `45` `36` `15` `39` + + 1 Abcdef~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ Abcd~ + `50` `23` `17` `28` `7` `32` `40` `25` + + 1 Abcdef~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 39) ctl_colonnade(df_str[c(23L, 49L, 13L, 37L, 3L, 25L, 36L, 4L, 9L, 7L, 27L, 48L, 12L, 10L, 50L, 14L, 38L, 39L, 46L, 22L, 28L, 8L, 21L, 44L, 32L, 40L, 31L, 1L, 29L, 34L, 35L, 33L, 19L, 15L, 41L, 20L, 47L, 18L, 16L, 45L, 6L, 5L, 24L, 26L, - 43L, 11L, 42L, 30L, 17L, 2L)], width = 1496) + 43L, 11L, 42L, 30L, 17L, 2L)], width = { + options(width = 39) + 1496 + }) Output $body `23` @@ -610,11 +628,13 @@ named list() Code - options(width = 31) ctl_colonnade(df_str[c(45L, 14L, 49L, 24L, 22L, 31L, 42L, 18L, 16L, 47L, 25L, 4L, 37L, 8L, 26L, 21L, 50L, 5L, 41L, 30L, 2L, 33L, 34L, 3L, 44L, 19L, 43L, 6L, 32L, 29L, 20L, 1L, 13L, 11L, 40L, 12L, 48L, 23L, 9L, 15L, 46L, 36L, 27L, 35L, - 28L, 10L, 7L, 39L, 17L, 38L)], width = 493) + 28L, 10L, 7L, 39L, 17L, 38L)], width = { + options(width = 31) + 493 + }) Output $body `45` @@ -638,43 +658,45 @@ `42` 1 AbcdefghijAbcdefghijAbcdefgh~ - `18` `16` `47` `25` `4` + `18` `16` `47` + + 1 Abcdefgh~ Abcdef~ Abcdefghij~ + `25` `4` `37` `8` `26` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd - `37` `8` `26` `21` `50` + 1 Abcd~ Abcd Abcd~ Abcd~ Abcd~ + `21` `50` `5` `41` `30` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `5` `41` `30` `2` `33` + 1 Abcd~ Abcd~ Abcde Abcd~ Abcd~ + `2` `33` `34` `3` `44` - 1 Abcde Abcd~ Abcd~ Ab Abcd~ - `34` `3` `44` `19` `43` + 1 Ab Abcd~ Abcd~ Abc Abcd~ + `19` `43` `6` `32` `29` - 1 Abcd~ Abc Abcd~ Abcd~ Abcd~ - `6` `32` `29` `20` `1` + 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `20` `1` `13` `11` `40` - 1 Abcd~ Abcd~ Abcd~ Abcd~ A - `13` `11` `40` `12` `48` + 1 Abcd~ A Abcd~ Abcd~ Abcd~ + `12` `48` `23` `9` `15` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `23` `9` `15` `46` `36` + `46` `36` `27` `35` `28` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `27` `35` `28` `10` `7` + `10` `7` `39` `17` `38` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `39` `17` `38` - - 1 Abcdefghi~ Abcdefg~ Abcdefgh~ $extra_cols named list() Code - options(width = 52) ctl_colonnade(df_str[c(38L, 46L, 17L, 11L, 24L, 18L, 16L, 39L, 50L, 42L, 6L, 13L, 37L, 29L, 41L, 47L, 9L, 33L, 44L, 31L, 45L, 36L, 28L, 5L, 10L, 30L, 20L, 1L, 14L, 43L, 49L, 23L, 26L, 21L, 32L, 19L, 34L, 15L, 48L, 4L, 7L, 35L, 40L, - 8L, 22L, 3L, 25L, 12L, 27L, 2L)], width = 1130) + 8L, 22L, 3L, 25L, 12L, 27L, 2L)], width = { + options(width = 52) + 1130 + }) Output $body `38` @@ -731,28 +753,30 @@ `36` 1 AbcdefghijAbcdefghijAbcdefghijAbcdef - `28` `5` `10` `30` `20` `1` `14` `43` + `28` `5` `10` `30` + + 1 AbcdefghijAbcdefghijAbcdefgh Abcde Abcde~ Abcdefg~ + `20` `1` `14` `43` `49` `23` `26` `21` - 1 Abcde~ Abcde Abcde~ Abcde~ Abcd~ A Abcd~ Abcd~ - `49` `23` `26` `21` `32` `19` `34` `15` + 1 Abcde~ A Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `32` `19` `34` `15` `48` `4` `7` `35` - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `48` `4` `7` `35` `40` `8` `22` `3` - - 1 Abcde~ Abcd Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abc - `25` `12` `27` `2` - - 1 AbcdefghijAbcdef~ Abcdefg~ AbcdefghijAbcdef~ Ab + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd Abcd~ Abcd~ + `40` `8` `22` `3` `25` `12` `27` `2` + + 1 Abcdef~ Abcde~ Abcd~ Abc Abcd~ Abcd~ Abcd~ Ab $extra_cols named list() Code - options(width = 58) ctl_colonnade(df_str[c(17L, 28L, 29L, 27L, 20L, 31L, 43L, 30L, 32L, 48L, 10L, 50L, 13L, 12L, 36L, 21L, 46L, 33L, 25L, 35L, 1L, 5L, 16L, 34L, 18L, 42L, 3L, 11L, 40L, 26L, 37L, 7L, 39L, 6L, 4L, 19L, 8L, 45L, 14L, 24L, 23L, 2L, 47L, 9L, - 49L, 41L, 38L, 22L, 44L, 15L)], width = 1310) + 49L, 41L, 38L, 22L, 44L, 15L)], width = { + options(width = 58) + 1310 + }) Output $body `17` `28` @@ -815,25 +839,27 @@ `42` `3` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb Abc - `11` `40` `26` `37` `7` `39` `6` `4` `19` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd Abcd~ - `8` `45` `14` `24` `23` `2` `47` `9` `49` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Ab Abcd~ Abcd~ Abcd~ - `41` `38` `22` `44` `15` - - 1 AbcdefghijAb~ AbcdefghijA~ Abcdefg~ AbcdefghijA~ Abcdef~ + `11` `40` `26` `37` `7` + + 1 AbcdefghijA AbcdefghijAbc~ Abcdefghi~ AbcdefghijA~ Abcd~ + `39` `6` `4` `19` `8` `45` `14` `24` `23` + + 1 Abcde~ Abcdef Abcd Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `2` `47` `9` `49` `41` `38` `22` `44` `15` + + 1 Ab Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 47) ctl_colonnade(df_str[c(1L, 26L, 20L, 12L, 49L, 16L, 24L, 4L, 15L, 47L, 8L, 11L, 14L, 50L, 17L, 2L, 44L, 30L, 36L, 45L, 25L, 38L, 18L, 29L, 5L, 13L, 3L, 23L, 48L, 40L, 34L, 22L, 39L, 33L, 27L, 7L, 19L, 10L, 37L, 6L, 35L, 46L, 31L, 41L, - 43L, 28L, 42L, 32L, 21L, 9L)], width = 484) + 43L, 28L, 42L, 32L, 21L, 9L)], width = { + options(width = 47) + 484 + }) Output $body `1` `26` @@ -848,37 +874,39 @@ `16` `24` 1 AbcdefghijAbcdef AbcdefghijAbcdefghijAbcd - `4` `15` `47` `8` `11` `14` `50` - - 1 Abcd Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcde~ - `17` `2` `44` `30` `36` `45` `25` - - 1 Abcde~ Ab Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ - `38` `18` `29` `5` `13` `3` `23` - - 1 Abcdef~ Abcde~ Abcde~ Abcde Abcd~ Abc Abcd~ - `48` `40` `34` `22` `39` `33` `27` + `4` + + 1 Abcd + `15` `47` `8` `11` `14` `50` `17` + + 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcde~ Abcd~ + `2` `44` `30` `36` `45` `25` `38` + + 1 Ab Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ + `18` `29` `5` `13` `3` `23` `48` + + 1 Abcde~ Abcde~ Abcde Abcde~ Abc Abcd~ Abcde~ + `40` `34` `22` `39` `33` `27` `7` 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `7` `19` `10` `37` `6` `35` `46` - - 1 Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ Abcde~ - `31` `41` `43` `28` `42` `32` `21` + `19` `10` `37` `6` `35` `46` `31` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde~ Abcd~ + `41` `43` `28` `42` `32` `21` `9` 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `9` - - 1 Abcdefghi $extra_cols named list() Code - options(width = 55) ctl_colonnade(df_str[c(6L, 49L, 26L, 45L, 25L, 15L, 31L, 20L, 21L, 44L, 23L, 48L, 37L, 36L, 5L, 43L, 11L, 14L, 13L, 39L, 16L, 12L, 4L, 18L, 42L, 3L, 10L, 28L, 40L, 24L, 29L, 17L, 35L, 47L, 2L, 38L, 34L, 9L, 7L, 8L, 50L, 33L, 32L, - 27L, 46L, 19L, 22L, 41L, 30L, 1L)], width = 779) + 27L, 46L, 19L, 22L, 41L, 30L, 1L)], width = { + options(width = 55) + 779 + }) Output $body `6` @@ -911,31 +939,33 @@ `48` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefgh - `37` `36` `5` `43` `11` `14` `13` `39` `16` + `37` `36` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcdefg AbcdefghijAbcd~ + `5` `43` `11` `14` `13` `39` `16` `12` `4` - 1 Abcd~ Abcd~ Abcde Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `4` `18` `42` `3` `10` `28` `40` `24` + 1 Abcde Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd + `18` `42` `3` `10` `28` `40` `24` `29` `17` - 1 Abcd~ Abcd Abcd~ Abcd~ Abc Abcd~ Abcd~ Abcd~ Abcd~ - `29` `17` `35` `47` `2` `38` `34` `9` `7` + 1 Abcd~ Abcd~ Abc Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `35` `47` `2` `38` `34` `9` `7` `8` `50` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Ab Abcd~ Abcd~ Abcd~ Abcd~ - `8` `50` `33` `32` `27` `46` `19` `22` `41` + 1 Abcd~ Abcd~ Ab Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `33` `32` `27` `46` `19` `22` `41` `30` `1` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `30` `1` - - 1 AbcdefghijAbcdefghijAbcdefghij A + 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ A $extra_cols named list() Code - options(width = 46) ctl_colonnade(df_str[c(38L, 42L, 41L, 10L, 40L, 11L, 27L, 9L, 17L, 37L, 46L, 13L, 36L, 18L, 31L, 20L, 39L, 12L, 44L, 33L, 50L, 34L, 26L, 32L, 23L, 30L, 29L, 21L, 4L, 49L, 19L, 25L, 3L, 6L, 15L, 14L, 43L, 48L, 8L, 22L, 1L, 2L, 45L, - 35L, 16L, 5L, 47L, 28L, 24L, 7L)], width = 694) + 35L, 16L, 5L, 47L, 28L, 24L, 7L)], width = { + options(width = 46) + 694 + }) Output $body `38` @@ -968,24 +998,24 @@ `13` 1 AbcdefghijAbc - `36` `18` `31` `20` `39` `12` `44` + `36` `18` `31` + + 1 AbcdefghijAbcdef~ Abcdefghi~ AbcdefghijAbcd~ + `20` `39` `12` `44` `33` `50` `34` 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `33` `50` `34` `26` `32` `23` `30` + `26` `32` `23` `30` `29` `21` `4` - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `29` `21` `4` `49` `19` `25` `3` + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd + `49` `19` `25` `3` `6` `15` `14` + + 1 Abcdef~ Abcde~ Abcd~ Abc Abcd~ Abcd~ Abcd~ + `43` `48` `8` `22` `1` `2` `45` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ A Ab Abcd~ + `35` `16` `5` `47` `28` `24` `7` - 1 Abcde~ Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abc - `6` `15` `14` `43` `48` `8` `22` - - 1 Abcdef Abcde~ Abcd~ Abcd~ Abcde~ Abcd~ Abcd~ - `1` `2` `45` `35` `16` `5` `47` - - 1 A Ab Abcde~ Abcde~ Abcde~ Abcde Abcd~ - `28` `24` `7` - - 1 AbcdefghijAbcdefghi~ AbcdefghijAbcde~ Abcde~ + 1 Abcde~ Abcde~ Abcde Abcde~ Abcd~ Abcd~ Abcd~ $extra_cols named list() diff --git a/tests/testthat/_snaps/ctl_colonnade_2.md b/tests/testthat/_snaps/ctl_colonnade_2.md index 720114da3..f0c03a8fa 100644 --- a/tests/testthat/_snaps/ctl_colonnade_2.md +++ b/tests/testthat/_snaps/ctl_colonnade_2.md @@ -1,11 +1,13 @@ # strings with varying widths Code - options(width = 54) ctl_colonnade(df_str[c(28L, 34L, 16L, 29L, 47L, 25L, 42L, 27L, 44L, 20L, 14L, 36L, 43L, 41L, 26L, 45L, 22L, 9L, 13L, 32L, 31L, 12L, 19L, 48L, 49L, 35L, 3L, 11L, 23L, 24L, 40L, 15L, 38L, 10L, 46L, 5L, 50L, 18L, 21L, 6L, 30L, 2L, 7L, - 1L, 4L, 8L, 17L, 33L, 39L, 37L)], width = 516) + 1L, 4L, 8L, 17L, 33L, 39L, 37L)], width = { + options(width = 54) + 516 + }) Output $body `28` @@ -20,34 +22,36 @@ `47` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefg - `25` `42` `27` `44` `20` `14` `36` `43` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `41` `26` `45` `22` `9` `13` `32` `31` - - 1 Abcdef~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `19` `48` `49` `35` `3` `11` `23` - - 1 Abcde~ Abcde~ Abcdef~ Abcde~ Abcd~ Abc Abcd~ Abcd~ - `24` `40` `15` `38` `10` `46` `5` `50` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde~ Abcde Abcde~ - `18` `21` `6` `30` `2` `7` `1` `4` - - 1 Abcdef~ Abcde~ Abcd~ Abcdef~ Ab Abcd~ A Abcd - `8` `17` `33` `39` `37` - - 1 Abcde~ Abcdefg~ Abcdefghij~ AbcdefghijA~ Abcdefghij~ + `25` `42` `27` `44` `20` + + 1 AbcdefghijAbcdefghijAbcde Abcde~ Abcde~ Abcde~ Abcd~ + `14` `36` `43` `41` `26` `45` `22` `9` + + 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ + `13` `32` `31` `12` `19` `48` `49` `35` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde~ Abcde~ Abcd~ + `3` `11` `23` `24` `40` `15` `38` `10` + + 1 Abc Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ + `46` `5` `50` `18` `21` `6` `30` `2` + + 1 Abcdef~ Abcde Abcdef~ Abcde~ Abcd~ Abcd~ Abcd~ Ab + `7` `1` `4` `8` `17` `33` `39` `37` + + 1 Abcde~ A Abcd Abcde~ Abcd~ Abcde~ Abcde~ Abcde~ $extra_cols named list() Code - options(width = 42) ctl_colonnade(df_str[c(28L, 41L, 12L, 29L, 13L, 43L, 24L, 50L, 48L, 35L, 44L, 21L, 33L, 45L, 47L, 34L, 25L, 14L, 18L, 23L, 7L, 3L, 42L, 36L, 11L, 2L, 20L, 31L, 1L, 4L, 38L, 9L, 27L, 40L, 32L, 17L, 6L, 49L, 16L, 19L, 15L, 22L, 39L, - 10L, 46L, 5L, 30L, 8L, 26L, 37L)], width = 1365) + 10L, 46L, 5L, 30L, 8L, 26L, 37L)], width = { + options(width = 42) + 1365 + }) Output $body `28` @@ -143,22 +147,24 @@ `16` `19` 1 AbcdefghijAbcdef AbcdefghijAbcdefghi - `15` `22` `39` `10` `46` `5` - - 1 Abcde~ Abcde~ Abcdef~ Abcd~ Abcde~ Abcde - `30` `8` `26` `37` - - 1 Abcdefghij~ Abcde~ Abcdefgh~ Abcdefghij~ + `15` `22` `39` `10` + + 1 AbcdefghijAbcde Abcdefg~ Abcdefgh~ Abcd~ + `46` `5` `30` `8` `26` `37` + + 1 Abcdef~ Abcde Abcdef~ Abcd~ Abcd~ Abcde~ $extra_cols named list() Code - options(width = 39) ctl_colonnade(df_str[c(40L, 17L, 13L, 23L, 22L, 2L, 18L, 3L, 29L, 45L, 14L, 19L, 33L, 37L, 47L, 43L, 44L, 10L, 31L, 27L, 34L, 35L, 41L, 21L, 4L, 25L, 38L, 48L, 9L, 24L, 26L, 39L, 20L, 36L, 42L, 16L, 6L, 11L, 7L, 12L, 1L, 46L, 15L, 5L, 8L, - 50L, 32L, 30L, 49L, 28L)], width = 934) + 50L, 32L, 30L, 49L, 28L)], width = { + options(width = 39) + 934 + }) Output $body `40` @@ -218,31 +224,33 @@ `41` 1 AbcdefghijAbcdefghijAbcdefghijAbcdef~ - `21` `4` `25` `38` `48` `9` - - 1 Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abcd~ - `24` `26` `39` `20` `36` `42` + `21` `4` `25` + + 1 AbcdefghijAbcdefghijA Abcd Abcdefgh~ + `38` `48` `9` `24` `26` `39` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `16` `6` `11` `7` `12` `1` + `20` `36` `42` `16` `6` `11` - 1 Abcde~ Abcdef Abcd~ Abcd~ Abcd~ A - `46` `15` `5` `8` `50` `32` + 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `7` `12` `1` `46` `15` `5` + + 1 Abcde~ Abcd~ A Abcde~ Abcd~ Abcde + `8` `50` `32` `30` `49` `28` - 1 Abcde~ Abcde~ Abcde Abcd~ Abcd~ Abcd~ - `30` `49` `28` - - 1 AbcdefghijA~ AbcdefghijAb~ Abcdefghi~ + 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 32) ctl_colonnade(df_str[c(11L, 36L, 17L, 14L, 31L, 35L, 23L, 13L, 6L, 44L, 45L, 22L, 21L, 18L, 33L, 10L, 43L, 2L, 46L, 34L, 3L, 19L, 1L, 38L, 9L, 37L, 5L, 8L, 25L, 49L, 27L, 29L, 15L, 39L, 24L, 40L, 48L, 26L, 47L, 42L, 41L, 12L, 28L, - 30L, 7L, 16L, 4L, 50L, 20L, 32L)], width = 565) + 30L, 7L, 16L, 4L, 50L, 20L, 32L)], width = { + options(width = 32) + 565 + }) Output $body `11` @@ -275,40 +283,42 @@ `45` 1 AbcdefghijAbcdefghijAbcdefghi~ - `22` `21` `18` `33` `10` - - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `43` `2` `46` `34` `3` - - 1 Abcde~ Ab Abcd~ Abcd~ Abc - `19` `1` `38` `9` `37` + `22` `21` `18` `33` + + 1 Abcdef~ Abcdef~ Abcde~ Abcdef~ + `10` `43` `2` `46` `34` - 1 Abcde~ A Abcd~ Abcd~ Abcd~ - `5` `8` `25` `49` `27` + 1 Abcde~ Abcd~ Ab Abcd~ Abcd~ + `3` `19` `1` `38` `9` - 1 Abcde Abcde~ Abcd~ Abcd~ Abcd~ - `29` `15` `39` `24` `40` + 1 Abc Abcde~ A Abcd~ Abcd~ + `37` `5` `8` `25` `49` + + 1 Abcde~ Abcde Abcd~ Abcd~ Abcd~ + `27` `29` `15` `39` `24` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `48` `26` `47` `42` `41` + `40` `48` `26` `47` `42` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `28` `30` `7` `16` + `41` `12` `28` `30` `7` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `4` `50` `20` `32` - - 1 Abcd Abcdefg~ Abcdef~ Abcdef~ + `16` `4` `50` `20` `32` + + 1 Abcde~ Abcd Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 35) ctl_colonnade(df_str[c(18L, 46L, 11L, 43L, 31L, 47L, 48L, 44L, 50L, 15L, 28L, 33L, 13L, 4L, 22L, 3L, 37L, 32L, 40L, 9L, 25L, 16L, 45L, 23L, 21L, 6L, 49L, 36L, 27L, 38L, 14L, 34L, 8L, 24L, 29L, 1L, 12L, 2L, 20L, 17L, 35L, 5L, 19L, - 30L, 7L, 26L, 42L, 41L, 39L, 10L)], width = 1121) + 30L, 7L, 26L, 42L, 41L, 39L, 10L)], width = { + options(width = 35) + 1121 + }) Output $body `18` @@ -398,28 +408,30 @@ `34` 1 AbcdefghijAbcdefghijAbcdefghijAb~ - `8` `24` `29` `1` `12` - - 1 Abcde~ Abcdef~ Abcde~ A Abcd~ - `2` `20` `17` `35` `5` - - 1 Ab Abcdef~ Abcd~ Abcdef~ Abcde - `19` `30` `7` `26` `42` - - 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcde~ - `41` `39` `10` - - 1 AbcdefghijAb~ AbcdefghijA~ Abcde~ + `8` `24` `29` + + 1 Abcdefgh Abcdefghij~ AbcdefghijA~ + `1` `12` `2` `20` `17` + + 1 A Abcde~ Ab Abcdef~ Abcde~ + `35` `5` `19` `30` `7` + + 1 Abcdef~ Abcde Abcde~ Abcde~ Abcd~ + `26` `42` `41` `39` `10` + + 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ $extra_cols named list() Code - options(width = 32) ctl_colonnade(df_str[c(43L, 1L, 3L, 15L, 28L, 12L, 46L, 34L, 31L, 7L, 11L, 4L, 44L, 8L, 9L, 5L, 36L, 22L, 17L, 39L, 18L, 45L, 37L, 13L, 29L, 6L, 30L, 16L, 20L, 10L, 19L, 26L, 33L, 40L, 35L, 48L, 38L, 25L, 2L, 47L, 42L, 41L, 27L, 14L, - 21L, 24L, 50L, 49L, 23L, 32L)], width = 446) + 21L, 24L, 50L, 49L, 23L, 32L)], width = { + options(width = 32) + 446 + }) Output $body `43` @@ -437,43 +449,45 @@ `46` 1 AbcdefghijAbcdefghijAbcdefghi~ - `34` `31` `7` `11` `4` - - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd - `44` `8` `9` `5` `36` + `34` `31` `7` + + 1 AbcdefghijA~ Abcdefghij~ Abcd~ + `11` `4` `44` `8` `9` - 1 Abcde~ Abcd~ Abcd~ Abcde Abcd~ - `22` `17` `39` `18` `45` + 1 Abcde~ Abcd Abcd~ Abcd~ Abcd~ + `5` `36` `22` `17` `39` + + 1 Abcde Abcde~ Abcd~ Abcd~ Abcd~ + `18` `45` `37` `13` `29` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `37` `13` `29` `6` `30` + `6` `30` `16` `20` `10` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `16` `20` `10` `19` `26` + 1 Abcdef Abcd~ Abcd~ Abcd~ Abcd~ + `19` `26` `33` `40` `35` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `33` `40` `35` `48` `38` + `48` `38` `25` `2` `47` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `25` `2` `47` `42` `41` + 1 Abcde~ Abcd~ Abcd~ Ab Abcd~ + `42` `41` `27` `14` `21` - 1 Abcde~ Ab Abcd~ Abcd~ Abcd~ - `27` `14` `21` `24` `50` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `24` `50` `49` `23` `32` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `49` `23` `32` - - 1 Abcdefghi~ Abcdefgh~ Abcdefgh~ $extra_cols named list() Code - options(width = 31) ctl_colonnade(df_str[c(37L, 46L, 21L, 3L, 16L, 39L, 34L, 33L, 10L, 17L, 19L, 36L, 45L, 49L, 11L, 50L, 14L, 29L, 44L, 13L, 30L, 38L, 32L, 40L, 42L, 1L, 31L, 41L, 7L, 23L, 35L, 28L, 6L, 25L, 2L, 9L, 12L, 15L, 5L, 18L, 20L, 27L, 43L, 8L, - 47L, 4L, 48L, 24L, 26L, 22L)], width = 1166) + 47L, 4L, 48L, 24L, 26L, 22L)], width = { + options(width = 31) + 1166 + }) Output $body `37` @@ -584,22 +598,24 @@ `20` 1 AbcdefghijAbcdefghij - `27` `43` `8` `47` `4` - - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd - `48` `24` `26` `22` + `27` `43` `8` `47` 1 Abcdef~ Abcdef~ Abcde~ Abcde~ + `4` `48` `24` `26` `22` + + 1 Abcd Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 58) ctl_colonnade(df_str[c(31L, 39L, 40L, 30L, 10L, 21L, 9L, 16L, 46L, 25L, 15L, 24L, 3L, 50L, 35L, 1L, 12L, 34L, 48L, 4L, 29L, 23L, 37L, 36L, 28L, 43L, 11L, 17L, 32L, 8L, 41L, 13L, 44L, 7L, 38L, 26L, 33L, 20L, 19L, 2L, 18L, 49L, 27L, - 47L, 22L, 14L, 6L, 5L, 45L, 42L)], width = 546) + 47L, 22L, 14L, 6L, 5L, 45L, 42L)], width = { + options(width = 58) + 546 + }) Output $body `31` @@ -617,31 +633,33 @@ `21` `9` `16` 1 AbcdefghijAbcdefghijA Abcdefghi AbcdefghijAbcdef - `46` `25` `15` `24` `3` `50` `35` `1` `12` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abc Abcd~ Abcd~ A Abcd~ - `34` `48` `4` `29` `23` `37` `36` `28` `43` - - 1 Abcde~ Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `11` `17` `32` `8` `41` `13` `44` `7` `38` + `46` `25` `15` `24` `3` `50` + + 1 AbcdefghijA~ Abcdefgh~ Abcde~ Abcdef~ Abc AbcdefghijA~ + `35` `1` `12` `34` `48` `4` `29` `23` `37` + + 1 Abcde~ A Abcde~ Abcde~ Abcd~ Abcd Abcd~ Abcd~ Abcd~ + `36` `28` `43` `11` `17` `32` `8` `41` `13` 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `26` `33` `20` `19` `2` `18` `49` `27` `47` + `44` `7` `38` `26` `33` `20` `19` `2` `18` - 1 Abcde~ Abcde~ Abcde~ Abcd~ Ab Abcd~ Abcd~ Abcd~ Abcd~ - `22` `14` `6` `5` `45` `42` - - 1 Abcdefgh~ Abcdef~ Abcd~ Abcde AbcdefghijAb~ AbcdefghijA~ + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Ab Abcd~ + `49` `27` `47` `22` `14` `6` `5` `45` `42` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcde Abcd~ Abcd~ $extra_cols named list() Code - options(width = 57) ctl_colonnade(df_str[c(43L, 21L, 41L, 48L, 22L, 25L, 2L, 8L, 1L, 24L, 6L, 39L, 38L, 20L, 49L, 45L, 47L, 12L, 9L, 13L, 36L, 26L, 44L, 11L, 46L, 28L, 7L, 18L, 50L, 16L, 29L, 30L, 4L, 23L, 17L, 40L, 33L, 14L, 27L, 19L, 34L, 32L, 3L, 37L, - 15L, 10L, 5L, 35L, 31L, 42L)], width = 1035) + 15L, 10L, 5L, 35L, 31L, 42L)], width = { + options(width = 57) + 1035 + }) Output $body `43` @@ -689,28 +707,30 @@ `26` 1 AbcdefghijAbcdefghijAbcdef - `44` `11` `46` `28` `7` `18` `50` `16` `29` + `44` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcd + `11` `46` `28` `7` `18` `50` `16` `29` `30` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `30` `4` `23` `17` `40` `33` `14` `27` `19` + `4` `23` `17` `40` `33` `14` `27` `19` `34` + + 1 Abcd Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `32` `3` `37` `15` `10` `5` `35` `31` `42` - 1 Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `34` `32` `3` `37` `15` `10` `5` `35` `31` - - 1 Abcde~ Abcde~ Abc Abcd~ Abcd~ Abcd~ Abcde Abcd~ Abcd~ - `42` - - 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb + 1 Abcde~ Abc Abcde~ Abcd~ Abcd~ Abcde Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 33) ctl_colonnade(df_str[c(40L, 6L, 25L, 5L, 26L, 17L, 19L, 2L, 11L, 34L, 45L, 24L, 22L, 44L, 35L, 7L, 4L, 49L, 1L, 36L, 12L, 41L, 39L, 13L, 48L, 27L, 18L, 30L, 42L, 28L, 3L, 46L, 21L, 20L, 16L, 29L, 50L, 10L, 9L, 8L, 47L, 31L, 14L, 38L, - 33L, 32L, 43L, 23L, 15L, 37L)], width = 1217) + 33L, 32L, 43L, 23L, 15L, 37L)], width = { + options(width = 33) + 1217 + }) Output $body `40` @@ -815,25 +835,27 @@ `50` 1 AbcdefghijAbcdefghijAbcdefghij~ - `10` `9` `8` `47` `31` + `10` `9` `8` + + 1 Abcdefghij Abcdefghi Abcdefgh + `47` `31` `14` `38` `33` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `14` `38` `33` `32` `43` + `32` `43` `23` `15` `37` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `23` `15` `37` - - 1 Abcdefghi~ Abcdefg~ Abcdefghij~ $extra_cols named list() Code - options(width = 32) ctl_colonnade(df_str[c(43L, 23L, 22L, 11L, 6L, 26L, 48L, 17L, 7L, 42L, 36L, 21L, 35L, 50L, 13L, 19L, 29L, 8L, 15L, 4L, 2L, 27L, 49L, 47L, 30L, 31L, 25L, 28L, 46L, 12L, 32L, 39L, 24L, 10L, 45L, 5L, 37L, 14L, 40L, 20L, 41L, 44L, 33L, 18L, - 38L, 3L, 1L, 34L, 16L, 9L)], width = 770) + 38L, 3L, 1L, 34L, 16L, 9L)], width = { + options(width = 32) + 770 + }) Output $body `43` @@ -893,34 +915,36 @@ `49` 1 AbcdefghijAbcdefghijAbcdefghi~ - `47` `30` `31` `25` `28` + `47` `30` + + 1 AbcdefghijAbcd~ AbcdefghijAbc~ + `31` `25` `28` `46` `12` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `46` `12` `32` `39` `24` + `32` `39` `24` `10` `45` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `10` `45` `5` `37` `14` - - 1 Abcde~ Abcd~ Abcde Abcd~ Abcd~ - `40` `20` `41` `44` `33` + `5` `37` `14` `40` `20` + + 1 Abcde Abcde~ Abcd~ Abcd~ Abcd~ + `41` `44` `33` `18` `38` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `18` `38` `3` `1` `34` - - 1 Abcde~ Abcd~ Abc A Abcd~ - `16` `9` - - 1 AbcdefghijAbcdef Abcdefghi + `3` `1` `34` `16` `9` + + 1 Abc A Abcde~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 46) ctl_colonnade(df_str[c(5L, 24L, 43L, 46L, 35L, 39L, 18L, 26L, 8L, 27L, 2L, 50L, 6L, 14L, 29L, 47L, 9L, 16L, 36L, 4L, 13L, 41L, 3L, 28L, 37L, 33L, 38L, 31L, 34L, 19L, 42L, 32L, 1L, 45L, 15L, 7L, 11L, 49L, 23L, 12L, 48L, 20L, 21L, 44L, - 25L, 10L, 22L, 30L, 40L, 17L)], width = 1439) + 25L, 10L, 22L, 30L, 40L, 17L)], width = { + options(width = 46) + 1439 + }) Output $body `5` `24` @@ -1013,22 +1037,24 @@ `48` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbc~ - `20` `21` `44` `25` `10` `22` `30` + `20` `21` + + 1 AbcdefghijAbcdefghij AbcdefghijAbcdefghijA + `44` `25` `10` `22` `30` `40` `17` 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `40` `17` - - 1 AbcdefghijAbcdefghijAbcdefghi~ AbcdefghijAb~ $extra_cols named list() Code - options(width = 52) ctl_colonnade(df_str[c(7L, 44L, 19L, 21L, 18L, 35L, 23L, 50L, 33L, 37L, 25L, 26L, 10L, 39L, 2L, 47L, 42L, 14L, 9L, 41L, 45L, 6L, 4L, 11L, 24L, 43L, 32L, 3L, 38L, 5L, 49L, 27L, 17L, 8L, 22L, 40L, 12L, 15L, 1L, 28L, 31L, 29L, 13L, - 48L, 34L, 36L, 30L, 20L, 16L, 46L)], width = 1065) + 48L, 34L, 36L, 30L, 20L, 16L, 46L)], width = { + options(width = 52) + 1065 + }) Output $body `7` @@ -1082,28 +1108,30 @@ `45` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcde - `6` `4` `11` `24` `43` `32` `3` `38` - - 1 Abcdef Abcd Abcde~ Abcde~ Abcd~ Abcd~ Abc Abcd~ - `5` `49` `27` `17` `8` `22` `40` `12` - - 1 Abcde Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `15` `1` `28` `31` `29` `13` `48` `34` - - 1 Abcde~ A Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `36` `30` `20` `16` `46` - - 1 Abcdefghij~ Abcdefghi~ Abcdef~ Abcde~ AbcdefghijA~ + `6` `4` `11` `24` `43` + + 1 Abcdef Abcd AbcdefghijA Abcdefghi~ AbcdefghijAbc~ + `32` `3` `38` `5` `49` `27` `17` `8` + + 1 Abcde~ Abc Abcde~ Abcde Abcde~ Abcd~ Abcd~ Abcd~ + `22` `40` `12` `15` `1` `28` `31` `29` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ A Abcd~ Abcd~ Abcd~ + `13` `48` `34` `36` `30` `20` `16` `46` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ $extra_cols named list() Code - options(width = 35) ctl_colonnade(df_str[c(38L, 18L, 23L, 36L, 35L, 20L, 44L, 19L, 13L, 41L, 31L, 7L, 11L, 29L, 2L, 14L, 26L, 46L, 40L, 45L, 9L, 34L, 33L, 22L, 1L, 17L, 28L, 10L, 21L, 30L, 47L, 49L, 6L, 12L, 4L, 25L, 32L, 15L, 43L, 24L, 48L, 3L, 37L, - 50L, 42L, 39L, 16L, 8L, 27L, 5L)], width = 393) + 50L, 42L, 39L, 16L, 8L, 27L, 5L)], width = { + options(width = 35) + 393 + }) Output $body `38` @@ -1112,46 +1140,48 @@ `18` 1 AbcdefghijAbcdefgh - `23` `36` `35` `20` `44` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `19` `13` `41` `31` `7` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `11` `29` `2` `14` `26` + `23` `36` `35` + + 1 Abcdefgh~ Abcdefghij~ Abcdefghij~ + `20` `44` `19` `13` `41` - 1 Abcde~ Abcdef~ Ab Abcd~ Abcde~ - `46` `40` `45` `9` `34` + 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcde~ + `31` `7` `11` `29` `2` + + 1 Abcdef~ Abcde~ Abcd~ Abcde~ Ab + `14` `26` `46` `40` `45` 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `33` `22` `1` `17` `28` - - 1 Abcdef~ Abcde~ A Abcd~ Abcde~ - `10` `21` `30` `47` `49` - - 1 Abcde~ Abcde~ Abcd~ Abcde~ Abcde~ - `6` `12` `4` `25` `32` - - 1 Abcdef Abcde~ Abcd Abcde~ Abcde~ - `15` `43` `24` `48` `3` + `9` `34` `33` `22` `1` + + 1 Abcde~ Abcdef~ Abcde~ Abcd~ A + `17` `28` `10` `21` `30` + + 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcde~ + `47` `49` `6` `12` `4` + + 1 Abcdef~ Abcdef~ Abcd~ Abcd~ Abcd + `25` `32` `15` `43` `24` - 1 Abcde~ Abcdef~ Abcd~ Abcde~ Abc - `37` `50` `42` `39` `16` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `8` `27` `5` - - 1 Abcdef~ AbcdefghijAbcdefgh~ Abcde + 1 Abcde~ Abcdef~ Abcd~ Abcde~ Abcd~ + `48` `3` `37` `50` `42` + + 1 Abcde~ Abc Abcde~ Abcde~ Abcde~ + `39` `16` `8` `27` `5` + + 1 Abcdef~ Abcde~ Abcd~ Abcde~ Abcde $extra_cols named list() Code - options(width = 41) ctl_colonnade(df_str[c(22L, 9L, 11L, 26L, 19L, 16L, 32L, 25L, 1L, 30L, 31L, 6L, 24L, 10L, 39L, 21L, 50L, 7L, 29L, 12L, 46L, 43L, 15L, 35L, 20L, 40L, 49L, 38L, 36L, 48L, 34L, 3L, 8L, 4L, 27L, 42L, 44L, 33L, 45L, 18L, 5L, 2L, 13L, 47L, - 28L, 17L, 37L, 14L, 41L, 23L)], width = 999) + 28L, 17L, 37L, 14L, 41L, 23L)], width = { + options(width = 41) + 999 + }) Output $body `22` `9` @@ -1217,18 +1247,18 @@ `38` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefgh - `36` `48` `34` `3` `8` `4` - - 1 Abcdef~ Abcde~ Abcde~ Abc Abcd~ Abcd - `27` `42` `44` `33` `45` `18` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ - `5` `2` `13` `47` `28` `17` - - 1 Abcde Ab Abcde~ Abcdef~ Abcde~ Abcd~ - `37` `14` `41` `23` - - 1 Abcdefghij~ Abcdef~ Abcdefghi~ Abcdefg~ + `36` `48` `34` `3` + + 1 Abcdefghij~ Abcdefghij~ Abcdefgh~ Abc + `8` `4` `27` `42` `44` `33` + + 1 Abcde~ Abcd Abcde~ Abcde~ Abcde~ Abcd~ + `45` `18` `5` `2` `13` `47` + + 1 Abcdef~ Abcde~ Abcde Ab Abcd~ Abcde~ + `28` `17` `37` `14` `41` `23` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ $extra_cols named list() diff --git a/tests/testthat/_snaps/format_character.md b/tests/testthat/_snaps/format_character.md index c7086e02b..ed944a973 100644 --- a/tests/testthat/_snaps/format_character.md +++ b/tests/testthat/_snaps/format_character.md @@ -68,16 +68,16 @@ pillar(add_special(c("\t")), width = 10) Output - - "\t" - + + "\t" + Code pillar(add_special(c("a\nb")), width = 10) Output - - "a\nb" - + + "a\nb" + Code pillar(add_special(c("a\001b")), width = 10) Output diff --git a/tests/testthat/_snaps/format_list_of.md b/tests/testthat/_snaps/format_list_of.md index df4737299..0ca86d542 100644 --- a/tests/testthat/_snaps/format_list_of.md +++ b/tests/testthat/_snaps/format_list_of.md @@ -4,9 +4,9 @@ pillar(v, width = 15) Output - > - [1] - [3] + > + [1] + [3] --- @@ -14,6 +14,6 @@ pillar(v, width = 30) Output - > - SC + > + SC diff --git a/tests/testthat/_snaps/format_multi.md b/tests/testthat/_snaps/format_multi.md index 129cfcbdf..0c337dc20 100644 --- a/tests/testthat/_snaps/format_multi.md +++ b/tests/testthat/_snaps/format_multi.md @@ -76,9 +76,37 @@ 3 3.23 Code colonnade(x, width = 13) + Output + column_zer~ + + 1 1.23 + 2 2.23 + 3 3.23 + Code colonnade(x, width = 14) + Output + column_zero~ + + 1 1.23 + 2 2.23 + 3 3.23 + Code colonnade(x, width = 15) + Output + column_zero_~ + + 1 1.23 + 2 2.23 + 3 3.23 + Code colonnade(x, width = 16) + Output + column_zero_o~ + + 1 1.23 + 2 2.23 + 3 3.23 + Code colonnade(x, width = 17) Output column_zero_one diff --git a/tests/testthat/_snaps/format_multi_fuzz.md b/tests/testthat/_snaps/format_multi_fuzz.md index bb5db2dab..a98694e4f 100644 --- a/tests/testthat/_snaps/format_multi_fuzz.md +++ b/tests/testthat/_snaps/format_multi_fuzz.md @@ -73,12 +73,12 @@ `37` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefg - `34` `49` `46` `2` `32` `35` `39` `11` `17` - - 1 Abcde~ Abcde~ Abcde~ Ab Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `5` `26` `20` - - 1 Abcde AbcdefghijAbcdefghijAbcdef AbcdefghijAbcdefghij + `34` `49` `46` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcd Abcdefghij~ Abcdefghi~ + `2` `32` `35` `39` `11` `17` `5` `26` `20` + + 1 Ab Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde Abcd~ Abcd~ Code options(width = 54) colonnade(df_str[c(40L, 28L, 7L, 16L, 48L, 6L, 21L, 1L, 20L, 17L, 47L, 45L, 29L, @@ -119,21 +119,21 @@ `49` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghi - `34` `4` `39` `18` `36` `26` `38` `10` - - 1 Abcde~ Abcd Abcdef~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `8` `5` `15` `44` `24` `46` `14` `25` - - 1 Abcde~ Abcde Abcde~ Abcdef~ Abcd~ Abcde~ Abcd~ Abcd~ - `27` `3` `37` `35` `12` `9` `13` `22` - - 1 Abcde~ Abc Abcdef~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ - `33` `42` `11` `19` `50` `23` `30` `32` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `2` `43` `31` - - 1 Ab AbcdefghijAbcdefghijAbcde~ AbcdefghijAbcdefgh~ + `34` `4` `39` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcd Abcd Abcdefghij~ + `18` `36` `26` `38` `10` `8` `5` `15` + + 1 Abcde~ Abcdef~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde Abcd~ + `44` `24` `46` `14` `25` `27` `3` `37` + + 1 Abcdef~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abc Abcd~ + `35` `12` `9` `13` `22` `33` `42` `11` + + 1 Abcdef~ Abcde~ Abcd~ Abcd~ Abcd~ Abcde~ Abcde~ Abcd~ + `19` `50` `23` `30` `32` `2` `43` `31` + + 1 Abcde~ Abcdef~ Abcde~ Abcde~ Abcd~ Ab Abcd~ Abcd~ Code options(width = 32) colonnade(df_str[c(47L, 42L, 4L, 46L, 9L, 34L, 19L, 39L, 8L, 32L, 36L, 12L, 29L, @@ -159,33 +159,33 @@ `34` 1 AbcdefghijAbcdefghijAbcdefghi~ - `19` `39` `8` `32` `36` + `19` `39` `8` `32` + + 1 Abcdef~ Abcdefg~ Abcd~ Abcdef~ + `36` `12` `29` `5` `15` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `29` `5` `15` `11` - - 1 Abcde~ Abcd~ Abcde Abcd~ Abcd~ - `31` `27` `33` `28` `43` + 1 Abcde~ Abcd~ Abcd~ Abcde Abcd~ + `11` `31` `27` `33` `28` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `6` `13` `22` `14` `16` + `43` `6` `13` `22` `14` - 1 Abcdef Abcd~ Abcd~ Abcd~ Abcd~ - `35` `50` `38` `7` `23` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `16` `35` `50` `38` `7` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `45` `40` `3` `2` `24` + `23` `45` `40` `3` `2` - 1 Abcde~ Abcd~ Abc Ab Abcd~ - `41` `10` `30` `25` `17` + 1 Abcde~ Abcd~ Abcd~ Abc Ab + `24` `41` `10` `30` `25` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `26` `48` `37` `49` `1` + `17` `26` `48` `37` `49` - 1 Abcde~ Abcd~ Abcd~ Abcd~ A - `18` `21` `44` `20` - - 1 Abcdef~ Abcdef~ Abcdef~ Abcde~ + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `1` `18` `21` `44` `20` + + 1 A Abcde~ Abcd~ Abcd~ Abcd~ Code options(width = 55) colonnade(df_str[c(41L, 4L, 25L, 31L, 8L, 22L, 19L, 10L, 29L, 21L, 34L, 5L, 26L, @@ -229,18 +229,18 @@ `39` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghi - `28` `43` `32` `30` `48` `44` `6` `20` `13` + `28` `43` `32` + + 1 AbcdefghijAbcdefghijAbcdefgh AbcdefghijAb~ Abcdefghi~ + `30` `48` `44` `6` `20` `13` `15` `18` `42` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `15` `18` `42` `9` `12` `37` `45` `16` `40` + `9` `12` `37` `45` `16` `40` `11` `14` `38` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `11` `14` `38` `1` `7` `3` `23` `35` `50` + `1` `7` `3` `23` `35` `50` `17` `49` `33` - 1 Abcd~ Abcd~ Abcd~ A Abcd~ Abc Abcd~ Abcd~ Abcd~ - `17` `49` `33` - - 1 Abcdefghij~ AbcdefghijAbcdefghijAb~ AbcdefghijAbcdef~ + 1 A Abcd~ Abc Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 54) colonnade(df_str[c(27L, 22L, 9L, 23L, 16L, 19L, 25L, 31L, 44L, 1L, 28L, 46L, @@ -266,21 +266,21 @@ `28` 1 AbcdefghijAbcdefghijAbcdefgh - `46` `12` `20` `43` `37` `5` `2` `18` - - 1 Abcdef~ Abcde~ Abcd~ Abcde~ Abcde~ Abcde Ab Abcd~ - `41` `26` `33` `11` `49` `24` `35` `4` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd - `47` `30` `7` `34` `3` `32` `42` `10` - - 1 Abcdef~ Abcde~ Abcde~ Abcd~ Abc Abcd~ Abcde~ Abcd~ - `45` `38` `39` `48` `14` `6` `17` `36` - - 1 Abcde~ Abcde~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ - `50` `40` `13` `8` `21` `15` `29` - - 1 Abcdefgh~ Abcdefg~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ + `46` `12` `20` `43` `37` `5` `2` + + 1 Abcdefgh~ Abcde~ Abcde~ Abcdefg~ Abcdef~ Abcde Ab + `18` `41` `26` `33` `11` `49` `24` `35` + + 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ + `4` `47` `30` `7` `34` `3` `32` `42` + + 1 Abcd Abcdef~ Abcde~ Abcde~ Abcd~ Abc Abcd~ Abcde~ + `10` `45` `38` `39` `48` `14` `6` `17` + + 1 Abcde~ Abcdef~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ Abcd~ + `36` `50` `40` `13` `8` `21` `15` `29` + + 1 Abcde~ Abcdef~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 49) colonnade(df_str[c(32L, 24L, 18L, 25L, 26L, 13L, 33L, 2L, 50L, 38L, 37L, 16L, @@ -342,18 +342,18 @@ `23` 1 AbcdefghijAbcdefghijAbc - `41` `5` `1` `14` `46` `30` `31` `44` + `41` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijA + `5` `1` `14` `46` `30` `31` `44` `4` - 1 Abcd~ Abcde A Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `4` `7` `40` `43` `12` `29` `8` `36` + 1 Abcde A Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd + `7` `40` `43` `12` `29` `8` `36` `45` - 1 Abcd Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `45` `11` `20` `10` `6` `19` `48` `39` + 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `11` `20` `10` `6` `19` `48` `39` `42` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `42` - - 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb Code options(width = 38) colonnade(df_str[c(44L, 34L, 49L, 9L, 15L, 16L, 1L, 10L, 40L, 29L, 26L, 22L, 4L, @@ -373,30 +373,30 @@ `9` `15` 1 Abcdefghi AbcdefghijAbcde - `16` `1` `10` `40` `29` `26` + `16` `1` `10` + + 1 AbcdefghijAbcdef A Abcdefghij + `40` `29` `26` `22` `4` `43` - 1 Abcde~ A Abcd~ Abcd~ Abcd~ Abcd~ - `22` `4` `43` `20` `17` `46` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd Abcd~ + `20` `17` `46` `33` `35` `32` - 1 Abcde~ Abcd Abcd~ Abcd~ Abcd~ Abcd~ - `33` `35` `32` `2` `12` `8` - - 1 Abcde~ Abcd~ Abcd~ Ab Abcd~ Abcd~ - `37` `23` `39` `7` `18` `36` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `2` `12` `8` `37` `23` `39` + + 1 Ab Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `7` `18` `36` `42` `6` `30` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `42` `6` `30` `19` `25` `5` + `19` `25` `5` `21` `47` `50` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcde - `21` `47` `50` `28` `11` `31` + 1 Abcde~ Abcd~ Abcde Abcd~ Abcd~ Abcd~ + `28` `11` `31` `14` `24` `27` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `14` `24` `27` `45` `41` `38` + `45` `41` `38` `3` `13` `48` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `3` `13` `48` - - 1 Abc Abcdefgh~ AbcdefghijAbcdefghi~ + 1 Abcde~ Abcd~ Abcd~ Abc Abcd~ Abcd~ Code options(width = 54) colonnade(df_str[c(21L, 26L, 8L, 22L, 41L, 24L, 13L, 5L, 47L, 37L, 4L, 42L, 19L, @@ -425,21 +425,21 @@ `42` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb - `19` `34` `11` `43` `38` `3` `33` `20` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abc Abcd~ Abcd~ - `31` `2` `18` `48` `27` `44` `9` `35` - - 1 Abcde~ Ab Abcde~ Abcdef~ Abcd~ Abcde~ Abcd~ Abcd~ - `30` `6` `49` `10` `1` `16` `46` `29` - - 1 Abcde~ Abcdef Abcdef~ Abcd~ A Abcd~ Abcde~ Abcd~ - `12` `14` `45` `36` `15` `39` `50` `23` - - 1 Abcde~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcde~ Abcd~ - `17` `28` `7` `32` `40` `25` - - 1 Abcdef~ Abcdefgh~ Abcde~ Abcdefg~ Abcdefghi~ Abcdef~ + `19` `34` `11` `43` `38` `3` + + 1 AbcdefghijAbcdefghi Abcde~ Abcde~ Abcde~ Abcd~ Abc + `33` `20` `31` `2` `18` `48` `27` `44` + + 1 Abcde~ Abcde~ Abcde~ Ab Abcd~ Abcde~ Abcd~ Abcde~ + `9` `35` `30` `6` `49` `10` `1` `16` + + 1 Abcde~ Abcdef~ Abcde~ Abcd~ Abcde~ Abcd~ A Abcd~ + `46` `29` `12` `14` `45` `36` `15` `39` + + 1 Abcdef~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ Abcd~ + `50` `23` `17` `28` `7` `32` `40` `25` + + 1 Abcdef~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 39) colonnade(df_str[c(23L, 49L, 13L, 37L, 3L, 25L, 36L, 4L, 9L, 7L, 27L, 48L, 12L, @@ -592,33 +592,33 @@ `42` 1 AbcdefghijAbcdefghijAbcdefgh~ - `18` `16` `47` `25` `4` + `18` `16` `47` + + 1 Abcdefgh~ Abcdef~ Abcdefghij~ + `25` `4` `37` `8` `26` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd - `37` `8` `26` `21` `50` + 1 Abcd~ Abcd Abcd~ Abcd~ Abcd~ + `21` `50` `5` `41` `30` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `5` `41` `30` `2` `33` + 1 Abcd~ Abcd~ Abcde Abcd~ Abcd~ + `2` `33` `34` `3` `44` - 1 Abcde Abcd~ Abcd~ Ab Abcd~ - `34` `3` `44` `19` `43` + 1 Ab Abcd~ Abcd~ Abc Abcd~ + `19` `43` `6` `32` `29` - 1 Abcd~ Abc Abcd~ Abcd~ Abcd~ - `6` `32` `29` `20` `1` + 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `20` `1` `13` `11` `40` - 1 Abcd~ Abcd~ Abcd~ Abcd~ A - `13` `11` `40` `12` `48` + 1 Abcd~ A Abcd~ Abcd~ Abcd~ + `12` `48` `23` `9` `15` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `23` `9` `15` `46` `36` + `46` `36` `27` `35` `28` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `27` `35` `28` `10` `7` + `10` `7` `39` `17` `38` 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `39` `17` `38` - - 1 Abcdefghi~ Abcdefg~ Abcdefgh~ Code options(width = 52) colonnade(df_str[c(38L, 46L, 17L, 11L, 24L, 18L, 16L, 39L, 50L, 42L, 6L, 13L, @@ -680,18 +680,18 @@ `36` 1 AbcdefghijAbcdefghijAbcdefghijAbcdef - `28` `5` `10` `30` `20` `1` `14` `43` + `28` `5` `10` `30` + + 1 AbcdefghijAbcdefghijAbcdefgh Abcde Abcde~ Abcdefg~ + `20` `1` `14` `43` `49` `23` `26` `21` - 1 Abcde~ Abcde Abcde~ Abcde~ Abcd~ A Abcd~ Abcd~ - `49` `23` `26` `21` `32` `19` `34` `15` + 1 Abcde~ A Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `32` `19` `34` `15` `48` `4` `7` `35` - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `48` `4` `7` `35` `40` `8` `22` `3` - - 1 Abcde~ Abcd Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abc - `25` `12` `27` `2` - - 1 AbcdefghijAbcdef~ Abcdefg~ AbcdefghijAbcdef~ Ab + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd Abcd~ Abcd~ + `40` `8` `22` `3` `25` `12` `27` `2` + + 1 Abcdef~ Abcde~ Abcd~ Abc Abcd~ Abcd~ Abcd~ Ab Code options(width = 58) colonnade(df_str[c(17L, 28L, 29L, 27L, 20L, 31L, 43L, 30L, 32L, 48L, 10L, 50L, @@ -759,15 +759,15 @@ `42` `3` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb Abc - `11` `40` `26` `37` `7` `39` `6` `4` `19` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd Abcd~ - `8` `45` `14` `24` `23` `2` `47` `9` `49` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Ab Abcd~ Abcd~ Abcd~ - `41` `38` `22` `44` `15` - - 1 AbcdefghijAb~ AbcdefghijA~ Abcdefg~ AbcdefghijA~ Abcdef~ + `11` `40` `26` `37` `7` + + 1 AbcdefghijA AbcdefghijAbc~ Abcdefghi~ AbcdefghijA~ Abcd~ + `39` `6` `4` `19` `8` `45` `14` `24` `23` + + 1 Abcde~ Abcdef Abcd Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `2` `47` `9` `49` `41` `38` `22` `44` `15` + + 1 Ab Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 47) colonnade(df_str[c(1L, 26L, 20L, 12L, 49L, 16L, 24L, 4L, 15L, 47L, 8L, 11L, 14L, @@ -787,27 +787,27 @@ `16` `24` 1 AbcdefghijAbcdef AbcdefghijAbcdefghijAbcd - `4` `15` `47` `8` `11` `14` `50` - - 1 Abcd Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcde~ - `17` `2` `44` `30` `36` `45` `25` - - 1 Abcde~ Ab Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ - `38` `18` `29` `5` `13` `3` `23` - - 1 Abcdef~ Abcde~ Abcde~ Abcde Abcd~ Abc Abcd~ - `48` `40` `34` `22` `39` `33` `27` + `4` + + 1 Abcd + `15` `47` `8` `11` `14` `50` `17` + + 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcde~ Abcd~ + `2` `44` `30` `36` `45` `25` `38` + + 1 Ab Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ + `18` `29` `5` `13` `3` `23` `48` + + 1 Abcde~ Abcde~ Abcde Abcde~ Abc Abcd~ Abcde~ + `40` `34` `22` `39` `33` `27` `7` 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `7` `19` `10` `37` `6` `35` `46` - - 1 Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ Abcde~ - `31` `41` `43` `28` `42` `32` `21` + `19` `10` `37` `6` `35` `46` `31` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde~ Abcd~ + `41` `43` `28` `42` `32` `21` `9` 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `9` - - 1 Abcdefghi Code options(width = 55) colonnade(df_str[c(6L, 49L, 26L, 45L, 25L, 15L, 31L, 20L, 21L, 44L, 23L, 48L, @@ -845,21 +845,21 @@ `48` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefgh - `37` `36` `5` `43` `11` `14` `13` `39` `16` + `37` `36` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcdefg AbcdefghijAbcd~ + `5` `43` `11` `14` `13` `39` `16` `12` `4` - 1 Abcd~ Abcd~ Abcde Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `4` `18` `42` `3` `10` `28` `40` `24` + 1 Abcde Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd + `18` `42` `3` `10` `28` `40` `24` `29` `17` - 1 Abcd~ Abcd Abcd~ Abcd~ Abc Abcd~ Abcd~ Abcd~ Abcd~ - `29` `17` `35` `47` `2` `38` `34` `9` `7` + 1 Abcd~ Abcd~ Abc Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `35` `47` `2` `38` `34` `9` `7` `8` `50` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Ab Abcd~ Abcd~ Abcd~ Abcd~ - `8` `50` `33` `32` `27` `46` `19` `22` `41` + 1 Abcd~ Abcd~ Ab Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `33` `32` `27` `46` `19` `22` `41` `30` `1` - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `30` `1` - - 1 AbcdefghijAbcdefghijAbcdefghij A + 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ A Code options(width = 46) colonnade(df_str[c(38L, 42L, 41L, 10L, 40L, 11L, 27L, 9L, 17L, 37L, 46L, 13L, @@ -897,22 +897,22 @@ `13` 1 AbcdefghijAbc - `36` `18` `31` `20` `39` `12` `44` + `36` `18` `31` + + 1 AbcdefghijAbcdef~ Abcdefghi~ AbcdefghijAbcd~ + `20` `39` `12` `44` `33` `50` `34` 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `33` `50` `34` `26` `32` `23` `30` + `26` `32` `23` `30` `29` `21` `4` - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `29` `21` `4` `49` `19` `25` `3` + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd + `49` `19` `25` `3` `6` `15` `14` + + 1 Abcdef~ Abcde~ Abcd~ Abc Abcd~ Abcd~ Abcd~ + `43` `48` `8` `22` `1` `2` `45` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ A Ab Abcd~ + `35` `16` `5` `47` `28` `24` `7` - 1 Abcde~ Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abc - `6` `15` `14` `43` `48` `8` `22` - - 1 Abcdef Abcde~ Abcd~ Abcd~ Abcde~ Abcd~ Abcd~ - `1` `2` `45` `35` `16` `5` `47` - - 1 A Ab Abcde~ Abcde~ Abcde~ Abcde Abcd~ - `28` `24` `7` - - 1 AbcdefghijAbcdefghi~ AbcdefghijAbcde~ Abcde~ + 1 Abcde~ Abcde~ Abcde Abcde~ Abcd~ Abcd~ Abcd~ diff --git a/tests/testthat/_snaps/format_multi_fuzz_2.md b/tests/testthat/_snaps/format_multi_fuzz_2.md index 8d092afa0..13aa139d9 100644 --- a/tests/testthat/_snaps/format_multi_fuzz_2.md +++ b/tests/testthat/_snaps/format_multi_fuzz_2.md @@ -19,24 +19,24 @@ `47` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefg - `25` `42` `27` `44` `20` `14` `36` `43` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `41` `26` `45` `22` `9` `13` `32` `31` - - 1 Abcdef~ Abcde~ Abcdef~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `19` `48` `49` `35` `3` `11` `23` - - 1 Abcde~ Abcde~ Abcdef~ Abcde~ Abcd~ Abc Abcd~ Abcd~ - `24` `40` `15` `38` `10` `46` `5` `50` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde~ Abcde Abcde~ - `18` `21` `6` `30` `2` `7` `1` `4` - - 1 Abcdef~ Abcde~ Abcd~ Abcdef~ Ab Abcd~ A Abcd - `8` `17` `33` `39` `37` - - 1 Abcde~ Abcdefg~ Abcdefghij~ AbcdefghijA~ Abcdefghij~ + `25` `42` `27` `44` `20` + + 1 AbcdefghijAbcdefghijAbcde Abcde~ Abcde~ Abcde~ Abcd~ + `14` `36` `43` `41` `26` `45` `22` `9` + + 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ Abcd~ + `13` `32` `31` `12` `19` `48` `49` `35` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcde~ Abcde~ Abcd~ + `3` `11` `23` `24` `40` `15` `38` `10` + + 1 Abc Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ + `46` `5` `50` `18` `21` `6` `30` `2` + + 1 Abcdef~ Abcde Abcdef~ Abcde~ Abcd~ Abcd~ Abcd~ Ab + `7` `1` `4` `8` `17` `33` `39` `37` + + 1 Abcde~ A Abcd Abcde~ Abcd~ Abcde~ Abcde~ Abcde~ Code options(width = 42) colonnade(df_str[c(28L, 41L, 12L, 29L, 13L, 43L, 24L, 50L, 48L, 35L, 44L, 21L, @@ -137,12 +137,12 @@ `16` `19` 1 AbcdefghijAbcdef AbcdefghijAbcdefghi - `15` `22` `39` `10` `46` `5` - - 1 Abcde~ Abcde~ Abcdef~ Abcd~ Abcde~ Abcde - `30` `8` `26` `37` - - 1 Abcdefghij~ Abcde~ Abcdefgh~ Abcdefghij~ + `15` `22` `39` `10` + + 1 AbcdefghijAbcde Abcdefg~ Abcdefgh~ Abcd~ + `46` `5` `30` `8` `26` `37` + + 1 Abcdef~ Abcde Abcdef~ Abcd~ Abcd~ Abcde~ Code options(width = 39) colonnade(df_str[c(40L, 17L, 13L, 23L, 22L, 2L, 18L, 3L, 29L, 45L, 14L, 19L, @@ -207,21 +207,21 @@ `41` 1 AbcdefghijAbcdefghijAbcdefghijAbcdef~ - `21` `4` `25` `38` `48` `9` - - 1 Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abcd~ - `24` `26` `39` `20` `36` `42` + `21` `4` `25` + + 1 AbcdefghijAbcdefghijA Abcd Abcdefgh~ + `38` `48` `9` `24` `26` `39` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `16` `6` `11` `7` `12` `1` + `20` `36` `42` `16` `6` `11` - 1 Abcde~ Abcdef Abcd~ Abcd~ Abcd~ A - `46` `15` `5` `8` `50` `32` + 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `7` `12` `1` `46` `15` `5` + + 1 Abcde~ Abcd~ A Abcde~ Abcd~ Abcde + `8` `50` `32` `30` `49` `28` - 1 Abcde~ Abcde~ Abcde Abcd~ Abcd~ Abcd~ - `30` `49` `28` - - 1 AbcdefghijA~ AbcdefghijAb~ Abcdefghi~ + 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 32) colonnade(df_str[c(11L, 36L, 17L, 14L, 31L, 35L, 23L, 13L, 6L, 44L, 45L, 22L, @@ -259,30 +259,30 @@ `45` 1 AbcdefghijAbcdefghijAbcdefghi~ - `22` `21` `18` `33` `10` - - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `43` `2` `46` `34` `3` - - 1 Abcde~ Ab Abcd~ Abcd~ Abc - `19` `1` `38` `9` `37` + `22` `21` `18` `33` + + 1 Abcdef~ Abcdef~ Abcde~ Abcdef~ + `10` `43` `2` `46` `34` - 1 Abcde~ A Abcd~ Abcd~ Abcd~ - `5` `8` `25` `49` `27` + 1 Abcde~ Abcd~ Ab Abcd~ Abcd~ + `3` `19` `1` `38` `9` - 1 Abcde Abcde~ Abcd~ Abcd~ Abcd~ - `29` `15` `39` `24` `40` + 1 Abc Abcde~ A Abcd~ Abcd~ + `37` `5` `8` `25` `49` + + 1 Abcde~ Abcde Abcd~ Abcd~ Abcd~ + `27` `29` `15` `39` `24` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `48` `26` `47` `42` `41` + `40` `48` `26` `47` `42` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `12` `28` `30` `7` `16` + `41` `12` `28` `30` `7` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `4` `50` `20` `32` - - 1 Abcd Abcdefg~ Abcdef~ Abcdef~ + `16` `4` `50` `20` `32` + + 1 Abcde~ Abcd Abcd~ Abcd~ Abcd~ Code options(width = 35) colonnade(df_str[c(18L, 46L, 11L, 43L, 31L, 47L, 48L, 44L, 50L, 15L, 28L, 33L, @@ -377,18 +377,18 @@ `34` 1 AbcdefghijAbcdefghijAbcdefghijAb~ - `8` `24` `29` `1` `12` - - 1 Abcde~ Abcdef~ Abcde~ A Abcd~ - `2` `20` `17` `35` `5` - - 1 Ab Abcdef~ Abcd~ Abcdef~ Abcde - `19` `30` `7` `26` `42` - - 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcde~ - `41` `39` `10` - - 1 AbcdefghijAb~ AbcdefghijA~ Abcde~ + `8` `24` `29` + + 1 Abcdefgh Abcdefghij~ AbcdefghijA~ + `1` `12` `2` `20` `17` + + 1 A Abcde~ Ab Abcdef~ Abcde~ + `35` `5` `19` `30` `7` + + 1 Abcdef~ Abcde Abcde~ Abcde~ Abcd~ + `26` `42` `41` `39` `10` + + 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Code options(width = 32) colonnade(df_str[c(43L, 1L, 3L, 15L, 28L, 12L, 46L, 34L, 31L, 7L, 11L, 4L, 44L, @@ -411,33 +411,33 @@ `46` 1 AbcdefghijAbcdefghijAbcdefghi~ - `34` `31` `7` `11` `4` - - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd - `44` `8` `9` `5` `36` + `34` `31` `7` + + 1 AbcdefghijA~ Abcdefghij~ Abcd~ + `11` `4` `44` `8` `9` - 1 Abcde~ Abcd~ Abcd~ Abcde Abcd~ - `22` `17` `39` `18` `45` + 1 Abcde~ Abcd Abcd~ Abcd~ Abcd~ + `5` `36` `22` `17` `39` + + 1 Abcde Abcde~ Abcd~ Abcd~ Abcd~ + `18` `45` `37` `13` `29` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `37` `13` `29` `6` `30` + `6` `30` `16` `20` `10` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `16` `20` `10` `19` `26` + 1 Abcdef Abcd~ Abcd~ Abcd~ Abcd~ + `19` `26` `33` `40` `35` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `33` `40` `35` `48` `38` + `48` `38` `25` `2` `47` - 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `25` `2` `47` `42` `41` + 1 Abcde~ Abcd~ Abcd~ Ab Abcd~ + `42` `41` `27` `14` `21` - 1 Abcde~ Ab Abcd~ Abcd~ Abcd~ - `27` `14` `21` `24` `50` + 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ + `24` `50` `49` `23` `32` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `49` `23` `32` - - 1 Abcdefghi~ Abcdefgh~ Abcdefgh~ Code options(width = 31) colonnade(df_str[c(37L, 46L, 21L, 3L, 16L, 39L, 34L, 33L, 10L, 17L, 19L, 36L, @@ -553,12 +553,12 @@ `20` 1 AbcdefghijAbcdefghij - `27` `43` `8` `47` `4` - - 1 Abcd~ Abcd~ Abcd~ Abcd~ Abcd - `48` `24` `26` `22` + `27` `43` `8` `47` 1 Abcdef~ Abcdef~ Abcde~ Abcde~ + `4` `48` `24` `26` `22` + + 1 Abcd Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 58) colonnade(df_str[c(31L, 39L, 40L, 30L, 10L, 21L, 9L, 16L, 46L, 25L, 15L, 24L, @@ -581,21 +581,21 @@ `21` `9` `16` 1 AbcdefghijAbcdefghijA Abcdefghi AbcdefghijAbcdef - `46` `25` `15` `24` `3` `50` `35` `1` `12` - - 1 Abcde~ Abcde~ Abcde~ Abcd~ Abc Abcd~ Abcd~ A Abcd~ - `34` `48` `4` `29` `23` `37` `36` `28` `43` - - 1 Abcde~ Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `11` `17` `32` `8` `41` `13` `44` `7` `38` + `46` `25` `15` `24` `3` `50` + + 1 AbcdefghijA~ Abcdefgh~ Abcde~ Abcdef~ Abc AbcdefghijA~ + `35` `1` `12` `34` `48` `4` `29` `23` `37` + + 1 Abcde~ A Abcde~ Abcde~ Abcd~ Abcd Abcd~ Abcd~ Abcd~ + `36` `28` `43` `11` `17` `32` `8` `41` `13` 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `26` `33` `20` `19` `2` `18` `49` `27` `47` + `44` `7` `38` `26` `33` `20` `19` `2` `18` - 1 Abcde~ Abcde~ Abcde~ Abcd~ Ab Abcd~ Abcd~ Abcd~ Abcd~ - `22` `14` `6` `5` `45` `42` - - 1 Abcdefgh~ Abcdef~ Abcd~ Abcde AbcdefghijAb~ AbcdefghijA~ + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Ab Abcd~ + `49` `27` `47` `22` `14` `6` `5` `45` `42` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcde Abcd~ Abcd~ Code options(width = 57) colonnade(df_str[c(43L, 21L, 41L, 48L, 22L, 25L, 2L, 8L, 1L, 24L, 6L, 39L, 38L, @@ -648,18 +648,18 @@ `26` 1 AbcdefghijAbcdefghijAbcdef - `44` `11` `46` `28` `7` `18` `50` `16` `29` + `44` + + 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcd + `11` `46` `28` `7` `18` `50` `16` `29` `30` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `30` `4` `23` `17` `40` `33` `14` `27` `19` + `4` `23` `17` `40` `33` `14` `27` `19` `34` + + 1 Abcd Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ + `32` `3` `37` `15` `10` `5` `35` `31` `42` - 1 Abcde~ Abcd Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ - `34` `32` `3` `37` `15` `10` `5` `35` `31` - - 1 Abcde~ Abcde~ Abc Abcd~ Abcd~ Abcd~ Abcde Abcd~ Abcd~ - `42` - - 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAb + 1 Abcde~ Abc Abcde~ Abcd~ Abcd~ Abcde Abcd~ Abcd~ Abcd~ Code options(width = 33) colonnade(df_str[c(40L, 6L, 25L, 5L, 26L, 17L, 19L, 2L, 11L, 34L, 45L, 24L, 22L, @@ -769,15 +769,15 @@ `50` 1 AbcdefghijAbcdefghijAbcdefghij~ - `10` `9` `8` `47` `31` + `10` `9` `8` + + 1 Abcdefghij Abcdefghi Abcdefgh + `47` `31` `14` `38` `33` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `14` `38` `33` `32` `43` + `32` `43` `23` `15` `37` 1 Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ - `23` `15` `37` - - 1 Abcdefghi~ Abcdefg~ Abcdefghij~ Code options(width = 32) colonnade(df_str[c(43L, 23L, 22L, 11L, 6L, 26L, 48L, 17L, 7L, 42L, 36L, 21L, @@ -842,24 +842,24 @@ `49` 1 AbcdefghijAbcdefghijAbcdefghi~ - `47` `30` `31` `25` `28` + `47` `30` + + 1 AbcdefghijAbcd~ AbcdefghijAbc~ + `31` `25` `28` `46` `12` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `46` `12` `32` `39` `24` + `32` `39` `24` `10` `45` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `10` `45` `5` `37` `14` - - 1 Abcde~ Abcd~ Abcde Abcd~ Abcd~ - `40` `20` `41` `44` `33` + `5` `37` `14` `40` `20` + + 1 Abcde Abcde~ Abcd~ Abcd~ Abcd~ + `41` `44` `33` `18` `38` 1 Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `18` `38` `3` `1` `34` - - 1 Abcde~ Abcd~ Abc A Abcd~ - `16` `9` - - 1 AbcdefghijAbcdef Abcdefghi + `3` `1` `34` `16` `9` + + 1 Abc A Abcde~ Abcd~ Abcd~ Code options(width = 46) colonnade(df_str[c(5L, 24L, 43L, 46L, 35L, 39L, 18L, 26L, 8L, 27L, 2L, 50L, 6L, @@ -957,12 +957,12 @@ `48` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbc~ - `20` `21` `44` `25` `10` `22` `30` + `20` `21` + + 1 AbcdefghijAbcdefghij AbcdefghijAbcdefghijA + `44` `25` `10` `22` `30` `40` `17` 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `40` `17` - - 1 AbcdefghijAbcdefghijAbcdefghi~ AbcdefghijAb~ Code options(width = 52) colonnade(df_str[c(7L, 44L, 19L, 21L, 18L, 35L, 23L, 50L, 33L, 37L, 25L, 26L, @@ -1021,18 +1021,18 @@ `45` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcde - `6` `4` `11` `24` `43` `32` `3` `38` - - 1 Abcdef Abcd Abcde~ Abcde~ Abcd~ Abcd~ Abc Abcd~ - `5` `49` `27` `17` `8` `22` `40` `12` - - 1 Abcde Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `15` `1` `28` `31` `29` `13` `48` `34` - - 1 Abcde~ A Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ - `36` `30` `20` `16` `46` - - 1 Abcdefghij~ Abcdefghi~ Abcdef~ Abcde~ AbcdefghijA~ + `6` `4` `11` `24` `43` + + 1 Abcdef Abcd AbcdefghijA Abcdefghi~ AbcdefghijAbc~ + `32` `3` `38` `5` `49` `27` `17` `8` + + 1 Abcde~ Abc Abcde~ Abcde Abcde~ Abcd~ Abcd~ Abcd~ + `22` `40` `12` `15` `1` `28` `31` `29` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ A Abcd~ Abcd~ Abcd~ + `13` `48` `34` `36` `30` `20` `16` `46` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ Abcd~ Abcd~ Abcd~ Code options(width = 35) colonnade(df_str[c(38L, 18L, 23L, 36L, 35L, 20L, 44L, 19L, 13L, 41L, 31L, 7L, @@ -1046,36 +1046,36 @@ `18` 1 AbcdefghijAbcdefgh - `23` `36` `35` `20` `44` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `19` `13` `41` `31` `7` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `11` `29` `2` `14` `26` + `23` `36` `35` + + 1 Abcdefgh~ Abcdefghij~ Abcdefghij~ + `20` `44` `19` `13` `41` - 1 Abcde~ Abcdef~ Ab Abcd~ Abcde~ - `46` `40` `45` `9` `34` + 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcde~ + `31` `7` `11` `29` `2` + + 1 Abcdef~ Abcde~ Abcd~ Abcde~ Ab + `14` `26` `46` `40` `45` 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `33` `22` `1` `17` `28` - - 1 Abcdef~ Abcde~ A Abcd~ Abcde~ - `10` `21` `30` `47` `49` - - 1 Abcde~ Abcde~ Abcd~ Abcde~ Abcde~ - `6` `12` `4` `25` `32` - - 1 Abcdef Abcde~ Abcd Abcde~ Abcde~ - `15` `43` `24` `48` `3` + `9` `34` `33` `22` `1` + + 1 Abcde~ Abcdef~ Abcde~ Abcd~ A + `17` `28` `10` `21` `30` + + 1 Abcde~ Abcdef~ Abcd~ Abcd~ Abcde~ + `47` `49` `6` `12` `4` + + 1 Abcdef~ Abcdef~ Abcd~ Abcd~ Abcd + `25` `32` `15` `43` `24` - 1 Abcde~ Abcdef~ Abcd~ Abcde~ Abc - `37` `50` `42` `39` `16` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ - `8` `27` `5` - - 1 Abcdef~ AbcdefghijAbcdefgh~ Abcde + 1 Abcde~ Abcdef~ Abcd~ Abcde~ Abcd~ + `48` `3` `37` `50` `42` + + 1 Abcde~ Abc Abcde~ Abcde~ Abcde~ + `39` `16` `8` `27` `5` + + 1 Abcdef~ Abcde~ Abcd~ Abcde~ Abcde Code options(width = 41) colonnade(df_str[c(22L, 9L, 11L, 26L, 19L, 16L, 32L, 25L, 1L, 30L, 31L, 6L, 24L, @@ -1146,16 +1146,16 @@ `38` 1 AbcdefghijAbcdefghijAbcdefghijAbcdefgh - `36` `48` `34` `3` `8` `4` - - 1 Abcdef~ Abcde~ Abcde~ Abc Abcd~ Abcd - `27` `42` `44` `33` `45` `18` - - 1 Abcde~ Abcde~ Abcde~ Abcde~ Abcd~ Abcd~ - `5` `2` `13` `47` `28` `17` - - 1 Abcde Ab Abcde~ Abcdef~ Abcde~ Abcd~ - `37` `14` `41` `23` - - 1 Abcdefghij~ Abcdef~ Abcdefghi~ Abcdefg~ + `36` `48` `34` `3` + + 1 Abcdefghij~ Abcdefghij~ Abcdefgh~ Abc + `8` `4` `27` `42` `44` `33` + + 1 Abcde~ Abcd Abcde~ Abcde~ Abcde~ Abcd~ + `45` `18` `5` `2` `13` `47` + + 1 Abcdef~ Abcde~ Abcde Ab Abcd~ Abcde~ + `28` `17` `37` `14` `41` `23` + + 1 Abcde~ Abcde~ Abcde~ Abcd~ Abcde~ Abcd~ diff --git a/tests/testthat/_snaps/format_survival.md b/tests/testthat/_snaps/format_survival.md index 6c12394b7..b61c2babf 100644 --- a/tests/testthat/_snaps/format_survival.md +++ b/tests/testthat/_snaps/format_survival.md @@ -4,13 +4,13 @@ pillar(x, width = 20) Output - - 306 - 455 - 1010+ - 210 - 883 - 1022+ + + 306 + 455 + 1010+ + 210 + 883 + 1022+ --- @@ -18,11 +18,11 @@ pillar(x, width = 20) Output - - 306:2 - 455:2 - 1010+ - 210:2 - 883:2 - 1022+ + + 306:2 + 455:2 + 1010+ + 210:2 + 883:2 + 1022+ diff --git a/tests/testthat/_snaps/format_unspecified.md b/tests/testthat/_snaps/format_unspecified.md index 63d1a03aa..050179403 100644 --- a/tests/testthat/_snaps/format_unspecified.md +++ b/tests/testthat/_snaps/format_unspecified.md @@ -4,8 +4,8 @@ pillar(vctrs::unspecified(3), width = 10) Output - - . - . - . + + . + . + . diff --git a/tests/testthat/_snaps/multi.md b/tests/testthat/_snaps/multi.md new file mode 100644 index 000000000..d5fdc5ed5 --- /dev/null +++ b/tests/testthat/_snaps/multi.md @@ -0,0 +1,195 @@ +# colonnade_compute_tiered_col_widths_df() + + Code + colonnade_compute_tiered_col_widths_df(rep(30, 4), rep(15, 4), rep(60, 4)) + Output + id tier width offset_after + 1 1 1 30 30 + 2 2 2 30 30 + 3 3 3 30 30 + 4 4 4 30 30 + Code + colonnade_compute_tiered_col_widths_df(rep(30, 4), rep(15, 4), rep(60, 3)) + Output + id tier width offset_after max_widths + 1 1 1 30 30 30 + 2 2 2 30 30 30 + 3 3 3 30 30 30 + 4 4 3 15 60 30 + Code + colonnade_compute_tiered_col_widths_df(rep(30, 4), rep(15, 4), rep(60, 2)) + Output + id tier width offset_after max_widths + 1 1 1 30 30 30 + 2 2 2 15 28 30 + 3 3 2 15 44 30 + 4 4 2 15 60 30 + Code + colonnade_compute_tiered_col_widths_df(rep(30, 5), rep(15, 5), rep(60, 3)) + Output + id tier width offset_after max_widths + 1 1 1 30 30 30 + 2 2 2 30 30 30 + 3 3 3 15 28 30 + 4 4 3 15 44 30 + 5 5 3 15 60 30 + Code + colonnade_compute_tiered_col_widths_df(rep(30, 5), rep(15, 5), rep(60, 4)) + Output + id tier width offset_after max_widths + 1 1 1 30 30 30 + 2 2 2 30 30 30 + 3 3 3 30 30 30 + 4 4 4 30 30 30 + 5 5 4 15 60 30 + Code + colonnade_compute_tiered_col_widths_df(rep(30, 10), rep(15, 10), rep(60, 5)) + Output + id tier width offset_after max_widths + 1 1 1 30 30 30 + 2 2 2 30 30 30 + 3 3 3 30 30 30 + 4 4 3 15 60 30 + 5 5 4 15 28 30 + 6 6 4 15 44 30 + 7 7 4 15 60 30 + 8 8 5 15 28 30 + 9 9 5 15 44 30 + 10 10 5 15 60 30 + Code + colonnade_compute_tiered_col_widths_df(c(6, 5, 10), c(5, 5, 10), 21) + Output + id tier width offset_after + 1 1 1 5 5 + 2 2 1 5 11 + 3 3 NA 10 NA + Code + colonnade_compute_tiered_col_widths_df(c(6, 5, 10), c(5, 5, 10), 22) + Output + id tier width offset_after max_widths + 1 1 1 5 5 6 + 2 2 1 5 11 5 + 3 3 1 10 22 10 + Code + colonnade_compute_tiered_col_widths_df(c(6, 5, 10), c(5, 5, 10), 23) + Output + id tier width offset_after + 1 1 1 6 6 + 2 2 1 5 12 + 3 3 1 10 23 + Code + colonnade_compute_tiered_col_widths_df(c(5, 6, 10), c(5, 5, 10), 21) + Output + id tier width offset_after + 1 1 1 5 5 + 2 2 1 5 11 + 3 3 NA 10 NA + Code + colonnade_compute_tiered_col_widths_df(c(5, 6, 10), c(5, 5, 10), 22) + Output + id tier width offset_after max_widths + 1 1 1 5 5 5 + 2 2 1 5 11 6 + 3 3 1 10 22 10 + Code + colonnade_compute_tiered_col_widths_df(c(5, 6, 10), c(5, 5, 10), 23) + Output + id tier width offset_after + 1 1 1 5 5 + 2 2 1 6 12 + 3 3 1 10 23 + +# distribute_pillars() + + Code + distribute_pillars(1:3, 10) + Output + id tier width offset_after + 1 1 1 1 1 + 2 2 1 2 4 + 3 3 1 3 8 + Code + distribute_pillars(1:3, 5) + Output + id tier width offset_after + 1 1 1 1 1 + 2 2 1 2 4 + 3 3 NA 3 NA + Code + distribute_pillars(1:3, c(5, 5)) + Output + id tier width offset_after + 1 1 1 1 1 + 2 2 1 2 4 + 3 3 2 3 3 + Code + distribute_pillars(1:5, 7:9) + Output + id tier width offset_after + 1 1 1 1 1 + 2 2 1 2 4 + 3 3 2 3 3 + 4 4 2 4 8 + 5 5 3 5 5 + Code + distribute_pillars(3:5, 8:10) + Output + id tier width offset_after + 1 1 1 3 3 + 2 2 1 4 8 + 3 3 2 5 5 + Code + distribute_pillars(5:3, 9:8) + Output + id tier width offset_after + 1 1 1 5 5 + 2 2 2 4 4 + 3 3 2 3 8 + +# distribute_pillars_rev() + + Code + distribute_pillars_rev(1:3, 10) + Output + id tier width offset_after + 1 1 1 1 3 + 2 2 1 2 6 + 3 3 1 3 10 + Code + distribute_pillars_rev(1:3, 5) + Output + id tier width offset_after + 1 1 NA 1 5 + 2 2 NA 2 NA + 3 3 1 3 NA + Code + distribute_pillars_rev(1:3, c(5, 5)) + Output + id tier width offset_after + 1 1 1 1 2 + 2 2 1 2 5 + 3 3 2 3 5 + Code + distribute_pillars_rev(1:5, 7:9) + Output + id tier width offset_after + 1 1 1 1 4 + 2 2 1 2 7 + 3 3 2 3 3 + 4 4 2 4 8 + 5 5 3 5 9 + Code + distribute_pillars_rev(3:5, 8:10) + Output + id tier width offset_after + 1 1 2 3 8 + 2 2 3 4 3 + 3 3 3 5 9 + Code + distribute_pillars_rev(5:3, 9:8) + Output + id tier width offset_after + 1 1 1 5 9 + 2 2 2 4 4 + 3 3 2 3 8 + diff --git a/tests/testthat/_snaps/num.md b/tests/testthat/_snaps/num.md index d186864ca..39489c9bf 100644 --- a/tests/testthat/_snaps/num.md +++ b/tests/testthat/_snaps/num.md @@ -115,6 +115,17 @@ 12 1230000000 e-3 1230 e3 1.23 M 13 12300000000 e-3 12300 e3 12.3 M 14 123000000000 e-3 123000 e3 123 M + Code + tibble::tibble(default = num(100 + 1:3 * 0.001), extra1 = num(100 + 1:3 * 0.001, + extra_sigfig = TRUE), extra2 = num(100 + 1:3 * 1e-04, extra_sigfig = TRUE), + extra3 = num(10000 + 1:3 * 1e-05, extra_sigfig = TRUE)) + Output + # A tibble: 3 x 4 + default extra1 extra2 extra3 + + 1 100. 100.001 100.0001 10000.00001 + 2 100. 100.002 100.0002 10000.00002 + 3 100. 100.003 100.0003 10000.00003 # many digits diff --git a/tests/testthat/_snaps/tbl-format-footer.md b/tests/testthat/_snaps/tbl-format-footer.md index 8f91e1b86..f5610e50e 100644 --- a/tests/testthat/_snaps/tbl-format-footer.md +++ b/tests/testthat/_snaps/tbl-format-footer.md @@ -16,12 +16,7 @@ # i , j , # k , l , # m , n , - # o , p , - # q , r , - # s , t , - # u , v , - # w , x , - # y , z  + # o , p , ... # wrapping column names with spaces in the footer @@ -66,17 +61,120 @@ # p , q , r , s , t , u , v , # w , x , y , z , a , b , c , # d , e , f , g , h , i , j , - # k , l.1 , m.1 , n.1 , o.1 , p.1 , - # q.1 , r.1 , s.1 , t.1 , u.1 , v.1 , - # w.1 , x.1 , y.1 , z.1 , a.1 , b.1 , - # c.1 , d.1 , e.1 , f.1 , g.1 , h.1 , - # i.1 , j.1 , k.1 , l.2 , m.2 , n.2 , - # o.2 , p.2 , q.2 , r.2 , s.2 , t.2 , - # u.2 , v.2 , w.2 , x.2 , y.2 , z.2 , - # a.2 , b.2 , c.2 , d.2 , e.2 , f.2 , - # g.2 , h.2 , i.2 , j.2 , k.2 , l.3 , - # m.3 , n.3 , o.3 , p.3 , q.3 , r.3 , - # s.3 , t.3 , u.3 , v.3 , w.3 , x.3 , - # y.3 , z.3 , a.3 , b.3 , c.3 , d.3 , - # e.3 , f.3 , g.3 , ... + # k , l , m , n , o , p , q , + # r , s , t , u , v , w , x , + # y , z , a , b , c , d , ... + +# max_footer_lines option + + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl(""))) + Output + + # ... with 39 more variables: bg , ah , bh , ai , bi , + # aj , bj , ak , bk , al , bl , am , + # bm , an , bn , ao , bo , ap , bp , + # aq , bq , ar , br , as , bs , at , + # bt , au , bu , av , bv , aw , bw , + # ax , bx , ay , by , az , bz + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl("prefix_"))) + Output + + # ... with 45 more variables: prefix_bd , prefix_ae , + # prefix_be , prefix_af , prefix_bf , prefix_ag , + # prefix_bg , prefix_ah , prefix_bh , prefix_ai , + # prefix_bi , prefix_aj , prefix_bj , prefix_ak , + # prefix_bk , prefix_al , prefix_bl , prefix_am , + # prefix_bm , prefix_an , prefix_bn , prefix_ao , + # prefix_bo , prefix_ap , prefix_bp , prefix_aq , ... + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl("a_very_long_prefix_"))) + Output + + # ... with 48 more variables: a_very_long_prefix_ac , + # a_very_long_prefix_bc , a_very_long_prefix_ad , + # a_very_long_prefix_bd , a_very_long_prefix_ae , + # a_very_long_prefix_be , a_very_long_prefix_af , + # a_very_long_prefix_bf , a_very_long_prefix_ag , + # a_very_long_prefix_bg , a_very_long_prefix_ah , + # a_very_long_prefix_bh , a_very_long_prefix_ai , ... + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl(""), max_footer_lines = 3)) + Output + + # ... with 39 more variables: bg , ah , bh , ai , bi , + # aj , bj , ak , bk , al , bl , am , + # bm , an , bn , ao , bo , ap , bp , ... + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl("prefix_"), max_footer_lines = 3)) + Output + + # ... with 45 more variables: prefix_bd , prefix_ae , + # prefix_be , prefix_af , prefix_bf , prefix_ag , + # prefix_bg , prefix_ah , prefix_bh , prefix_ai , ... + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl("a_very_long_prefix_"), + max_footer_lines = 3)) + Output + + # ... with 48 more variables: a_very_long_prefix_ac , + # a_very_long_prefix_bc , a_very_long_prefix_ad , + # a_very_long_prefix_bd , a_very_long_prefix_ae , ... + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl(""), max_footer_lines = Inf)) + Output + + # ... with 39 more variables: bg , ah , bh , ai , bi , + # aj , bj , ak , bk , al , bl , am , + # bm , an , bn , ao , bo , ap , bp , + # aq , bq , ar , br , as , bs , at , + # bt , au , bu , av , bv , aw , bw , + # ax , bx , ay , by , az , bz + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl("prefix_"), max_footer_lines = Inf)) + Output + + # ... with 45 more variables: prefix_bd , prefix_ae , + # prefix_be , prefix_af , prefix_bf , prefix_ag , + # prefix_bg , prefix_ah , prefix_bh , prefix_ai , + # prefix_bi , prefix_aj , prefix_bj , prefix_ak , + # prefix_bk , prefix_al , prefix_bl , prefix_am , + # prefix_bm , prefix_an , prefix_bn , prefix_ao , + # prefix_bo , prefix_ap , prefix_bp , prefix_aq , + # prefix_bq , prefix_ar , prefix_br , prefix_as , + # prefix_bs , prefix_at , prefix_bt , prefix_au , + # prefix_bu , prefix_av , prefix_bv , prefix_aw , + # prefix_bw , prefix_ax , prefix_bx , prefix_ay , + # prefix_by , prefix_az , prefix_bz + Code + tbl_format_footer(tbl_format_setup(new_footer_tbl("a_very_long_prefix_"), + max_footer_lines = Inf)) + Output + + # ... with 48 more variables: a_very_long_prefix_ac , + # a_very_long_prefix_bc , a_very_long_prefix_ad , + # a_very_long_prefix_bd , a_very_long_prefix_ae , + # a_very_long_prefix_be , a_very_long_prefix_af , + # a_very_long_prefix_bf , a_very_long_prefix_ag , + # a_very_long_prefix_bg , a_very_long_prefix_ah , + # a_very_long_prefix_bh , a_very_long_prefix_ai , + # a_very_long_prefix_bi , a_very_long_prefix_aj , + # a_very_long_prefix_bj , a_very_long_prefix_ak , + # a_very_long_prefix_bk , a_very_long_prefix_al , + # a_very_long_prefix_bl , a_very_long_prefix_am , + # a_very_long_prefix_bm , a_very_long_prefix_an , + # a_very_long_prefix_bn , a_very_long_prefix_ao , + # a_very_long_prefix_bo , a_very_long_prefix_ap , + # a_very_long_prefix_bp , a_very_long_prefix_aq , + # a_very_long_prefix_bq , a_very_long_prefix_ar , + # a_very_long_prefix_br , a_very_long_prefix_as , + # a_very_long_prefix_bs , a_very_long_prefix_at , + # a_very_long_prefix_bt , a_very_long_prefix_au , + # a_very_long_prefix_bu , a_very_long_prefix_av , + # a_very_long_prefix_bv , a_very_long_prefix_aw , + # a_very_long_prefix_bw , a_very_long_prefix_ax , + # a_very_long_prefix_bx , a_very_long_prefix_ay , + # a_very_long_prefix_by , a_very_long_prefix_az , + # a_very_long_prefix_bz diff --git a/tests/testthat/_snaps/tbl-format.md b/tests/testthat/_snaps/tbl-format.md index 89b9dcdde..eee0cc52f 100644 --- a/tests/testthat/_snaps/tbl-format.md +++ b/tests/testthat/_snaps/tbl-format.md @@ -143,6 +143,64 @@ 30 19.7 6 145 175 3.62 2.77 15.5 0 1 5 6 31 15 8 301 335 3.54 3.57 14.6 0 1 5 8 32 21.4 4 121 109 4.11 2.78 18.6 1 1 4 2 + Code + print(as_tbl(mtcars), width = 40, n_extra = 1) + Warning + The `n_extra` argument of `print()` is deprecated as of pillar 1.6.2. + Please use the `max_extra_cols` argument instead. + Output + # A data frame: 32 x 11 + mpg cyl disp hp drat wt + * + 1 21 6 160 110 3.9 2.62 + 2 21 6 160 110 3.9 2.88 + 3 22.8 4 108 93 3.85 2.32 + 4 21.4 6 258 110 3.08 3.22 + 5 18.7 8 360 175 3.15 3.44 + 6 18.1 6 225 105 2.76 3.46 + 7 14.3 8 360 245 3.21 3.57 + 8 24.4 4 147. 62 3.69 3.19 + 9 22.8 4 141. 95 3.92 3.15 + 10 19.2 6 168. 123 3.92 3.44 + # ... with 22 more rows, and 5 more + # variable: qsec , ... + Code + print(as_tbl(mtcars), width = 40, max_extra_cols = 1) + Output + # A data frame: 32 x 11 + mpg cyl disp hp drat wt + * + 1 21 6 160 110 3.9 2.62 + 2 21 6 160 110 3.9 2.88 + 3 22.8 4 108 93 3.85 2.32 + 4 21.4 6 258 110 3.08 3.22 + 5 18.7 8 360 175 3.15 3.44 + 6 18.1 6 225 105 2.76 3.46 + 7 14.3 8 360 245 3.21 3.57 + 8 24.4 4 147. 62 3.69 3.19 + 9 22.8 4 141. 95 3.92 3.15 + 10 19.2 6 168. 123 3.92 3.44 + # ... with 22 more rows, and 5 more + # variable: qsec , ... + Code + print(as_tbl(mtcars), width = 30, max_footer_lines = 3) + Output + # A data frame: 32 x 11 + mpg cyl disp hp + * + 1 21 6 160 110 + 2 21 6 160 110 + 3 22.8 4 108 93 + 4 21.4 6 258 110 + 5 18.7 8 360 175 + 6 18.1 6 225 105 + 7 14.3 8 360 245 + 8 24.4 4 147. 62 + 9 22.8 4 141. 95 + 10 19.2 6 168. 123 + # ... with 22 more rows, and + # 7 more variables: + # drat , wt , ... Code rlang::with_options(tibble.print_min = 5, as_tbl(mtcars)) Output diff --git a/tests/testthat/_snaps/type_sum.md b/tests/testthat/_snaps/type_sum.md index 9d593da0c..956f1b015 100644 --- a/tests/testthat/_snaps/type_sum.md +++ b/tests/testthat/_snaps/type_sum.md @@ -14,9 +14,9 @@ new_tbl(new_tbl(list(foo = foo, bar = bar))) Output # A data frame: 3 x 2 - foo bar - AsIs SC - 1 2011 2011 - 2 2012 2012 - 3 2013 2013 + foo bar + AsIs SC + 1 2011 2011 + 2 2012 2012 + 3 2013 2013 diff --git a/tests/testthat/helper-output.R b/tests/testthat/helper-output.R index 7e8c9c9f0..6a9e4a3ec 100644 --- a/tests/testthat/helper-output.R +++ b/tests/testthat/helper-output.R @@ -3,7 +3,7 @@ show_output_in_terminal <- function() { } # A data frame with all major types -df_all <- new_tbl(list( +df_all <- pillar:::new_tbl(list( a = c(1, 2.5, NA), b = c(1:2, NA), c = c(T, F, NA), @@ -17,7 +17,7 @@ df_all <- new_tbl(list( # A data frame with strings of varying lengths long_str <- strrep("Abcdefghij", 5) -df_str <- map(rlang::set_names(1:50), function(i) substr(long_str, 1, i)) +df_str <- pillar:::map(rlang::set_names(1:50), function(i) substr(long_str, 1, i)) #' `add_special()` is not exported, and used only for initializing default #' values to `expect_pillar_output()`. diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 50bd3d55c..a622aac94 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -6,4 +6,4 @@ rlang::with_options( ) # Override .Rprofile -options(pillar.bold = FALSE) +walk(pillar_options, do.call, list(NULL)) diff --git a/tests/testthat/test-ctl_colonnade.R b/tests/testthat/test-ctl_colonnade.R index 14bc21b68..c40765a13 100644 --- a/tests/testthat/test-ctl_colonnade.R +++ b/tests/testthat/test-ctl_colonnade.R @@ -159,3 +159,45 @@ test_that("matrix columns (empty)", { ) }) }) + +test_that("filling unused width (#331)", { + new_foo <- function(x = character()) { + vctrs::vec_assert(x, character()) + vctrs::new_vctr(x, class = "foo") + } + + data <- new_tbl(list( + month = month.name[1], + sentences = new_foo(paste(letters, collapse = " ")), + blah = paste(LETTERS, collapse = " ") + )) + + pillar_shaft.foo <- function(x, ...) { + full <- format(x) + trunc <- format(paste0(substr(x, 1, 7), cli::symbol$continue)) + pillar::new_pillar_shaft( + list(full = full, trunc = trunc), + width = pillar::get_max_extent(full), + min_width = pillar::get_max_extent(trunc), + class = "pillar_shaft_foo" + ) + } + + format.pillar_shaft_foo <- function(x, width, ...) { + if (pillar::get_max_extent(x$full) <= width) { + ornament <- x$full + } else { + ornament <- x$trunc + } + + pillar::new_ornament(ornament, align = "left") + } + + local_methods(pillar_shaft.foo = pillar_shaft.foo, format.pillar_shaft_foo = format.pillar_shaft_foo) + + expect_snapshot({ + data + options(width = 60) + print(data) + }) +}) diff --git a/tests/testthat/test-ctl_colonnade_1.R b/tests/testthat/test-ctl_colonnade_1.R index 041b3621c..c7390a253 100644 --- a/tests/testthat/test-ctl_colonnade_1.R +++ b/tests/testthat/test-ctl_colonnade_1.R @@ -4,36 +4,35 @@ test_that("strings with varying widths", { # Generated by data-raw/create-chr-tests.R # nolint start expect_snapshot({ - options(width = 59) - ctl_colonnade(df_str[c(12L, 33L, 36L, 7L, 41L, 3L, 18L, 23L, 13L, 44L, 14L, 16L, 25L, 21L, 19L, 45L, 43L, 29L, 1L, 30L, 22L, 27L, 15L, 47L, 28L, 31L, 10L, 50L, 4L, 40L, 42L, 8L, 6L, 9L, 24L, 48L, 38L, 37L, 34L, 49L, 46L, 2L, 32L, 35L, 39L, 11L, 17L, 5L, 26L, 20L)], width = 1382) - options(width = 54) - ctl_colonnade(df_str[c(40L, 28L, 7L, 16L, 48L, 6L, 21L, 1L, 20L, 17L, 47L, 45L, 29L, 41L, 49L, 34L, 4L, 39L, 18L, 36L, 26L, 38L, 10L, 8L, 5L, 15L, 44L, 24L, 46L, 14L, 25L, 27L, 3L, 37L, 35L, 12L, 9L, 13L, 22L, 33L, 42L, 11L, 19L, 50L, 23L, 30L, 32L, 2L, 43L, 31L)], width = 837) - options(width = 32) - ctl_colonnade(df_str[c(47L, 42L, 4L, 46L, 9L, 34L, 19L, 39L, 8L, 32L, 36L, 12L, 29L, 5L, 15L, 11L, 31L, 27L, 33L, 28L, 43L, 6L, 13L, 22L, 14L, 16L, 35L, 50L, 38L, 7L, 23L, 45L, 40L, 3L, 2L, 24L, 41L, 10L, 30L, 25L, 17L, 26L, 48L, 37L, 49L, 1L, 18L, 21L, 44L, 20L)], width = 455) - options(width = 55) - ctl_colonnade(df_str[c(41L, 4L, 25L, 31L, 8L, 22L, 19L, 10L, 29L, 21L, 34L, 5L, 26L, 36L, 47L, 46L, 2L, 24L, 27L, 39L, 28L, 43L, 32L, 30L, 48L, 44L, 6L, 20L, 13L, 15L, 18L, 42L, 9L, 12L, 37L, 45L, 16L, 40L, 11L, 14L, 38L, 1L, 7L, 3L, 23L, 35L, 50L, 17L, 49L, 33L)], width = 855) - options(width = 54) - ctl_colonnade(df_str[c(27L, 22L, 9L, 23L, 16L, 19L, 25L, 31L, 44L, 1L, 28L, 46L, 12L, 20L, 43L, 37L, 5L, 2L, 18L, 41L, 26L, 33L, 11L, 49L, 24L, 35L, 4L, 47L, 30L, 7L, 34L, 3L, 32L, 42L, 10L, 45L, 38L, 39L, 48L, 14L, 6L, 17L, 36L, 50L, 40L, 13L, 8L, 21L, 15L, 29L)], width = 552) - options(width = 49) - ctl_colonnade(df_str[c(32L, 24L, 18L, 25L, 26L, 13L, 33L, 2L, 50L, 38L, 37L, 16L, 27L, 9L, 28L, 49L, 34L, 15L, 17L, 35L, 22L, 47L, 3L, 21L, 23L, 41L, 5L, 1L, 14L, 46L, 30L, 31L, 44L, 4L, 7L, 40L, 43L, 12L, 29L, 8L, 36L, 45L, 11L, 20L, 10L, 6L, 19L, 48L, 39L, 42L)], width = 1031) - options(width = 38) - ctl_colonnade(df_str[c(44L, 34L, 49L, 9L, 15L, 16L, 1L, 10L, 40L, 29L, 26L, 22L, 4L, 43L, 20L, 17L, 46L, 33L, 35L, 32L, 2L, 12L, 8L, 37L, 23L, 39L, 7L, 18L, 36L, 42L, 6L, 30L, 19L, 25L, 5L, 21L, 47L, 50L, 28L, 11L, 31L, 14L, 24L, 27L, 45L, 41L, 38L, 3L, 13L, 48L)], width = 429) - options(width = 54) - ctl_colonnade(df_str[c(21L, 26L, 8L, 22L, 41L, 24L, 13L, 5L, 47L, 37L, 4L, 42L, 19L, 34L, 11L, 43L, 38L, 3L, 33L, 20L, 31L, 2L, 18L, 48L, 27L, 44L, 9L, 35L, 30L, 6L, 49L, 10L, 1L, 16L, 46L, 29L, 12L, 14L, 45L, 36L, 15L, 39L, 50L, 23L, 17L, 28L, 7L, 32L, 40L, 25L)], width = 633) - options(width = 39) - ctl_colonnade(df_str[c(23L, 49L, 13L, 37L, 3L, 25L, 36L, 4L, 9L, 7L, 27L, 48L, 12L, 10L, 50L, 14L, 38L, 39L, 46L, 22L, 28L, 8L, 21L, 44L, 32L, 40L, 31L, 1L, 29L, 34L, 35L, 33L, 19L, 15L, 41L, 20L, 47L, 18L, 16L, 45L, 6L, 5L, 24L, 26L, 43L, 11L, 42L, 30L, 17L, 2L)], width = 1496) - options(width = 31) - ctl_colonnade(df_str[c(45L, 14L, 49L, 24L, 22L, 31L, 42L, 18L, 16L, 47L, 25L, 4L, 37L, 8L, 26L, 21L, 50L, 5L, 41L, 30L, 2L, 33L, 34L, 3L, 44L, 19L, 43L, 6L, 32L, 29L, 20L, 1L, 13L, 11L, 40L, 12L, 48L, 23L, 9L, 15L, 46L, 36L, 27L, 35L, 28L, 10L, 7L, 39L, 17L, 38L)], width = 493) - options(width = 52) - ctl_colonnade(df_str[c(38L, 46L, 17L, 11L, 24L, 18L, 16L, 39L, 50L, 42L, 6L, 13L, 37L, 29L, 41L, 47L, 9L, 33L, 44L, 31L, 45L, 36L, 28L, 5L, 10L, 30L, 20L, 1L, 14L, 43L, 49L, 23L, 26L, 21L, 32L, 19L, 34L, 15L, 48L, 4L, 7L, 35L, 40L, 8L, 22L, 3L, 25L, 12L, 27L, 2L)], width = 1130) - options(width = 58) - ctl_colonnade(df_str[c(17L, 28L, 29L, 27L, 20L, 31L, 43L, 30L, 32L, 48L, 10L, 50L, 13L, 12L, 36L, 21L, 46L, 33L, 25L, 35L, 1L, 5L, 16L, 34L, 18L, 42L, 3L, 11L, 40L, 26L, 37L, 7L, 39L, 6L, 4L, 19L, 8L, 45L, 14L, 24L, 23L, 2L, 47L, 9L, 49L, 41L, 38L, 22L, 44L, 15L)], width = 1310) - options(width = 47) - ctl_colonnade(df_str[c(1L, 26L, 20L, 12L, 49L, 16L, 24L, 4L, 15L, 47L, 8L, 11L, 14L, 50L, 17L, 2L, 44L, 30L, 36L, 45L, 25L, 38L, 18L, 29L, 5L, 13L, 3L, 23L, 48L, 40L, 34L, 22L, 39L, 33L, 27L, 7L, 19L, 10L, 37L, 6L, 35L, 46L, 31L, 41L, 43L, 28L, 42L, 32L, 21L, 9L)], width = 484) - options(width = 55) - ctl_colonnade(df_str[c(6L, 49L, 26L, 45L, 25L, 15L, 31L, 20L, 21L, 44L, 23L, 48L, 37L, 36L, 5L, 43L, 11L, 14L, 13L, 39L, 16L, 12L, 4L, 18L, 42L, 3L, 10L, 28L, 40L, 24L, 29L, 17L, 35L, 47L, 2L, 38L, 34L, 9L, 7L, 8L, 50L, 33L, 32L, 27L, 46L, 19L, 22L, 41L, 30L, 1L)], width = 779) - options(width = 46) - ctl_colonnade(df_str[c(38L, 42L, 41L, 10L, 40L, 11L, 27L, 9L, 17L, 37L, 46L, 13L, 36L, 18L, 31L, 20L, 39L, 12L, 44L, 33L, 50L, 34L, 26L, 32L, 23L, 30L, 29L, 21L, 4L, 49L, 19L, 25L, 3L, 6L, 15L, 14L, 43L, 48L, 8L, 22L, 1L, 2L, 45L, 35L, 16L, 5L, 47L, 28L, 24L, 7L)], width = 694) - }) + ctl_colonnade(df_str[c(12L, 33L, 36L, 7L, 41L, 3L, 18L, 23L, 13L, 44L, 14L, 16L, 25L, 21L, 19L, 45L, 43L, 29L, 1L, 30L, 22L, 27L, 15L, 47L, 28L, 31L, 10L, 50L, 4L, 40L, 42L, 8L, 6L, 9L, 24L, 48L, 38L, 37L, 34L, 49L, 46L, 2L, 32L, 35L, 39L, 11L, 17L, 5L, 26L, 20L)], width = { options(width = 59); 1382 }) + + ctl_colonnade(df_str[c(40L, 28L, 7L, 16L, 48L, 6L, 21L, 1L, 20L, 17L, 47L, 45L, 29L, 41L, 49L, 34L, 4L, 39L, 18L, 36L, 26L, 38L, 10L, 8L, 5L, 15L, 44L, 24L, 46L, 14L, 25L, 27L, 3L, 37L, 35L, 12L, 9L, 13L, 22L, 33L, 42L, 11L, 19L, 50L, 23L, 30L, 32L, 2L, 43L, 31L)], width = { options(width = 54); 837 }) + + ctl_colonnade(df_str[c(47L, 42L, 4L, 46L, 9L, 34L, 19L, 39L, 8L, 32L, 36L, 12L, 29L, 5L, 15L, 11L, 31L, 27L, 33L, 28L, 43L, 6L, 13L, 22L, 14L, 16L, 35L, 50L, 38L, 7L, 23L, 45L, 40L, 3L, 2L, 24L, 41L, 10L, 30L, 25L, 17L, 26L, 48L, 37L, 49L, 1L, 18L, 21L, 44L, 20L)], width = { options(width = 32); 455 }) + + ctl_colonnade(df_str[c(41L, 4L, 25L, 31L, 8L, 22L, 19L, 10L, 29L, 21L, 34L, 5L, 26L, 36L, 47L, 46L, 2L, 24L, 27L, 39L, 28L, 43L, 32L, 30L, 48L, 44L, 6L, 20L, 13L, 15L, 18L, 42L, 9L, 12L, 37L, 45L, 16L, 40L, 11L, 14L, 38L, 1L, 7L, 3L, 23L, 35L, 50L, 17L, 49L, 33L)], width = { options(width = 55); 855 }) + + ctl_colonnade(df_str[c(27L, 22L, 9L, 23L, 16L, 19L, 25L, 31L, 44L, 1L, 28L, 46L, 12L, 20L, 43L, 37L, 5L, 2L, 18L, 41L, 26L, 33L, 11L, 49L, 24L, 35L, 4L, 47L, 30L, 7L, 34L, 3L, 32L, 42L, 10L, 45L, 38L, 39L, 48L, 14L, 6L, 17L, 36L, 50L, 40L, 13L, 8L, 21L, 15L, 29L)], width = { options(width = 54); 552 }) + + ctl_colonnade(df_str[c(32L, 24L, 18L, 25L, 26L, 13L, 33L, 2L, 50L, 38L, 37L, 16L, 27L, 9L, 28L, 49L, 34L, 15L, 17L, 35L, 22L, 47L, 3L, 21L, 23L, 41L, 5L, 1L, 14L, 46L, 30L, 31L, 44L, 4L, 7L, 40L, 43L, 12L, 29L, 8L, 36L, 45L, 11L, 20L, 10L, 6L, 19L, 48L, 39L, 42L)], width = { options(width = 49); 1031 }) + + ctl_colonnade(df_str[c(44L, 34L, 49L, 9L, 15L, 16L, 1L, 10L, 40L, 29L, 26L, 22L, 4L, 43L, 20L, 17L, 46L, 33L, 35L, 32L, 2L, 12L, 8L, 37L, 23L, 39L, 7L, 18L, 36L, 42L, 6L, 30L, 19L, 25L, 5L, 21L, 47L, 50L, 28L, 11L, 31L, 14L, 24L, 27L, 45L, 41L, 38L, 3L, 13L, 48L)], width = { options(width = 38); 429 }) + + ctl_colonnade(df_str[c(21L, 26L, 8L, 22L, 41L, 24L, 13L, 5L, 47L, 37L, 4L, 42L, 19L, 34L, 11L, 43L, 38L, 3L, 33L, 20L, 31L, 2L, 18L, 48L, 27L, 44L, 9L, 35L, 30L, 6L, 49L, 10L, 1L, 16L, 46L, 29L, 12L, 14L, 45L, 36L, 15L, 39L, 50L, 23L, 17L, 28L, 7L, 32L, 40L, 25L)], width = { options(width = 54); 633 }) + + ctl_colonnade(df_str[c(23L, 49L, 13L, 37L, 3L, 25L, 36L, 4L, 9L, 7L, 27L, 48L, 12L, 10L, 50L, 14L, 38L, 39L, 46L, 22L, 28L, 8L, 21L, 44L, 32L, 40L, 31L, 1L, 29L, 34L, 35L, 33L, 19L, 15L, 41L, 20L, 47L, 18L, 16L, 45L, 6L, 5L, 24L, 26L, 43L, 11L, 42L, 30L, 17L, 2L)], width = { options(width = 39); 1496 }) + + ctl_colonnade(df_str[c(45L, 14L, 49L, 24L, 22L, 31L, 42L, 18L, 16L, 47L, 25L, 4L, 37L, 8L, 26L, 21L, 50L, 5L, 41L, 30L, 2L, 33L, 34L, 3L, 44L, 19L, 43L, 6L, 32L, 29L, 20L, 1L, 13L, 11L, 40L, 12L, 48L, 23L, 9L, 15L, 46L, 36L, 27L, 35L, 28L, 10L, 7L, 39L, 17L, 38L)], width = { options(width = 31); 493 }) + + ctl_colonnade(df_str[c(38L, 46L, 17L, 11L, 24L, 18L, 16L, 39L, 50L, 42L, 6L, 13L, 37L, 29L, 41L, 47L, 9L, 33L, 44L, 31L, 45L, 36L, 28L, 5L, 10L, 30L, 20L, 1L, 14L, 43L, 49L, 23L, 26L, 21L, 32L, 19L, 34L, 15L, 48L, 4L, 7L, 35L, 40L, 8L, 22L, 3L, 25L, 12L, 27L, 2L)], width = { options(width = 52); 1130 }) + + ctl_colonnade(df_str[c(17L, 28L, 29L, 27L, 20L, 31L, 43L, 30L, 32L, 48L, 10L, 50L, 13L, 12L, 36L, 21L, 46L, 33L, 25L, 35L, 1L, 5L, 16L, 34L, 18L, 42L, 3L, 11L, 40L, 26L, 37L, 7L, 39L, 6L, 4L, 19L, 8L, 45L, 14L, 24L, 23L, 2L, 47L, 9L, 49L, 41L, 38L, 22L, 44L, 15L)], width = { options(width = 58); 1310 }) + + ctl_colonnade(df_str[c(1L, 26L, 20L, 12L, 49L, 16L, 24L, 4L, 15L, 47L, 8L, 11L, 14L, 50L, 17L, 2L, 44L, 30L, 36L, 45L, 25L, 38L, 18L, 29L, 5L, 13L, 3L, 23L, 48L, 40L, 34L, 22L, 39L, 33L, 27L, 7L, 19L, 10L, 37L, 6L, 35L, 46L, 31L, 41L, 43L, 28L, 42L, 32L, 21L, 9L)], width = { options(width = 47); 484 }) + + ctl_colonnade(df_str[c(6L, 49L, 26L, 45L, 25L, 15L, 31L, 20L, 21L, 44L, 23L, 48L, 37L, 36L, 5L, 43L, 11L, 14L, 13L, 39L, 16L, 12L, 4L, 18L, 42L, 3L, 10L, 28L, 40L, 24L, 29L, 17L, 35L, 47L, 2L, 38L, 34L, 9L, 7L, 8L, 50L, 33L, 32L, 27L, 46L, 19L, 22L, 41L, 30L, 1L)], width = { options(width = 55); 779 }) + + ctl_colonnade(df_str[c(38L, 42L, 41L, 10L, 40L, 11L, 27L, 9L, 17L, 37L, 46L, 13L, 36L, 18L, 31L, 20L, 39L, 12L, 44L, 33L, 50L, 34L, 26L, 32L, 23L, 30L, 29L, 21L, 4L, 49L, 19L, 25L, 3L, 6L, 15L, 14L, 43L, 48L, 8L, 22L, 1L, 2L, 45L, 35L, 16L, 5L, 47L, 28L, 24L, 7L)], width = { options(width = 46); 694 }) + }) # nolint end -}) + }) diff --git a/tests/testthat/test-ctl_colonnade_2.R b/tests/testthat/test-ctl_colonnade_2.R index e36d47f18..782141ff6 100644 --- a/tests/testthat/test-ctl_colonnade_2.R +++ b/tests/testthat/test-ctl_colonnade_2.R @@ -4,36 +4,35 @@ test_that("strings with varying widths", { # Generated by data-raw/create-chr-tests.R # nolint start expect_snapshot({ - options(width = 54) - ctl_colonnade(df_str[c(28L, 34L, 16L, 29L, 47L, 25L, 42L, 27L, 44L, 20L, 14L, 36L, 43L, 41L, 26L, 45L, 22L, 9L, 13L, 32L, 31L, 12L, 19L, 48L, 49L, 35L, 3L, 11L, 23L, 24L, 40L, 15L, 38L, 10L, 46L, 5L, 50L, 18L, 21L, 6L, 30L, 2L, 7L, 1L, 4L, 8L, 17L, 33L, 39L, 37L)], width = 516) - options(width = 42) - ctl_colonnade(df_str[c(28L, 41L, 12L, 29L, 13L, 43L, 24L, 50L, 48L, 35L, 44L, 21L, 33L, 45L, 47L, 34L, 25L, 14L, 18L, 23L, 7L, 3L, 42L, 36L, 11L, 2L, 20L, 31L, 1L, 4L, 38L, 9L, 27L, 40L, 32L, 17L, 6L, 49L, 16L, 19L, 15L, 22L, 39L, 10L, 46L, 5L, 30L, 8L, 26L, 37L)], width = 1365) - options(width = 39) - ctl_colonnade(df_str[c(40L, 17L, 13L, 23L, 22L, 2L, 18L, 3L, 29L, 45L, 14L, 19L, 33L, 37L, 47L, 43L, 44L, 10L, 31L, 27L, 34L, 35L, 41L, 21L, 4L, 25L, 38L, 48L, 9L, 24L, 26L, 39L, 20L, 36L, 42L, 16L, 6L, 11L, 7L, 12L, 1L, 46L, 15L, 5L, 8L, 50L, 32L, 30L, 49L, 28L)], width = 934) - options(width = 32) - ctl_colonnade(df_str[c(11L, 36L, 17L, 14L, 31L, 35L, 23L, 13L, 6L, 44L, 45L, 22L, 21L, 18L, 33L, 10L, 43L, 2L, 46L, 34L, 3L, 19L, 1L, 38L, 9L, 37L, 5L, 8L, 25L, 49L, 27L, 29L, 15L, 39L, 24L, 40L, 48L, 26L, 47L, 42L, 41L, 12L, 28L, 30L, 7L, 16L, 4L, 50L, 20L, 32L)], width = 565) - options(width = 35) - ctl_colonnade(df_str[c(18L, 46L, 11L, 43L, 31L, 47L, 48L, 44L, 50L, 15L, 28L, 33L, 13L, 4L, 22L, 3L, 37L, 32L, 40L, 9L, 25L, 16L, 45L, 23L, 21L, 6L, 49L, 36L, 27L, 38L, 14L, 34L, 8L, 24L, 29L, 1L, 12L, 2L, 20L, 17L, 35L, 5L, 19L, 30L, 7L, 26L, 42L, 41L, 39L, 10L)], width = 1121) - options(width = 32) - ctl_colonnade(df_str[c(43L, 1L, 3L, 15L, 28L, 12L, 46L, 34L, 31L, 7L, 11L, 4L, 44L, 8L, 9L, 5L, 36L, 22L, 17L, 39L, 18L, 45L, 37L, 13L, 29L, 6L, 30L, 16L, 20L, 10L, 19L, 26L, 33L, 40L, 35L, 48L, 38L, 25L, 2L, 47L, 42L, 41L, 27L, 14L, 21L, 24L, 50L, 49L, 23L, 32L)], width = 446) - options(width = 31) - ctl_colonnade(df_str[c(37L, 46L, 21L, 3L, 16L, 39L, 34L, 33L, 10L, 17L, 19L, 36L, 45L, 49L, 11L, 50L, 14L, 29L, 44L, 13L, 30L, 38L, 32L, 40L, 42L, 1L, 31L, 41L, 7L, 23L, 35L, 28L, 6L, 25L, 2L, 9L, 12L, 15L, 5L, 18L, 20L, 27L, 43L, 8L, 47L, 4L, 48L, 24L, 26L, 22L)], width = 1166) - options(width = 58) - ctl_colonnade(df_str[c(31L, 39L, 40L, 30L, 10L, 21L, 9L, 16L, 46L, 25L, 15L, 24L, 3L, 50L, 35L, 1L, 12L, 34L, 48L, 4L, 29L, 23L, 37L, 36L, 28L, 43L, 11L, 17L, 32L, 8L, 41L, 13L, 44L, 7L, 38L, 26L, 33L, 20L, 19L, 2L, 18L, 49L, 27L, 47L, 22L, 14L, 6L, 5L, 45L, 42L)], width = 546) - options(width = 57) - ctl_colonnade(df_str[c(43L, 21L, 41L, 48L, 22L, 25L, 2L, 8L, 1L, 24L, 6L, 39L, 38L, 20L, 49L, 45L, 47L, 12L, 9L, 13L, 36L, 26L, 44L, 11L, 46L, 28L, 7L, 18L, 50L, 16L, 29L, 30L, 4L, 23L, 17L, 40L, 33L, 14L, 27L, 19L, 34L, 32L, 3L, 37L, 15L, 10L, 5L, 35L, 31L, 42L)], width = 1035) - options(width = 33) - ctl_colonnade(df_str[c(40L, 6L, 25L, 5L, 26L, 17L, 19L, 2L, 11L, 34L, 45L, 24L, 22L, 44L, 35L, 7L, 4L, 49L, 1L, 36L, 12L, 41L, 39L, 13L, 48L, 27L, 18L, 30L, 42L, 28L, 3L, 46L, 21L, 20L, 16L, 29L, 50L, 10L, 9L, 8L, 47L, 31L, 14L, 38L, 33L, 32L, 43L, 23L, 15L, 37L)], width = 1217) - options(width = 32) - ctl_colonnade(df_str[c(43L, 23L, 22L, 11L, 6L, 26L, 48L, 17L, 7L, 42L, 36L, 21L, 35L, 50L, 13L, 19L, 29L, 8L, 15L, 4L, 2L, 27L, 49L, 47L, 30L, 31L, 25L, 28L, 46L, 12L, 32L, 39L, 24L, 10L, 45L, 5L, 37L, 14L, 40L, 20L, 41L, 44L, 33L, 18L, 38L, 3L, 1L, 34L, 16L, 9L)], width = 770) - options(width = 46) - ctl_colonnade(df_str[c(5L, 24L, 43L, 46L, 35L, 39L, 18L, 26L, 8L, 27L, 2L, 50L, 6L, 14L, 29L, 47L, 9L, 16L, 36L, 4L, 13L, 41L, 3L, 28L, 37L, 33L, 38L, 31L, 34L, 19L, 42L, 32L, 1L, 45L, 15L, 7L, 11L, 49L, 23L, 12L, 48L, 20L, 21L, 44L, 25L, 10L, 22L, 30L, 40L, 17L)], width = 1439) - options(width = 52) - ctl_colonnade(df_str[c(7L, 44L, 19L, 21L, 18L, 35L, 23L, 50L, 33L, 37L, 25L, 26L, 10L, 39L, 2L, 47L, 42L, 14L, 9L, 41L, 45L, 6L, 4L, 11L, 24L, 43L, 32L, 3L, 38L, 5L, 49L, 27L, 17L, 8L, 22L, 40L, 12L, 15L, 1L, 28L, 31L, 29L, 13L, 48L, 34L, 36L, 30L, 20L, 16L, 46L)], width = 1065) - options(width = 35) - ctl_colonnade(df_str[c(38L, 18L, 23L, 36L, 35L, 20L, 44L, 19L, 13L, 41L, 31L, 7L, 11L, 29L, 2L, 14L, 26L, 46L, 40L, 45L, 9L, 34L, 33L, 22L, 1L, 17L, 28L, 10L, 21L, 30L, 47L, 49L, 6L, 12L, 4L, 25L, 32L, 15L, 43L, 24L, 48L, 3L, 37L, 50L, 42L, 39L, 16L, 8L, 27L, 5L)], width = 393) - options(width = 41) - ctl_colonnade(df_str[c(22L, 9L, 11L, 26L, 19L, 16L, 32L, 25L, 1L, 30L, 31L, 6L, 24L, 10L, 39L, 21L, 50L, 7L, 29L, 12L, 46L, 43L, 15L, 35L, 20L, 40L, 49L, 38L, 36L, 48L, 34L, 3L, 8L, 4L, 27L, 42L, 44L, 33L, 45L, 18L, 5L, 2L, 13L, 47L, 28L, 17L, 37L, 14L, 41L, 23L)], width = 999) + ctl_colonnade(df_str[c(28L, 34L, 16L, 29L, 47L, 25L, 42L, 27L, 44L, 20L, 14L, 36L, 43L, 41L, 26L, 45L, 22L, 9L, 13L, 32L, 31L, 12L, 19L, 48L, 49L, 35L, 3L, 11L, 23L, 24L, 40L, 15L, 38L, 10L, 46L, 5L, 50L, 18L, 21L, 6L, 30L, 2L, 7L, 1L, 4L, 8L, 17L, 33L, 39L, 37L)], width = { options(width = 54); 516 }) + + ctl_colonnade(df_str[c(28L, 41L, 12L, 29L, 13L, 43L, 24L, 50L, 48L, 35L, 44L, 21L, 33L, 45L, 47L, 34L, 25L, 14L, 18L, 23L, 7L, 3L, 42L, 36L, 11L, 2L, 20L, 31L, 1L, 4L, 38L, 9L, 27L, 40L, 32L, 17L, 6L, 49L, 16L, 19L, 15L, 22L, 39L, 10L, 46L, 5L, 30L, 8L, 26L, 37L)], width = { options(width = 42); 1365 }) + + ctl_colonnade(df_str[c(40L, 17L, 13L, 23L, 22L, 2L, 18L, 3L, 29L, 45L, 14L, 19L, 33L, 37L, 47L, 43L, 44L, 10L, 31L, 27L, 34L, 35L, 41L, 21L, 4L, 25L, 38L, 48L, 9L, 24L, 26L, 39L, 20L, 36L, 42L, 16L, 6L, 11L, 7L, 12L, 1L, 46L, 15L, 5L, 8L, 50L, 32L, 30L, 49L, 28L)], width = { options(width = 39); 934 }) + + ctl_colonnade(df_str[c(11L, 36L, 17L, 14L, 31L, 35L, 23L, 13L, 6L, 44L, 45L, 22L, 21L, 18L, 33L, 10L, 43L, 2L, 46L, 34L, 3L, 19L, 1L, 38L, 9L, 37L, 5L, 8L, 25L, 49L, 27L, 29L, 15L, 39L, 24L, 40L, 48L, 26L, 47L, 42L, 41L, 12L, 28L, 30L, 7L, 16L, 4L, 50L, 20L, 32L)], width = { options(width = 32); 565 }) + + ctl_colonnade(df_str[c(18L, 46L, 11L, 43L, 31L, 47L, 48L, 44L, 50L, 15L, 28L, 33L, 13L, 4L, 22L, 3L, 37L, 32L, 40L, 9L, 25L, 16L, 45L, 23L, 21L, 6L, 49L, 36L, 27L, 38L, 14L, 34L, 8L, 24L, 29L, 1L, 12L, 2L, 20L, 17L, 35L, 5L, 19L, 30L, 7L, 26L, 42L, 41L, 39L, 10L)], width = { options(width = 35); 1121 }) + + ctl_colonnade(df_str[c(43L, 1L, 3L, 15L, 28L, 12L, 46L, 34L, 31L, 7L, 11L, 4L, 44L, 8L, 9L, 5L, 36L, 22L, 17L, 39L, 18L, 45L, 37L, 13L, 29L, 6L, 30L, 16L, 20L, 10L, 19L, 26L, 33L, 40L, 35L, 48L, 38L, 25L, 2L, 47L, 42L, 41L, 27L, 14L, 21L, 24L, 50L, 49L, 23L, 32L)], width = { options(width = 32); 446 }) + + ctl_colonnade(df_str[c(37L, 46L, 21L, 3L, 16L, 39L, 34L, 33L, 10L, 17L, 19L, 36L, 45L, 49L, 11L, 50L, 14L, 29L, 44L, 13L, 30L, 38L, 32L, 40L, 42L, 1L, 31L, 41L, 7L, 23L, 35L, 28L, 6L, 25L, 2L, 9L, 12L, 15L, 5L, 18L, 20L, 27L, 43L, 8L, 47L, 4L, 48L, 24L, 26L, 22L)], width = { options(width = 31); 1166 }) + + ctl_colonnade(df_str[c(31L, 39L, 40L, 30L, 10L, 21L, 9L, 16L, 46L, 25L, 15L, 24L, 3L, 50L, 35L, 1L, 12L, 34L, 48L, 4L, 29L, 23L, 37L, 36L, 28L, 43L, 11L, 17L, 32L, 8L, 41L, 13L, 44L, 7L, 38L, 26L, 33L, 20L, 19L, 2L, 18L, 49L, 27L, 47L, 22L, 14L, 6L, 5L, 45L, 42L)], width = { options(width = 58); 546 }) + + ctl_colonnade(df_str[c(43L, 21L, 41L, 48L, 22L, 25L, 2L, 8L, 1L, 24L, 6L, 39L, 38L, 20L, 49L, 45L, 47L, 12L, 9L, 13L, 36L, 26L, 44L, 11L, 46L, 28L, 7L, 18L, 50L, 16L, 29L, 30L, 4L, 23L, 17L, 40L, 33L, 14L, 27L, 19L, 34L, 32L, 3L, 37L, 15L, 10L, 5L, 35L, 31L, 42L)], width = { options(width = 57); 1035 }) + + ctl_colonnade(df_str[c(40L, 6L, 25L, 5L, 26L, 17L, 19L, 2L, 11L, 34L, 45L, 24L, 22L, 44L, 35L, 7L, 4L, 49L, 1L, 36L, 12L, 41L, 39L, 13L, 48L, 27L, 18L, 30L, 42L, 28L, 3L, 46L, 21L, 20L, 16L, 29L, 50L, 10L, 9L, 8L, 47L, 31L, 14L, 38L, 33L, 32L, 43L, 23L, 15L, 37L)], width = { options(width = 33); 1217 }) + + ctl_colonnade(df_str[c(43L, 23L, 22L, 11L, 6L, 26L, 48L, 17L, 7L, 42L, 36L, 21L, 35L, 50L, 13L, 19L, 29L, 8L, 15L, 4L, 2L, 27L, 49L, 47L, 30L, 31L, 25L, 28L, 46L, 12L, 32L, 39L, 24L, 10L, 45L, 5L, 37L, 14L, 40L, 20L, 41L, 44L, 33L, 18L, 38L, 3L, 1L, 34L, 16L, 9L)], width = { options(width = 32); 770 }) + + ctl_colonnade(df_str[c(5L, 24L, 43L, 46L, 35L, 39L, 18L, 26L, 8L, 27L, 2L, 50L, 6L, 14L, 29L, 47L, 9L, 16L, 36L, 4L, 13L, 41L, 3L, 28L, 37L, 33L, 38L, 31L, 34L, 19L, 42L, 32L, 1L, 45L, 15L, 7L, 11L, 49L, 23L, 12L, 48L, 20L, 21L, 44L, 25L, 10L, 22L, 30L, 40L, 17L)], width = { options(width = 46); 1439 }) + + ctl_colonnade(df_str[c(7L, 44L, 19L, 21L, 18L, 35L, 23L, 50L, 33L, 37L, 25L, 26L, 10L, 39L, 2L, 47L, 42L, 14L, 9L, 41L, 45L, 6L, 4L, 11L, 24L, 43L, 32L, 3L, 38L, 5L, 49L, 27L, 17L, 8L, 22L, 40L, 12L, 15L, 1L, 28L, 31L, 29L, 13L, 48L, 34L, 36L, 30L, 20L, 16L, 46L)], width = { options(width = 52); 1065 }) + + ctl_colonnade(df_str[c(38L, 18L, 23L, 36L, 35L, 20L, 44L, 19L, 13L, 41L, 31L, 7L, 11L, 29L, 2L, 14L, 26L, 46L, 40L, 45L, 9L, 34L, 33L, 22L, 1L, 17L, 28L, 10L, 21L, 30L, 47L, 49L, 6L, 12L, 4L, 25L, 32L, 15L, 43L, 24L, 48L, 3L, 37L, 50L, 42L, 39L, 16L, 8L, 27L, 5L)], width = { options(width = 35); 393 }) + + ctl_colonnade(df_str[c(22L, 9L, 11L, 26L, 19L, 16L, 32L, 25L, 1L, 30L, 31L, 6L, 24L, 10L, 39L, 21L, 50L, 7L, 29L, 12L, 46L, 43L, 15L, 35L, 20L, 40L, 49L, 38L, 36L, 48L, 34L, 3L, 8L, 4L, 27L, 42L, 44L, 33L, 45L, 18L, 5L, 2L, 13L, 47L, 28L, 17L, 37L, 14L, 41L, 23L)], width = { options(width = 41); 999 }) }) # nolint end }) diff --git a/tests/testthat/test-multi.R b/tests/testthat/test-multi.R new file mode 100644 index 000000000..8ce4e3db7 --- /dev/null +++ b/tests/testthat/test-multi.R @@ -0,0 +1,38 @@ +test_that("colonnade_compute_tiered_col_widths_df()", { + expect_snapshot({ + colonnade_compute_tiered_col_widths_df(rep(30, 4), rep(15, 4), rep(60, 4)) + colonnade_compute_tiered_col_widths_df(rep(30, 4), rep(15, 4), rep(60, 3)) + colonnade_compute_tiered_col_widths_df(rep(30, 4), rep(15, 4), rep(60, 2)) + colonnade_compute_tiered_col_widths_df(rep(30, 5), rep(15, 5), rep(60, 3)) + colonnade_compute_tiered_col_widths_df(rep(30, 5), rep(15, 5), rep(60, 4)) + colonnade_compute_tiered_col_widths_df(rep(30, 10), rep(15, 10), rep(60, 5)) + colonnade_compute_tiered_col_widths_df(c(6, 5, 10), c(5, 5, 10), 21) + colonnade_compute_tiered_col_widths_df(c(6, 5, 10), c(5, 5, 10), 22) + colonnade_compute_tiered_col_widths_df(c(6, 5, 10), c(5, 5, 10), 23) + colonnade_compute_tiered_col_widths_df(c(5, 6, 10), c(5, 5, 10), 21) + colonnade_compute_tiered_col_widths_df(c(5, 6, 10), c(5, 5, 10), 22) + colonnade_compute_tiered_col_widths_df(c(5, 6, 10), c(5, 5, 10), 23) + }) +}) + +test_that("distribute_pillars()", { + expect_snapshot({ + distribute_pillars(1:3, 10) + distribute_pillars(1:3, 5) + distribute_pillars(1:3, c(5, 5)) + distribute_pillars(1:5, 7:9) + distribute_pillars(3:5, 8:10) + distribute_pillars(5:3, 9:8) + }) +}) + +test_that("distribute_pillars_rev()", { + expect_snapshot({ + distribute_pillars_rev(1:3, 10) + distribute_pillars_rev(1:3, 5) + distribute_pillars_rev(1:3, c(5, 5)) + distribute_pillars_rev(1:5, 7:9) + distribute_pillars_rev(3:5, 8:10) + distribute_pillars_rev(5:3, 9:8) + }) +}) diff --git a/tests/testthat/test-num.R b/tests/testthat/test-num.R index f5c095ad3..8ebbb669d 100644 --- a/tests/testthat/test-num.R +++ b/tests/testthat/test-num.R @@ -47,6 +47,14 @@ test_that("output test", { scilarge = num(10^(-7:6) * 123, notation = "eng", fixed_exponent = 3), scimax = num(10^(-7:6) * 123, notation = "si", fixed_exponent = Inf) ) + + # Extra significant figures + tibble::tibble( + default = num(100 + 1:3 * 0.001), + extra1 = num(100 + 1:3 * 0.001, extra_sigfig = TRUE), + extra2 = num(100 + 1:3 * 0.0001, extra_sigfig = TRUE), + extra3 = num(10000 + 1:3 * 0.00001, extra_sigfig = TRUE) + ) }) }) diff --git a/tests/testthat/test-options.R b/tests/testthat/test-options.R new file mode 100644 index 000000000..148718ffe --- /dev/null +++ b/tests/testthat/test-options.R @@ -0,0 +1,321 @@ +test_that("print_max", { + value <- 15L + + orig <- get_pillar_option_print_max() + expect_identical(orig, pillar_options$print_max()) + + old <- set_pillar_option_print_max(value) + expect_equal(get_pillar_option_print_max(), value) + expect_equal(expect_invisible(set_pillar_option_print_max(old)), value) + + old <- pillar_options$print_max(value) + expect_equal(pillar_options$print_max(), value) + expect_equal(expect_invisible(pillar_options$print_max(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_print_max(value)), old) + expect_equal(get_pillar_option_print_max(), value) + }) + expect_equal(get_pillar_option_print_max(), orig) +}) + +test_that("print_min", { + value <- 5L + + orig <- get_pillar_option_print_min() + expect_identical(orig, pillar_options$print_min()) + + old <- set_pillar_option_print_min(value) + expect_equal(get_pillar_option_print_min(), value) + expect_equal(expect_invisible(set_pillar_option_print_min(old)), value) + + old <- pillar_options$print_min(value) + expect_equal(pillar_options$print_min(), value) + expect_equal(expect_invisible(pillar_options$print_min(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_print_min(value)), old) + expect_equal(get_pillar_option_print_min(), value) + }) + expect_equal(get_pillar_option_print_min(), orig) +}) + +test_that("width", { + value <- 160L + + orig <- get_pillar_option_width() + expect_identical(orig, pillar_options$width()) + + old <- set_pillar_option_width(value) + expect_equal(get_pillar_option_width(), value) + expect_equal(expect_invisible(set_pillar_option_width(old)), value) + + old <- pillar_options$width(value) + expect_equal(pillar_options$width(), value) + expect_equal(expect_invisible(pillar_options$width(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_width(value)), old) + expect_equal(get_pillar_option_width(), value) + }) + expect_equal(get_pillar_option_width(), orig) +}) + +test_that("max_footer_lines", { + value <- 15L + + orig <- get_pillar_option_max_footer_lines() + expect_identical(orig, pillar_options$max_footer_lines()) + + old <- set_pillar_option_max_footer_lines(value) + expect_equal(get_pillar_option_max_footer_lines(), value) + expect_equal(expect_invisible(set_pillar_option_max_footer_lines(old)), value) + + old <- pillar_options$max_footer_lines(value) + expect_equal(pillar_options$max_footer_lines(), value) + expect_equal(expect_invisible(pillar_options$max_footer_lines(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_max_footer_lines(value)), old) + expect_equal(get_pillar_option_max_footer_lines(), value) + }) + expect_equal(get_pillar_option_max_footer_lines(), orig) +}) + +test_that("max_extra_cols", { + value <- 30L + + orig <- get_pillar_option_max_extra_cols() + expect_identical(orig, pillar_options$max_extra_cols()) + + old <- set_pillar_option_max_extra_cols(value) + expect_equal(get_pillar_option_max_extra_cols(), value) + expect_equal(expect_invisible(set_pillar_option_max_extra_cols(old)), value) + + old <- pillar_options$max_extra_cols(value) + expect_equal(pillar_options$max_extra_cols(), value) + expect_equal(expect_invisible(pillar_options$max_extra_cols(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_max_extra_cols(value)), old) + expect_equal(get_pillar_option_max_extra_cols(), value) + }) + expect_equal(get_pillar_option_max_extra_cols(), orig) +}) + +test_that("bold", { + value <- 0L + + orig <- get_pillar_option_bold() + expect_identical(orig, pillar_options$bold()) + + old <- set_pillar_option_bold(value) + expect_equal(get_pillar_option_bold(), value) + expect_equal(expect_invisible(set_pillar_option_bold(old)), value) + + old <- pillar_options$bold(value) + expect_equal(pillar_options$bold(), value) + expect_equal(expect_invisible(pillar_options$bold(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_bold(value)), old) + expect_equal(get_pillar_option_bold(), value) + }) + expect_equal(get_pillar_option_bold(), orig) +}) + +test_that("subtle", { + value <- 0L + + orig <- get_pillar_option_subtle() + expect_identical(orig, pillar_options$subtle()) + + old <- set_pillar_option_subtle(value) + expect_equal(get_pillar_option_subtle(), value) + expect_equal(expect_invisible(set_pillar_option_subtle(old)), value) + + old <- pillar_options$subtle(value) + expect_equal(pillar_options$subtle(), value) + expect_equal(expect_invisible(pillar_options$subtle(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_subtle(value)), old) + expect_equal(get_pillar_option_subtle(), value) + }) + expect_equal(get_pillar_option_subtle(), orig) +}) + +test_that("subtle_num", { + value <- 0L + + orig <- get_pillar_option_subtle_num() + expect_identical(orig, pillar_options$subtle_num()) + + old <- set_pillar_option_subtle_num(value) + expect_equal(get_pillar_option_subtle_num(), value) + expect_equal(expect_invisible(set_pillar_option_subtle_num(old)), value) + + old <- pillar_options$subtle_num(value) + expect_equal(pillar_options$subtle_num(), value) + expect_equal(expect_invisible(pillar_options$subtle_num(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_subtle_num(value)), old) + expect_equal(get_pillar_option_subtle_num(), value) + }) + expect_equal(get_pillar_option_subtle_num(), orig) +}) + +test_that("neg", { + value <- 0L + + orig <- get_pillar_option_neg() + expect_identical(orig, pillar_options$neg()) + + old <- set_pillar_option_neg(value) + expect_equal(get_pillar_option_neg(), value) + expect_equal(expect_invisible(set_pillar_option_neg(old)), value) + + old <- pillar_options$neg(value) + expect_equal(pillar_options$neg(), value) + expect_equal(expect_invisible(pillar_options$neg(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_neg(value)), old) + expect_equal(get_pillar_option_neg(), value) + }) + expect_equal(get_pillar_option_neg(), orig) +}) + +test_that("sigfig", { + value <- 5L + + orig <- get_pillar_option_sigfig() + expect_identical(orig, pillar_options$sigfig()) + + old <- set_pillar_option_sigfig(value) + expect_equal(get_pillar_option_sigfig(), value) + expect_equal(expect_invisible(set_pillar_option_sigfig(old)), value) + + old <- pillar_options$sigfig(value) + expect_equal(pillar_options$sigfig(), value) + expect_equal(expect_invisible(pillar_options$sigfig(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_sigfig(value)), old) + expect_equal(get_pillar_option_sigfig(), value) + }) + expect_equal(get_pillar_option_sigfig(), orig) +}) + +test_that("min_title_chars", { + value <- 12L + + orig <- get_pillar_option_min_title_chars() + expect_identical(orig, pillar_options$min_title_chars()) + + old <- set_pillar_option_min_title_chars(value) + expect_equal(get_pillar_option_min_title_chars(), value) + expect_equal(expect_invisible(set_pillar_option_min_title_chars(old)), value) + + old <- pillar_options$min_title_chars(value) + expect_equal(pillar_options$min_title_chars(), value) + expect_equal(expect_invisible(pillar_options$min_title_chars(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_min_title_chars(value)), old) + expect_equal(get_pillar_option_min_title_chars(), value) + }) + expect_equal(get_pillar_option_min_title_chars(), orig) +}) + +test_that("min_chars", { + value <- 5L + + orig <- get_pillar_option_min_chars() + expect_identical(orig, pillar_options$min_chars()) + + old <- set_pillar_option_min_chars(value) + expect_equal(get_pillar_option_min_chars(), value) + expect_equal(expect_invisible(set_pillar_option_min_chars(old)), value) + + old <- pillar_options$min_chars(value) + expect_equal(pillar_options$min_chars(), value) + expect_equal(expect_invisible(pillar_options$min_chars(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_min_chars(value)), old) + expect_equal(get_pillar_option_min_chars(), value) + }) + expect_equal(get_pillar_option_min_chars(), orig) +}) + +test_that("max_dec_width", { + value <- 0L + + orig <- get_pillar_option_max_dec_width() + expect_identical(orig, pillar_options$max_dec_width()) + + old <- set_pillar_option_max_dec_width(value) + expect_equal(get_pillar_option_max_dec_width(), value) + expect_equal(expect_invisible(set_pillar_option_max_dec_width(old)), value) + + old <- pillar_options$max_dec_width(value) + expect_equal(pillar_options$max_dec_width(), value) + expect_equal(expect_invisible(pillar_options$max_dec_width(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_max_dec_width(value)), old) + expect_equal(get_pillar_option_max_dec_width(), value) + }) + expect_equal(get_pillar_option_max_dec_width(), orig) +}) + +test_that("bidi", { + value <- TRUE + + orig <- get_pillar_option_bidi() + expect_identical(orig, pillar_options$bidi()) + + old <- set_pillar_option_bidi(value) + expect_equal(get_pillar_option_bidi(), value) + expect_equal(expect_invisible(set_pillar_option_bidi(old)), value) + + old <- pillar_options$bidi(value) + expect_equal(pillar_options$bidi(), value) + expect_equal(expect_invisible(pillar_options$bidi(old)), value) + + local({ + expect_equal(expect_invisible(local_pillar_option_bidi(value)), old) + expect_equal(get_pillar_option_bidi(), value) + }) + expect_equal(get_pillar_option_bidi(), orig) +}) + +test_that("print.tbl ignores max.print option", { + trees2 <- as_tbl(trees) + expect_output( + withr::with_options(list(max.print = 3), print(trees2)), + capture_output(print(trees2)), + fixed = TRUE + ) +}) + +test_that("print.tbl uses tibble.width option", { + mtcars2 <- as_tbl(mtcars) + expect_output( + withr::with_options(list(tibble.width = 40, dplyr.width = 50, width = 60), print(mtcars2)), + capture_output(print(mtcars2, width = 40)), + fixed = TRUE + ) + expect_output( + withr::with_options(list(dplyr.width = 50, width = 60), print(mtcars2)), + capture_output(print(mtcars2, width = 50)), + fixed = TRUE + ) + expect_output( + withr::with_options(list(width = 60), print(mtcars2)), + capture_output(print(mtcars2, width = 60)), + fixed = TRUE + ) +}) diff --git a/tests/testthat/test-tbl-format-footer.R b/tests/testthat/test-tbl-format-footer.R index 71b7c6ed0..3560be802 100644 --- a/tests/testthat/test-tbl-format-footer.R +++ b/tests/testthat/test-tbl-format-footer.R @@ -25,3 +25,53 @@ test_that("overflow", { )) }) }) + +test_that("max_footer_lines option", { + new_footer_tbl <- function(prefix) { + names <- outer(letters[1:2], letters, paste0) + x <- setNames(as.list(seq_along(names)), paste0(prefix, names)) + new_tbl(x) + } + + expect_identical( + local({ + local_pillar_option_max_footer_lines(3) + tbl_format_footer(tbl_format_setup(new_footer_tbl(""))) + }), + tbl_format_footer( + tbl_format_setup(new_footer_tbl(""), max_footer_lines = 3) + ) + ) + + expect_snapshot({ + tbl_format_footer( + tbl_format_setup(new_footer_tbl("")) + ) + tbl_format_footer( + tbl_format_setup(new_footer_tbl("prefix_")) + ) + tbl_format_footer( + tbl_format_setup(new_footer_tbl("a_very_long_prefix_")) + ) + + tbl_format_footer( + tbl_format_setup(new_footer_tbl(""), max_footer_lines = 3) + ) + tbl_format_footer( + tbl_format_setup(new_footer_tbl("prefix_"), max_footer_lines = 3) + ) + tbl_format_footer( + tbl_format_setup(new_footer_tbl("a_very_long_prefix_"), max_footer_lines = 3) + ) + + tbl_format_footer( + tbl_format_setup(new_footer_tbl(""), max_footer_lines = Inf) + ) + tbl_format_footer( + tbl_format_setup(new_footer_tbl("prefix_"), max_footer_lines = Inf) + ) + tbl_format_footer( + tbl_format_setup(new_footer_tbl("a_very_long_prefix_"), max_footer_lines = Inf) + ) + }) +}) diff --git a/tests/testthat/test-tbl-format.R b/tests/testthat/test-tbl-format.R index ac549e691..61d80b44c 100644 --- a/tests/testthat/test-tbl-format.R +++ b/tests/testthat/test-tbl-format.R @@ -24,6 +24,12 @@ test_that("print() output", { print(as_tbl(mtcars), n = 100) + print(as_tbl(mtcars), width = 40, n_extra = 1) + + print(as_tbl(mtcars), width = 40, max_extra_cols = 1) + + print(as_tbl(mtcars), width = 30, max_footer_lines = 3) + rlang::with_options( tibble.print_min = 5, as_tbl(mtcars) diff --git a/tests/testthat/test-tibble-opt.R b/tests/testthat/test-tibble-opt.R deleted file mode 100644 index 3b4c0f6a4..000000000 --- a/tests/testthat/test-tibble-opt.R +++ /dev/null @@ -1,27 +0,0 @@ -test_that("print.tbl ignores max.print option", { - trees2 <- as_tbl(trees) - expect_output( - withr::with_options(list(max.print = 3), print(trees2)), - capture_output(print(trees2)), - fixed = TRUE - ) -}) - -test_that("print.tbl uses tibble.width option", { - mtcars2 <- as_tbl(mtcars) - expect_output( - withr::with_options(list(tibble.width = 40, dplyr.width = 50, width = 60), print(mtcars2)), - capture_output(print(mtcars2, width = 40)), - fixed = TRUE - ) - expect_output( - withr::with_options(list(dplyr.width = 50, width = 60), print(mtcars2)), - capture_output(print(mtcars2, width = 50)), - fixed = TRUE - ) - expect_output( - withr::with_options(list(width = 60), print(mtcars2)), - capture_output(print(mtcars2, width = 60)), - fixed = TRUE - ) -}) diff --git a/vignettes/digits.Rmd b/vignettes/digits.Rmd index 2167ab6aa..be13332ab 100644 --- a/vignettes/digits.Rmd +++ b/vignettes/digits.Rmd @@ -1,135 +1,10 @@ --- -title: "Significant figures and scientific notation" +title: "Comparison with data frames" output: html_vignette vignette: > - %\VignetteIndexEntry{Significant figures and scientific notation} + %\VignetteIndexEntry{Comparison with data frames} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - -```{r setup} -library(pillar) -``` - -Base R offers the `"digits"` and `"scipen"` options to control the number of significant digits and the switch to scientific notation. -For pillar, the options `"pillar.sigfig"` and `"pillar.max_dec_width"` fulfill a similar purpose. -This vignette showcases similarities and differences. -See `?"pillar-package"` for an overview over all options. - -## Digits - -### Basic differences - -The default for `getOption("digits")` is 7, whereas the `"pillar.sigfig"` option defaults to 3. -In the default setting, pillar prints the first three digits only (i.e. the digits that represent > 99.9% of the value of the number). -Another difference is that pillar will show at most the specified number of significant digits, even if space is available. -The rationale is to allow a quick glance over the most significant digits of a number, without spending too much horizontal space and without distraction from insignificant digits. - -```{r} -options(digits = 3) -c(1.2345, 12.345, 123.45, 1234.5, 12345) -pillar(c(1.2345, 12.345, 123.45, 1234.5, 12345)) -``` - -### Terminal zeros - -Terminal zeros are only shown in pillar if there is a nonzero value past the significant digits shown. -This is in contrast to base R where terminal zeros are always shown if there is space, but hidden if the value is too insignificant: - -```{r} -c(1, 1.00001) -pillar(c(1, 1.00001)) -``` - -### Trailing dot - -A trailing decimal separator is shown if there is a fractional part but the integer part already exceeds the significant digits. -The presence of the decimal separator does **not** indicate that the number is larger, only that there exists a nonzero fractional part: - -```{r} -c(123, 123.45, 567.89) -pillar(c(123, 123.45, 567.89)) -``` - -### Showing more digits - -To show more significant digits, set the `"pillar.sigfig"` option to a larger value: - -```{r} -options(digits = 7) -options(pillar.sigfig = 7) -c(1.2345, 12.345, 123.45, 1234.5, 12345) -pillar(c(1.2345, 12.345, 123.45, 1234.5, 12345)) -``` - -Setting `"pillar.sigfig"` to a larger value will not enhance the display with digits deemed insignificant: - -```{r} -options(digits = 7) -options(pillar.sigfig = 7) -c(1.2345, 12.3456, 123.4567, 1234.5678, 12345.6789) -pillar(c(1.2345, 12.3456, 123.4567, 1234.5678, 12345.6789)) -``` - -### Fixed number of digits - -To show a fixed number of decimal digits, use `num()` with a `digits` argument: - -```{r} -num(c(1.2345, 12.345, 123.45, 1234.5, 12345), digits = 2) -``` - -See `vignette("numbers")` for details. - -## Scientific notation - -### When is it used? - -Both base R and pillar switch to scientific notation when the decimal representation becomes too wide. -The larger `getOption("scipen")`, the stronger the resistance to switching to scientific notation. -The default `0` seems to be anchored at 13 digits for the integer part. - -```{r} -123456789012 -123456789012.3 -1234567890123 -1234567890123.4 -options(scipen = 1) -1234567890123 -12345678901234 -12345678901234.5 -``` - -The `"pillar.max_dec_width"` option is similar, it indicates the width that must be exceeded for a switch to scientific notation to happen. -This width includes the decimal separator. - -```{r} -pillar(123456789012) -pillar(123456789012.3) -pillar(1234567890123) -pillar(1234567890123.4) -options(pillar.max_dec_width = 14) -pillar(1234567890123) -pillar(12345678901234) -pillar(12345678901234.5) -``` - -### Enforce notation - -To avoid switching to scientific notation, set the `"pillar.max_dec_width"` option to a large value. -Note that if the required width is not available to show the column, it will not be shown at all in this case. -The `notation` argument to `num()` offers more options: - -```{r} -num(12345678901234567, notation = "dec") -num(12345678901234567, notation = "sci") -num(12345678901234567, notation = "eng") -num(12345678901234567, notation = "si") -``` +This content has moved to `vignette("digits", packages = "tibble)`. diff --git a/vignettes/numbers.Rmd b/vignettes/numbers.Rmd index 0b0f88b01..fd355f4b9 100644 --- a/vignettes/numbers.Rmd +++ b/vignettes/numbers.Rmd @@ -7,113 +7,7 @@ vignette: > %\VignetteEncoding{UTF-8} --- -```{r numbers-1, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - cache = TRUE, - comment = "#>" -) -``` - -Tibbles print numbers with three significant digits by default, switching to scientific notation if the available space is too small. -Underlines are used to highlight groups of three digits. -This display works for many, but not for all use cases. - -```{r numbers-2} -library(pillar) -library(tibble) -``` - -## Per-column number formatting - -The new `num()` constructor allows creating vectors that behave like numbers but allow customizing their display. - -```{r numbers-5} -num(-1:3, notation = "sci") - -tibble( - x4 = num(8:12 * 100 + 0.5, digits = 4), - x1 = num(8:12 * 100 + 0.5, digits = -1), - usd = num(8:12 * 100 + 0.5, digits = 2, label = "USD"), - percent = num(8:12 / 100 + 0.0005, label = "%", scale = 100), - eng = num(10^(-3:1), notation = "eng", fixed_exponent = -Inf), - si = num(10^(-3:1) * 123, notation = "si") -) -``` - - -## Computing on `num` - -Formatting numbers is useful for presentation of results. -If defined early on in the analysis, the formatting options survive most operations. -It is worth defining output options that suit your data once early on in the process, to benefit from the formatting throughout the analysis. -We are working on seamlessly applying this formatting to the final presentation (plots, tables, ...). - - -### Arithmetics - -```{r numbers-13} -num(1) + 2 -1 + num(2) -1L + num(2) -num(3.23456, sigfig = 4) - num(2) -num(4, sigfig = 2) * num(3, digits = 2) -num(3, digits = 2) * num(4, sigfig = 2) --num(2) -``` - -### Mathematics - -```{r numbers-15} -min(num(1:3, label = "$")) -mean(num(1:3, notation = "eng")) -sin(num(1:3, label = "%", scale = 100)) -``` - -### Recovery - -The `var()` function is one of the examples where the formatting is lost: - -```{r numbers-16} -x <- num(c(1, 2, 4), notation = "eng") -var(x) -``` - -One way to recover is to apply `num()` to the result: - -```{r numbers-16a} -num(var(x), notation = "eng") -``` - -For automatic recovery, we can also define our version of `var()`, or even overwrite the base implementation. -Note that this pattern is still experimental and may be subject to change: - -```{r numbers-16b} -var_ <- function(x, ...) { - out <- var(vctrs::vec_proxy(x), ...) - vctrs::vec_restore(out, x) -} -var_(x) -``` - -This pattern can be applied to all functions that lose the formatting. -The `make_restore()` function defined below is a function factory that consumes a function and returns a derived function: - -```{r numbers-16c} -make_restore <- function(fun) { - force(fun) - function(x, ...) { - out <- fun(vctrs::vec_proxy(x), ...) - vctrs::vec_restore(out, x) - } -} - -var_ <- make_restore(var) -sd_ <- make_restore(sd) - -var_(x) -sd_(x) -``` +This content has moved to `vignette("numbes", packages = "tibble)`. `````{asis echo = FALSE} @@ -127,7 +21,7 @@ FIXME ### units -```{r numbers-17} +xxx{r numbers-17} library(units) set_units.pillar_num <- function(x, ...) { @@ -150,11 +44,11 @@ tibble( digits_int = set_num_opts(km, digits = 4) + m, sci_ext = set_units(num(1:3, notation = "sci"), m) + km ) -``` +xxx ### formattable -```{r numbers-18, error = TRUE} +xxx{r numbers-18, error = TRUE} library(formattable) pillar_shaft.formattable <- function(x, ...) { @@ -198,11 +92,11 @@ tibble( percent = num_percent(1:3 * 0.1 + 0.001), scientific = num_scientific(1:3 * 0.1 + 0.001) ) -``` +xxx ### scales -```{r numbers-scales, error = TRUE} +xxx{r numbers-scales, error = TRUE} library(scales) x <- num(1:10 / 100, label = "%", scale = 100) @@ -213,11 +107,11 @@ x < 0 x < 0L scales::cscale(x, scales::rescale_pal()) -``` +xxx ### ggplot2 -```{r numbers-19} +xxx{r numbers-19} library(ggplot2) scale_type.pillar_num <- function(x, ...) { @@ -227,13 +121,13 @@ scale_type.pillar_num <- function(x, ...) { data.frame(x = x, y = 1:10) %>% ggplot(aes(x = x, y = y)) %>% + geom_point() -``` +xxx ## Rule-based decoration -```{r} +xxx{r} library(dplyr) data_units <- @@ -243,25 +137,25 @@ data_units <- data_units %>% mutate(bill_area = bill_length_mm * bill_depth_mm, .after = island) -``` +xxx -```{r eval = FALSE} +xxx{r eval = FALSE} data_decor <- data_units %>% decorate(year, digits = 0) %>% decorate(where(is.numeric), digits = 3) -``` +xxx -```{r eval = FALSE} +xxx{r eval = FALSE} data_decor %>% mutate(bill_area = bill_length_mm * bill_depth_mm, .after = island) -``` +xxx -```{r echo = FALSE} +xxx{r echo = FALSE} data_units %>% mutate(bill_area = bill_length_mm * bill_depth_mm, .after = island) %>% mutate(across(year, set_num_opts, digits = 0)) %>% mutate(across(where(is.numeric), set_num_opts, digits = 3)) -``` +xxx `````