Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: crane
Title: Supplements the 'gtsummary' Package for Pharmaceutical Reporting
Version: 0.3.1.9044
Version: 0.3.2
Authors@R: c(
person("Daniel D.", "Sjoberg", , "danield.sjoberg@gmail.com", role = "aut",
comment = c(ORCID = "0000-0003-0862-2018", note = "Original creator of the package")),
Expand Down Expand Up @@ -28,12 +28,12 @@ URL: https://github.com/insightsengineering/crane,
https://insightsengineering.github.io/crane/
BugReports: https://github.com/insightsengineering/crane/issues
Depends:
gtsummary (>= 2.5.0),
gtsummary (>= 2.5.1),
R (>= 4.2)
Imports:
broom (>= 1.0.8),
cards (>= 0.7.0),
cardx (>= 0.3.0),
cards (>= 0.8.0),
cardx (>= 0.3.3),
cli (>= 3.6.4),
cowplot (>= 1.2.0),
dplyr (>= 1.2.0),
Expand Down Expand Up @@ -62,10 +62,6 @@ Suggests:
tidyselect,
withr (>= 3.0.1),
yaml
Remotes:
ddsjoberg/gtsummary@main,
insightsengineering/cards@main,
insightsengineering/cardx@main
Config/Needs/check: hms
Config/Needs/website: rmarkdown, yaml
Config/testthat/edition: 3
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# crane 0.3.1.9044
# crane 0.3.2

## New Functions and Functionality

Expand Down
30 changes: 17 additions & 13 deletions R/add_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,23 @@
#' add_forest(table_engine = "gt")
#'
#' # Realistic example ---------------------------------------------------------
#' trial |>
#' tbl_roche_subgroups(
#' rsp = "response",
#' by = "trt",
#' subgroups = c("grade"),
#' ~ glm(response ~ trt, data = .x) |>
#' gtsummary::tbl_regression(
#' show_single_row = trt,
#' exponentiate = TRUE # , tidy_fun = broom.helpers::tidy_parameters
#' )
#' ) |>
#' add_forest(pvalue = starts_with("p.value"), table_engine = "flextable") |>
#' flextable::set_header_labels(ggplot = "---------")
#' \donttest{
#' if (requireNamespace("broom.helpers", quietly = TRUE)) {
#' trial |>
#' tbl_roche_subgroups(
#' rsp = "response",
#' by = "trt",
#' subgroups = c("grade"),
#' ~ glm(response ~ trt, data = .x) |>
#' gtsummary::tbl_regression(
#' show_single_row = trt,
#' exponentiate = TRUE # , tidy_fun = broom.helpers::tidy_parameters
#' )
#' ) |>
#' add_forest(pvalue = starts_with("p.value"), table_engine = "flextable") |>
#' flextable::set_header_labels(ggplot = "---------")
#' }
#' }
#' @export
add_forest <- function(x,
estimate = starts_with("estimate"),
Expand Down
8 changes: 7 additions & 1 deletion R/adjust_stat_columns_wrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
#' Defaults to `"protect"`.
#'
#' @return A modified `gtsummary` object.
#'
#' @export
#' @examples
#' tbl <- gtsummary::tbl_summary(
#' trial,
#' by = trt,
#' include = c(age, grade)
#' )
#' adjust_stat_columns_wrap(tbl, "protect")
adjust_stat_columns_wrap <- function(tbl, mode = c("protect", "unprotect")) {
# Robustly match the argument (defaults to "protect" if not provided)
mode <- rlang::arg_match(mode)
Expand Down
2 changes: 1 addition & 1 deletion R/annotate_gg_pkc.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' The font size for the table text. Defaults to `3.5`.
#' @param rel_height_plot (`numeric`)\cr
#' Relative height of the plot vs the table. Defaults to `0.75`.
#'
#' @returns A ggplot2 object: a plot with a table at the bottom.
#' @seealso [gg_pkc_lineplot()] for related functionalities.
#' @examples
#' # Prepare PK Data using the built-in Theoph dataset
Expand Down
9 changes: 6 additions & 3 deletions R/deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#' supported.
#'
#' @name deprecated
#' @returns Warnings
#' @examples
#' NULL
#' @keywords internal
NULL

Expand All @@ -25,7 +28,7 @@ tbl_demographics <- function(..., nonmissing = "always") {
#' @export
g_lineplot <- function(...) {
lifecycle::deprecate_soft(
"0.3.1.9017",
"0.3.2",
"crane::g_lineplot()",
"crane::gg_lineplot"
)
Expand All @@ -35,7 +38,7 @@ g_lineplot <- function(...) {
#' @export
g_lineplot_table <- function(...) {
lifecycle::deprecate_soft(
"0.3.1.9017",
"0.3.2",
"crane::g_lineplot_table()",
"crane::annotate_gg()"
)
Expand All @@ -45,7 +48,7 @@ g_lineplot_table <- function(...) {
#' @export
preprocess_lineplot_data <- function(...) {
lifecycle::deprecate_soft(
"0.3.1.9017",
"0.3.2",
"crane::preprocess_lineplot_data()",
"crane::annotate_gg()"
)
Expand Down
4 changes: 4 additions & 0 deletions R/gg_km_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' @return A numeric vector of x-axis tick positions.
#'
#' @keywords internal
#' @examples
#' NULL
h_xticks <- function(data, xticks = NULL, max_time = NULL) {
if (is.null(xticks)) {
if (is.null(max_time)) {
Expand Down Expand Up @@ -46,6 +48,8 @@ h_xticks <- function(data, xticks = NULL, max_time = NULL) {
#' @return A data frame with columns "N", "Median", and the confidence interval label.
#'
#' @keywords internal
#' @examples
#' NULL
h_tbl_median_surv <- function(fit_km, strata_levels = "All") {
y <- if (is.null(fit_km$strata)) {
as.data.frame(t(summary(fit_km)$table), row.names = strata_levels)
Expand Down
10 changes: 10 additions & 0 deletions R/tbl_coxph.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ tbl_coxph <- function(pairwise_df) {
#' @return A `gtsummary` object containing the stacked summary statistics.
#'
#' @keywords internal
#' @examples
#' tbl <- tibble::tibble(
#' comparison_label = "A-B",
#' hr_formatted = "5.21",
#' ci_formatted = "0.25-0.35",
#' pval_formatted = 0.005
#' )
#' crane:::.get_single_comp_table(tbl, pval_label = "p-val")
.get_single_comp_table <- function(data_subset, pval_label = NULL) {
# Check which pre-formatted columns made it into the subset
has_pval <- "pval_formatted" %in% names(data_subset)
Expand Down Expand Up @@ -214,6 +222,8 @@ tbl_coxph <- function(pairwise_df) {
#'
#' @returns A character vector of formatted p-values.
#' @keywords internal
#' @examples
#' crane:::.format_pvalue(0.000156)
.format_pvalue <- function(x) {
if (is.character(x)) {
return(x)
Expand Down
2 changes: 1 addition & 1 deletion R/tbl_listing.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' parameters used in [gtsummary::tbl_split_by_rows()]. See example 4.
#' * Split by columns - you can split the data frame by columns by using `split_by_columns` parameter. Use the same
#' parameters from [gtsummary::tbl_split_by_rows()]. See example 5.
#'
#' @returns A table listing of class "tbl_listing".
#' @examplesIf crane:::is_pkg_installed("labelled")
#' # Load the trial dataset
#' trial_data <- trial |>
Expand Down
2 changes: 1 addition & 1 deletion R/tbl_null_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @param label (`string`)\cr label to display in the header of the null report. It defaults to
#' "No observations met the reporting criteria for this output."
#'
#' @returns A gtsummary object of class tbl_null_report.
#' @examples
#' tbl_null_report(label = "No data available for the selected criteria.")
#'
Expand Down
2 changes: 2 additions & 0 deletions R/tbl_rmpt.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#'
#' # Example 2 --------------------------------
#' # Add overall column at the end
#' \donttest{
#' tbl_rmpt(
#' data = df_adex,
#' variable = AVAL_CAT,
Expand All @@ -103,6 +104,7 @@
#' denominator = df_adsl,
#' label = "Treatment Exposure Duration"
#' )
#' }
#'
NULL
#' @rdname tbl_rmpt
Expand Down
5 changes: 3 additions & 2 deletions R/tbl_roche_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#'
#' @returns a 'gtsummary' table
#'
#' @examples
#' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true")
#' set.seed(1)
#'
#' # prepare sample data
Expand Down Expand Up @@ -49,6 +49,7 @@
#' # coxph regression ----------------------------------------------------------
#' # please use browser() inside .tbl_fun to check if the coxph model throws an error
#' # and use tryCatch to modify the input/output accordingly
#' \donttest{
#' df_adtte |>
#' tbl_roche_subgroups(
#' rsp = status,
Expand All @@ -66,7 +67,7 @@
#' )
#' ) |>
#' modify_header(starts_with("estimate") ~ "**Hazard Ratio**")
#'
#' }
#' @export
tbl_roche_subgroups <- function(data, rsp, by, subgroups, .tbl_fun, time_to_event = NULL) {
set_cli_abort_call()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tbl <- trial |>
tbl_roche_summary(by = trt, include = c(age, grade), nonmissing = "always")
```

<img src="man/figures/README-tbl_print_simple-1.png" width="40%" />
<img src="man/figures/README-tbl_print_simple-1.png" alt="" width="40%" />

The package also exports functions for Roche adverse event reporting,
functions for shift tables, and others.
30 changes: 17 additions & 13 deletions man/add_forest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/adjust_stat_columns_wrap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/annotate_pkc_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/deprecated.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/dot-format_pvalue.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/dot-get_single_comp_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-tbl_print_simple-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions man/h_tbl_median_surv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/h_xticks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/tbl_listing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/tbl_null_report.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/tbl_rmpt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading