From cf387751620eaedb3ee7efef42e6e1cf7c7a755f Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Tue, 2 Jul 2024 15:06:34 -0700 Subject: [PATCH] removing tibble dep (#1792) --- DESCRIPTION | 1 - R/as_tibble.R | 2 +- R/tests.R | 2 +- R/utils-tbl_regression.R | 2 +- data-raw/trial.R | 2 +- man/as_tibble.gtsummary.Rd | 2 +- tests/testthat/test-add_difference.tbl_summary.R | 4 ++-- tests/testthat/test-add_p.tbl_summary.R | 15 ++++++++------- tests/testthat/test-add_stat.R | 2 +- tests/testthat/test-as_gt.R | 2 +- vignettes/gtsummary_definition.Rmd | 14 +++++++------- vignettes/inline_text.Rmd | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 49c69e0600..8f2255cae8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,6 @@ Imports: gt (>= 0.10.0), lifecycle (>= 1.0.3), rlang (>= 1.1.1), - tibble (>= 3.2.1), tidyr (>= 1.3.0), vctrs Suggests: diff --git a/R/as_tibble.R b/R/as_tibble.R index 9bc4ba7fc7..a7deddef18 100644 --- a/R/as_tibble.R +++ b/R/as_tibble.R @@ -9,7 +9,7 @@ #' Logical argument adding the missing value formats. #' @inheritParams rlang::args_dots_empty #' -#' @return a [tibble][tibble::tibble-package] +#' @return a [tibble](https://tibble.tidyverse.org/) #' #' @author Daniel D. Sjoberg #' @name as_tibble.gtsummary diff --git a/R/tests.R b/R/tests.R index d2cdef75d1..9f3b89f790 100644 --- a/R/tests.R +++ b/R/tests.R @@ -151,7 +151,7 @@ #' The following table describes the argument inputs for each gtsummary table type. #' #' ```{r, echo = FALSE} -#' tibble::tribble( +#' dplyr::tribble( #' ~`**argument**`, ~`**tbl_summary**`, ~`**tbl_svysummary**`, ~`**tbl_survfit**`, ~`**tbl_continuous**`, #' "`data=`", "A data frame", "A survey object", "A `survfit()` object", "A data frame", #' "`variable=`", "String variable name", "String variable name", "`NA`", "String variable name", diff --git a/R/utils-tbl_regression.R b/R/utils-tbl_regression.R index c7c06ce4e5..f967f968e1 100644 --- a/R/utils-tbl_regression.R +++ b/R/utils-tbl_regression.R @@ -35,7 +35,7 @@ tidy_prep <- function(x, tidy_fun, exponentiate, conf.level, intercept, label, {dplyr::bind_cols( ., attributes(.)[names(attributes(.)) %in% c("N_obs", "N_event", "coefficients_type", "coefficients_label")] %>% - tibble::as_tibble() + dplyr::as_tibble() )} # styler: on diff --git a/data-raw/trial.R b/data-raw/trial.R index 0618860961..40f853a56f 100644 --- a/data-raw/trial.R +++ b/data-raw/trial.R @@ -3,7 +3,7 @@ set.seed(8976) n <- 200 trial <- - tibble::tibble( + dplyr::tibble( trt = sample(c("Drug A", "Drug B"), n, replace = TRUE), age = rnorm(n, mean = 50, sd = 15) %>% as.integer(), marker = rgamma(n, 1, 1) %>% round(digits = 3), diff --git a/man/as_tibble.gtsummary.Rd b/man/as_tibble.gtsummary.Rd index 908362982f..77e4c54593 100644 --- a/man/as_tibble.gtsummary.Rd +++ b/man/as_tibble.gtsummary.Rd @@ -37,7 +37,7 @@ Logical argument adding the missing value formats.} \item{...}{Arguments passed on to \code{gt::gt(...)}} } \value{ -a \link[tibble:tibble-package]{tibble} +a \href{https://tibble.tidyverse.org/}{tibble} } \description{ Function converts a gtsummary object to a tibble. diff --git a/tests/testthat/test-add_difference.tbl_summary.R b/tests/testthat/test-add_difference.tbl_summary.R index 852593ef3c..78d89f9fcc 100644 --- a/tests/testthat/test-add_difference.tbl_summary.R +++ b/tests/testthat/test-add_difference.tbl_summary.R @@ -326,7 +326,7 @@ test_that("statistics are replicated within add_difference.tbl_summary()", { verbose = FALSE ) ) |> - tibble::as_tibble() |> + dplyr::as_tibble() |> select(-CI) |> set_names(c("estimate", "conf.low", "conf.high")), ignore_attr = TRUE @@ -350,7 +350,7 @@ test_that("statistics are replicated within add_difference.tbl_summary()", { verbose = FALSE ) ) |> - tibble::as_tibble() |> + dplyr::as_tibble() |> select(-CI) |> set_names(c("estimate", "conf.low", "conf.high")), ignore_attr = TRUE diff --git a/tests/testthat/test-add_p.tbl_summary.R b/tests/testthat/test-add_p.tbl_summary.R index 1342b441d0..5ff12eefdb 100644 --- a/tests/testthat/test-add_p.tbl_summary.R +++ b/tests/testthat/test-add_p.tbl_summary.R @@ -502,13 +502,14 @@ test_that("add_p.tbl_summary() can be run after add_difference()", { test_that("addressing GH #1513, where the default test was incorrect", { expect_equal( # before the fix, this was defaulting to a chi-squared, when it should be fisher - tibble::tibble(type = character(), answer = character()) |> - tibble::add_row(tidyr::uncount(tibble::tibble(type = "A", answer = "C1"), 5)) |> - tibble::add_row(tidyr::uncount(tibble::tibble(type = "B", answer = "C1"), 10)) |> - tibble::add_row(tidyr::uncount(tibble::tibble(type = "A", answer = "C2"), 100)) |> - tibble::add_row(tidyr::uncount(tibble::tibble(type = "B", answer = "C2"), 305)) |> - tibble::add_row(tidyr::uncount(tibble::tibble(type = "A", answer = NA), 400)) |> - tibble::add_row(tidyr::uncount(tibble::tibble(type = "B", answer = NA), 300)) |> + dplyr::bind_rows( + tidyr::uncount(dplyr::tibble(type = "A", answer = "C1"), 5), + tidyr::uncount(dplyr::tibble(type = "B", answer = "C1"), 10), + tidyr::uncount(dplyr::tibble(type = "A", answer = "C2"), 100), + tidyr::uncount(dplyr::tibble(type = "B", answer = "C2"), 305), + tidyr::uncount(dplyr::tibble(type = "A", answer = NA), 400), + tidyr::uncount(dplyr::tibble(type = "B", answer = NA), 300) + ) |> tbl_summary(by = type) |> assign_tests(include = "answer", calling_fun = "add_p") |> getElement(1L) |> diff --git a/tests/testthat/test-add_stat.R b/tests/testthat/test-add_stat.R index 644ac3f70b..5dab988b31 100644 --- a/tests/testthat/test-add_stat.R +++ b/tests/testthat/test-add_stat.R @@ -181,7 +181,7 @@ test_that("add_stat() for 'tbl_continuous'", { ) add_stat_test1 <- function(data, variable, by, ...) { - tibble::tibble(addtl = "Data from elsewhere") + dplyr::tibble(addtl = "Data from elsewhere") } expect_equal( diff --git a/tests/testthat/test-as_gt.R b/tests/testthat/test-as_gt.R index ba23b458bd..9870d6583c 100644 --- a/tests/testthat/test-as_gt.R +++ b/tests/testthat/test-as_gt.R @@ -298,7 +298,7 @@ test_that("as_gt passes appended glance statistics correctly", { gt_tbl <- tbl |> as_gt() loc_hline <- tbl$table_body |> - tibble::rownames_to_column() |> + rownames_to_column() |> dplyr::filter(!!tbl$table_styling$horizontal_line_above) |> dplyr::pull(rowname) |> as.numeric() diff --git a/vignettes/gtsummary_definition.Rmd b/vignettes/gtsummary_definition.Rmd index 221ef900ff..b0de31f450 100644 --- a/vignettes/gtsummary_definition.Rmd +++ b/vignettes/gtsummary_definition.Rmd @@ -66,7 +66,7 @@ The `header` table has the following columns and is one row per column found in The table contains styling information that applies to entire column or the columns headers. ```{r, echo=FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "column", "Column name from `.$table_body`", "hide", "Logical indicating whether the column is hidden in the output. This column is also scoped in `modify_header()` (and friends) to be used in a selecting environment", @@ -99,7 +99,7 @@ Updates/changes to footnote are appended to the bottom of the tibble. A footnote of `NA_character_` deletes an existing footnote. ```{r, echo=FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "column", "Column name from `.$table_body`", "rows", "expression selecting rows in `.$table_body`, `NA` indicates to add footnote to header", @@ -125,7 +125,7 @@ Updates/changes to styling functions are appended to the bottom of the tibble. ```{r, echo=FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "column", "Column name from `.$table_body`", "rows", "expression selecting rows in `.$table_body`", @@ -151,7 +151,7 @@ Updates/changes to styling functions are appended to the bottom of the tibble. ```{r, echo=FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "column", "Column name from `.$table_body`", "rows", "expression selecting rows in `.$table_body`", @@ -179,7 +179,7 @@ For example, reference rows in `tbl_regression()` are shown with an em-dash. Updates/changes to styling functions are appended to the bottom of the tibble. ```{r, echo=FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "column", "Column name from `.$table_body`", "rows", "expression selecting rows in `.$table_body`", @@ -205,7 +205,7 @@ This tibble gives instructions for merging columns into a single column. The implementation in `as_gt()` will be updated after `gt::cols_label()` gains a `rows=` argument. ```{r, echo=FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "column", "Column name from `.$table_body`", "rows", "expression selecting rows in `.$table_body`", @@ -309,7 +309,7 @@ While the statistics contained in each `"df_stats"` tibble can vary within a sin Each tibble contain the following columns ```{r, echo = FALSE} -tibble::tribble( +dplyr::tribble( ~Column, ~Description, "`variable`", "String of the variable name", "`label`", "String matching the variable's values in `.$table_body$label`", diff --git a/vignettes/inline_text.Rmd b/vignettes/inline_text.Rmd index f9e4d069f1..894c74f276 100644 --- a/vignettes/inline_text.Rmd +++ b/vignettes/inline_text.Rmd @@ -135,7 +135,7 @@ The `pattern` argument syntax follows `glue::glue()` format with referenced R ob The default is `pattern = "{estimate} ({conf.level*100}% CI {conf.low}, {conf.high}; {p.value})"`. You have access the to following fields within the `pattern` argument. ```{r, echo = FALSE} -tibble::tribble( +dplyr::tribble( ~Parameter, ~Description, "`{estimate}`", "primary estimate (e.g. model coefficient, odds ratio)", "`{conf.low}`", "lower limit of confidence interval",