diff --git a/R/ID_tbl_length_class.R b/R/ID_tbl_length_class.R index d4842a53..7416ba01 100644 --- a/R/ID_tbl_length_class.R +++ b/R/ID_tbl_length_class.R @@ -31,8 +31,8 @@ ID_tbl_length_class <- function( gt_table <- table_rda$table # Get table length in rows - table_length <- nrow(gt_table) - + table_length <- nrow(gt_table[["_data"]]) + # determine table length class if (table_length <= 38) { length_class <- "regular" # fit on one landscape page (and, by default, portrait) diff --git a/R/ID_tbl_width_class.R b/R/ID_tbl_width_class.R index 50efb2a6..7f3789af 100644 --- a/R/ID_tbl_width_class.R +++ b/R/ID_tbl_width_class.R @@ -40,8 +40,8 @@ ID_tbl_width_class <- function( col_inches <- 1.5 # Calculate total table width in inches - table_width <- ncol(gt_table) * col_inches - + table_width <- ncol(gt_table[["_data"]]) * col_inches + # determine table width class if (table_width <= portrait_pg_width) { width_class <- "regular" diff --git a/R/create_tables_doc.R b/R/create_tables_doc.R index 7d7d10b6..e03be07b 100644 --- a/R/create_tables_doc.R +++ b/R/create_tables_doc.R @@ -302,7 +302,7 @@ load(file.path(tables_dir, '", stringr::str_remove(tab, "_split"), "'))\n load(fs::path(tables_dir, "tables", tab)) # identify number of tables that each split table must be further split # into, with different rows per table - split_table_rows <- length(rda[[1]][[1]]) + split_table_rows <- nrow(rda$table[["_data"]]) split_tables_rowwise <- ceiling(split_table_rows / max_rows) # prepare text for chunk that will display split tables @@ -453,7 +453,7 @@ load(file.path(tables_dir, '", stringr::str_remove(tab, "_split"), "'))\n } # identify number of tables that each split table must be further split # into, with different rows per table - split_table_rows <- length(table_list[[1]]$`_data`[[1]]) + split_table_rows <- nrow(table_list[[1]][["_data"]]) split_tables_rowwise <- ceiling(split_table_rows / max_rows) # add a chunk to import split tables diff --git a/tests/testthat/test-ID_tbl_length_class.R b/tests/testthat/test-ID_tbl_length_class.R index 4941822b..362a4ff8 100644 --- a/tests/testthat/test-ID_tbl_length_class.R +++ b/tests/testthat/test-ID_tbl_length_class.R @@ -10,7 +10,7 @@ test_that("Table length calculated correctly for regular table", { gt() rda <- list( - "table" = test_table[[1]], + "table" = test_table, "caption" = "test_caption" ) @@ -82,7 +82,7 @@ test_that("Table lengths calculated correctly for a long table", { gt() rda <- list( - "table" = test_table[[1]], + "table" = test_table, "caption" = "test_caption" ) diff --git a/tests/testthat/test-ID_tbl_width_class.R b/tests/testthat/test-ID_tbl_width_class.R index eac9c2e2..86d3e19e 100644 --- a/tests/testthat/test-ID_tbl_width_class.R +++ b/tests/testthat/test-ID_tbl_width_class.R @@ -10,7 +10,7 @@ test_that("Table widths calculated correctly for wide table", { gt() rda <- list( - "table" = test_table[[1]], + "table" = test_table, "caption" = "test_caption" ) @@ -65,7 +65,7 @@ test_that("Table widths calculated correctly for extra-wide table", { gt() rda <- list( - "table" = test_table[[1]], + "table" = test_table, "caption" = "test_caption" )