diff --git a/.github/dep-suggests-matrix.json b/.github/dep-suggests-matrix.json deleted file mode 100644 index 3cc98e25f..000000000 --- a/.github/dep-suggests-matrix.json +++ /dev/null @@ -1 +0,0 @@ -{"package":["bit64","DBI","debugme","DiagrammeR","dplyr","formattable","ggplot2","lubridate","nanotime","nycflights13","palmerpenguins","scales","stringi","units","vdiffr"]} diff --git a/.github/versions-matrix.json b/.github/versions-matrix.json deleted file mode 100644 index 5af4434a8..000000000 --- a/.github/versions-matrix.json +++ /dev/null @@ -1 +0,0 @@ -{"include":[{"os":"macos-latest","r":"4.4"},{"os":"macos-latest","r":"4.3"},{"os":"windows-latest","r":"devel"},{"os":"windows-latest","r":"4.4"},{"os":"windows-latest","r":"4.3"},{"os":"ubuntu-22.04","r":"devel","http-user-agent":"release"},{"os":"ubuntu-22.04","r":"4.4"},{"os":"ubuntu-22.04","r":"4.3"},{"os":"ubuntu-22.04","r":"4.2"},{"os":"ubuntu-22.04","r":"4.1"},{"os":"ubuntu-22.04","r":"4.0"},{"os":"ubuntu-22.04","r":"4.4","covr":"true","desc":"with covr"}]} diff --git a/R/tbl-format-footer.R b/R/tbl-format-footer.R index cfa088165..5cb8b2e00 100644 --- a/R/tbl-format-footer.R +++ b/R/tbl-format-footer.R @@ -61,7 +61,7 @@ format_footer <- function(x, setup) { } format_footer_extra_rows <- function(x, setup) { - if (ncol(setup$x) != 0) { + if (length(setup$df) != 0) { if (is.na(setup$rows_missing)) { c("more", "rows") } else if (setup$rows_missing > 0) { diff --git a/R/tbl-format-setup.R b/R/tbl-format-setup.R index 6038e19b2..9311addc0 100644 --- a/R/tbl-format-setup.R +++ b/R/tbl-format-setup.R @@ -63,10 +63,15 @@ #' @export #' @examplesIf rlang::is_installed("palmerpenguins") #' tbl_format_setup(palmerpenguins::penguins) -tbl_format_setup <- function(x, width = NULL, ..., - n = NULL, max_extra_cols = NULL, - max_footer_lines = NULL, - focus = NULL) { +tbl_format_setup <- function( + x, + width = NULL, + ..., + n = NULL, + max_extra_cols = NULL, + max_footer_lines = NULL, + focus = NULL +) { "!!!!DEBUG tbl_format_setup()" width <- get_width_print(width) @@ -79,8 +84,12 @@ tbl_format_setup <- function(x, width = NULL, ..., # Calls UseMethod("tbl_format_setup"), # allows using default values in S3 dispatch out <- tbl_format_setup_dispatch( - x, width, ..., - n = n, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines, + x, + width, + ..., + n = n, + max_extra_cols = max_extra_cols, + max_footer_lines = max_footer_lines, focus = focus ) return(out) @@ -105,8 +114,9 @@ tbl_format_setup.tbl <- function(x, width, ..., # Number of rows rows <- nrow(x) - if (is.na(rows)) { - df <- df_head(x, n + 1) + lazy <- is.na(rows) + if (lazy) { + df <- as.data.frame(head(x, n + 1)) if (nrow(df) <= n) { rows <- nrow(df) } else { @@ -138,7 +148,7 @@ tbl_format_setup.tbl <- function(x, width, ..., colonnade <- ctl_colonnade( df, - has_row_id = if (.row_names_info(x) > 0) "*" else TRUE, + has_row_id = if (!lazy && .row_names_info(x) > 0) "*" else TRUE, width = width, controller = x, focus = focus @@ -203,11 +213,19 @@ tbl_format_setup.tbl <- function(x, width, ..., #' in the body. #' #' @keywords internal -new_tbl_format_setup <- function(x, df, width, tbl_sum, body, - rows_missing, rows_total, - extra_cols, extra_cols_total, - max_footer_lines, - abbrev_cols) { +new_tbl_format_setup <- function( + x, + df, + width, + tbl_sum, + body, + rows_missing, + rows_total, + extra_cols, + extra_cols_total, + max_footer_lines, + abbrev_cols +) { trunc_info <- list( x = x, df = df, diff --git a/R/tbl-format.R b/R/tbl-format.R index ef44d3da4..2d0c1a831 100644 --- a/R/tbl-format.R +++ b/R/tbl-format.R @@ -41,16 +41,19 @@ format.tbl <- function(x, width = NULL, ..., ) } -format_tbl <- function(x, width = NULL, ..., - n_extra = NULL, - n = NULL, max_extra_cols = NULL, max_footer_lines = NULL) { +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_stop("1.6.2", "pillar::format(n_extra = )", "pillar::format(max_extra_cols = )") - if (is.null(max_extra_cols)) { - max_extra_cols <- n_extra - } } # Reset local cache for each new output diff --git a/tests/testthat/_snaps/tbl-format-setup.md b/tests/testthat/_snaps/tbl-format-setup.md index 293473f07..7b0fdfb6f 100644 --- a/tests/testthat/_snaps/tbl-format-setup.md +++ b/tests/testthat/_snaps/tbl-format-setup.md @@ -1420,7 +1420,7 @@ # A data frame: ?? x 3 Girth Height Volume - * + 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2 @@ -1439,7 +1439,7 @@ # A data frame: ?? x 3 Girth Height Volume - * + 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2 @@ -1459,7 +1459,7 @@ # A data frame: ?? x 3 Girth Height Volume - * + 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2