Title: Supplements the 'gtsummary' Package for Pharmaceutical Reporting
Version: 0.1.0
Description: Tables summarizing clinical trial results are often complex and require detailed tailoring prior to submission to a health authority. The 'crane' package supplements the functionality of the 'gtsummary' package for creating these often highly bespoke tables in the pharmaceutical industry.
License: Apache License 2.0
URL: https://github.com/insightsengineering/crane, https://insightsengineering.github.io/crane/
BugReports: https://github.com/insightsengineering/crane/issues
Depends: R (≥ 4.2)
Imports: cli (≥ 3.6.4), dplyr (≥ 1.1.4), flextable (≥ 0.9.7), gt (≥ 0.11.1), gtsummary (≥ 2.1.0), rlang (≥ 1.1.5)
Suggests: testthat (≥ 3.0.0)
Config/Needs/check: hms
Config/Needs/website: rmarkdown, yaml, insightsengineering/nesttemplate
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-02-21 22:53:07 UTC; sjobergd
Author: Daniel D. Sjoberg ORCID iD [aut, cre], Emily de la Rua [aut], Davide Garolini [aut], Abinaya Yogasekaram [aut], F. Hoffmann-La Roche AG [cph, fnd]
Maintainer: Daniel D. Sjoberg <danield.sjoberg@gmail.com>
Repository: CRAN
Date/Publication: 2025-02-24 17:00:07 UTC

crane: Supplements the 'gtsummary' Package for Pharmaceutical Reporting

Description

Tables summarizing clinical trial results are often complex and require detailed tailoring prior to submission to a health authority. The 'crane' package supplements the functionality of the 'gtsummary' package for creating these often highly bespoke tables in the pharmaceutical industry.

Author(s)

Maintainer: Daniel D. Sjoberg danield.sjoberg@gmail.com (ORCID)

Authors:

Other contributors:

See Also

Useful links:


Add Blank Row

Description

Add a blank row below each variable group. A blank row will not be added to the bottom of the table.

NOTE: For HTML flextable output (which includes the RStudio IDE Viewer), the blank rows do not render. But they will appear when the table is rendered to Word.

Usage

add_blank_row(x)

Arguments

x

(gtsummary)
a 'gtsummary' table. The table must include a column named 'variable' in x$table_body.

Value

updated 'gtsummary' table

Examples

gtsummary::trial |>
  tbl_demographics(
    by = trt,
    include = c(age, marker, grade)
  ) |>
  add_blank_row()

Objects exported from other packages

Description

These objects are imported from other packages. Follow the links below to see their documentation.

dplyr

%>%

gtsummary

all_categorical, all_continuous


Round p-values

Description

Round p-values

Usage

roche_pvalue(
  x,
  big.mark = ifelse(decimal.mark == ",", " ", ","),
  decimal.mark = getOption("OutDec"),
  ...
)

label_roche_pvalue(
  big.mark = ifelse(decimal.mark == ",", " ", ","),
  decimal.mark = getOption("OutDec"),
  ...
)

Arguments

x

(numeric)
Numeric vector of p-values.

big.mark

(string)
Character used between every 3 digits to separate hundreds/thousands/millions/etc. Default is ",", except when decimal.mark = "," when the default is a space.

decimal.mark

(string)
The character to be used to indicate the numeric decimal point. Default is "." or getOption("OutDec")

...

Arguments passed on to base::format()

Value

A character vector of rounded p-values

Examples

x <- c(0.0000001, 0.123456)

roche_pvalue(x)
label_roche_pvalue()(x)

Demographics Table

Description

This is a thin wrapper of gtsummary::tbl_summary() with the following differences:

Usage

tbl_demographics(
  data,
  by = NULL,
  label = NULL,
  statistic = list(all_continuous() ~ c("{mean} ({sd})", "{median}", "{min} - {max}"),
    all_categorical() ~ "{n} ({p}%)"),
  digits = NULL,
  type = NULL,
  value = NULL,
  nonmissing = c("always", "ifany", "no"),
  nonmissing_text = "n",
  nonmissing_stat = "{N_nonmiss}",
  sort = all_categorical(FALSE) ~ "alphanumeric",
  percent = c("column", "row", "cell"),
  include = everything()
)

Arguments

data

(data.frame)
A data frame.

by

(tidy-select)
A single column from data. Summary statistics will be stratified by this variable. Default is NULL.

label

(formula-list-selector)
Used to override default labels in summary table, e.g. list(age = "Age, years"). The default for each variable is the column label attribute, attr(., 'label'). If no label has been set, the column name is used.

statistic

(formula-list-selector)
Specifies summary statistics to display for each variable. The default is list(all_continuous() ~ "{median} ({p25}, {p75})", all_categorical() ~ "{n} ({p}%)"). See below for details.

digits

(formula-list-selector)
Specifies how summary statistics are rounded. Values may be either integer(s) or function(s). If not specified, default formatting is assigned via assign_summary_digits(). See below for details.

type

(formula-list-selector)
Specifies the summary type. Accepted value are c("continuous", "continuous2", "categorical", "dichotomous"). If not specified, default type is assigned via assign_summary_type(). See below for details.

value

(formula-list-selector)
Specifies the level of a variable to display on a single row. The gtsummary type selectors, e.g. all_dichotomous(), cannot be used with this argument. Default is NULL. See below for details.

nonmissing, nonmissing_text, nonmissing_stat

Arguments dictating how and if missing values are presented:

  • nonmissing: must be one of c("always", "ifany", "no")

  • nonmissing_text: string indicating text shown on non-missing row. Default is "n"

  • nonmissing_stat: statistic to show on non-missing row. Default is "{N_nonmiss}". Possible values are N_nonmiss, N_miss, N_obs,, p_nonmiss p_miss.

sort

(formula-list-selector)
Specifies sorting to perform for categorical variables. Values must be one of c("alphanumeric", "frequency"). Default is all_categorical(FALSE) ~ "alphanumeric".

percent

(string)
Indicates the type of percentage to return. Must be one of c("column", "row", "cell"). Default is "column".

include

(tidy-select)
Variables to include in the summary table. Default is everything().

Value

a 'gtsummary' table

Examples

# Example 1 ----------------------------------
gtsummary::trial |>
  tbl_demographics(
    by = trt,
    include = c(age, grade)
  )

Roche Theme

Description

A gtsummary theme for Roche tables

Usage

theme_gtsummary_roche(set_theme = TRUE, font_size = NULL)

Arguments

set_theme

(scalar logical)
Logical indicating whether to set the theme. Default is TRUE. When FALSE the named list of theme elements is returned invisibly

font_size

(scalar numeric)
Numeric font size for compact theme. Default is 13 for gt tables, and 8 for all other output types

Value

theme list

Examples

theme_gtsummary_roche()

tbl_demographics(gtsummary::trial, by = trt, include = c(age, grade))

gtsummary::reset_gtsummary_theme()