diff --git a/main/404.html b/main/404.html index 6a5947dd3e..54961ad763 100644 --- a/main/404.html +++ b/main/404.html @@ -1,5 +1,4 @@ - - + @@ -58,7 +57,38 @@
  • Non-CRAN unit test report
  • - +
    + + @@ -48,65 +109,80 @@
    -

    Our Pledge

    +

    Our Pledge +

    We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

    We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

    -

    Our Standards

    +

    Our Standards +

    Examples of behavior that contributes to a positive environment for our community include:

    -
    + +
    -

    Enforcement Responsibilities

    +

    Enforcement Responsibilities +

    Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

    Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

    -

    Scope

    +

    Scope +

    This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

    -

    Enforcement

    +

    Enforcement +

    Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.

    All community leaders are obligated to respect the privacy and security of the reporter of any incident.

    -

    Enforcement Guidelines

    +

    Enforcement Guidelines +

    Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

    -

    1. Correction

    +

    1. Correction +

    Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

    Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

    -

    2. Warning

    +

    2. Warning +

    Community Impact: A violation through a single incident or series of actions.

    Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

    -

    3. Temporary Ban

    +

    3. Temporary Ban +

    Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

    Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

    -

    4. Permanent Ban

    +

    4. Permanent Ban +

    Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

    Consequence: A permanent ban from any sort of public interaction within the community.

    -

    Attribution

    +

    Attribution +

    This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

    Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder.

    For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

    @@ -114,17 +190,19 @@

    Attribution

    + + - + + - + + diff --git a/main/CONTRIBUTING.html b/main/CONTRIBUTING.html index 8311d22f8d..79979c8812 100644 --- a/main/CONTRIBUTING.html +++ b/main/CONTRIBUTING.html @@ -1,5 +1,26 @@ - -Contribution Guidelines • tern + + + + + + +Contribution Guidelines • tern + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +36,66 @@ + + @@ -50,7 +111,8 @@

    🙏 Thank you for taking the time to contribute!

    Your input is deeply valued, whether an issue, a pull request, or even feedback, regardless of size, content or scope.

    -

    Table of contents

    +

    Table of contents +

    👶 Getting started

    📔 Code of Conduct

    🗃 License

    @@ -61,38 +123,47 @@

    Table of contents❓ Questions

    -

    Getting started

    +

    Getting started +

    Please refer the project documentation for a brief introduction. Please also see other articles within the project documentation for additional information.

    -

    Code of Conduct

    +

    Code of Conduct +

    A Code of Conduct governs this project. Participants and contributors are expected to follow the rules outlined therein.

    -

    License

    +

    License +

    All your contributions will be covered by this project’s license.

    -

    Issues

    +

    Issues +

    We use GitHub to track issues, feature requests, and bugs. Before submitting a new issue, please check if the issue has already been reported. If the issue already exists, please upvote the existing issue 👍.

    For new feature requests, please elaborate on the context and the benefit the feature will have for users, developers, or other relevant personas.

    -

    Pull requests

    +

    Pull requests +

    -

    GitHub Flow

    +

    GitHub Flow +

    This repository uses the GitHub Flow model for collaboration. To submit a pull request:

    -
    1. +
        +
      1. Create a branch

        Please see the branch naming convention below. If you don’t have write access to this repository, please fork it.

      2. Make changes

        Make sure your code

        -
        • passes all checks imposed by GitHub Actions
        • +
            +
          • passes all checks imposed by GitHub Actions
          • is well documented
          • is well tested with unit tests sufficiently covering the changes introduced
          • -
          +
        +
      3. Create a pull request (PR)

        In the pull request description, please link the relevant issue (if any), provide a detailed description of the change, and include any assumptions.

        @@ -106,76 +177,93 @@

        GitHub Flow -

        Branch naming convention

        +

        Branch naming convention +

        Suppose your changes are related to a current issue in the current project; please name your branch as follows: <issue_id>_<short_description>. Please use underscore (_) as a delimiter for word separation. For example, 420_fix_ui_bug would be a suitable branch name if your change is resolving and UI-related bug reported in issue number 420 in the current project.

        If your change affects multiple repositories, please name your branches as follows: <issue_id>_<issue_repo>_<short description>. For example, 69_awesomeproject_fix_spelling_error would reference issue 69 reported in project awesomeproject and aims to resolve one or more spelling errors in multiple (likely related) repositories.

    monorepo and staged.dependencies -

    + +

    Sometimes you might need to change upstream dependent package(s) to be able to submit a meaningful change. We are using staged.dependencies functionality to simulate a monorepo behavior. The dependency configuration is already specified in this project’s staged_dependencies.yaml file. You need to name the feature branches appropriately. This is the only exception from the branch naming convention described above.

    Please refer to the staged.dependencies package documentation for more details.

    -

    Coding guidelines

    +

    Coding guidelines +

    This repository follows some unified processes and standards adopted by its maintainers to ensure software development is carried out consistently within teams and cohesively across other repositories.

    -

    Style guide

    +

    Style guide +

    This repository follows the standard tidyverse style guide and uses lintr for lint checks. Customized lint configurations are available in this repository’s .lintr file.

    -

    Dependency management

    +

    Dependency management +

    Lightweight is the right weight. This repository follows tinyverse recommedations of limiting dependencies to minimum.

    -

    Dependency version management

    +

    Dependency version management +

    If the code is not compatible with all (!) historical versions of a given dependenct package, it is required to specify minimal version in the DESCRIPTION file. In particular: if the development version requires (imports) the development version of another package - it is required to put abc (>= 1.2.3.9000).

    - +
    -

    R & package versions

    +

    R & package versions +

    We continuously test our packages against the newest R version along with the most recent dependencies from CRAN and BioConductor. We recommend that your working environment is also set up in the same way. You can find the details about the R version and packages used in the R CMD check GitHub Action execution log - there is a step that prints out the R sessionInfo().

    If you discover bugs on older R versions or with an older set of dependencies, please create the relevant bug reports.

    -

    pre-commit

    +

    +pre-commit +

    We highly recommend that you use the pre-commit tool combined with R hooks for pre-commit to execute some of the checks before committing and pushing your changes.

    Pre-commit hooks are already available in this repository’s .pre-commit-config.yaml file.

    -

    Recognition model

    +

    Recognition model +

    As mentioned previously, all contributions are deeply valued and appreciated. While all contribution data is available as part of the repository insights, to recognize a significant contribution and hence add the contributor to the package authors list, the following rules are enforced:

    - +

    *Excluding auto-generated code, including but not limited to roxygen comments or renv.lock files.

    The package maintainer also reserves the right to adjust the criteria to recognize contributions.

    -

    Questions

    +

    Questions +

    If you have further questions regarding the contribution guidelines, please contact the package/repository maintainer.

    + + - + + - + + diff --git a/main/LICENSE-text.html b/main/LICENSE-text.html index a6dba8d575..8e8a0db7e7 100644 --- a/main/LICENSE-text.html +++ b/main/LICENSE-text.html @@ -1,5 +1,26 @@ - -License • tern + + + + + + +License • tern + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +36,66 @@ + + @@ -60,17 +121,19 @@ limitations under the License. - + + - + + - + + diff --git a/main/SECURITY.html b/main/SECURITY.html index 917610d566..8ea6e4de37 100644 --- a/main/SECURITY.html +++ b/main/SECURITY.html @@ -1,5 +1,26 @@ - -Security Policy • tern + + + + + + +Security Policy • tern + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +36,66 @@ + + @@ -48,38 +109,44 @@
    -

    Reporting Security Issues

    +

    Reporting Security Issues +

    If you believe you have found a security vulnerability in any of the repositories in this organization, please report it to us through coordinated disclosure.

    Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.

    Instead, please send an email to vulnerability.management[@]roche.com.

    Please include as much of the information listed below as you can to help us better understand and resolve the issue:

    - +

    This information will help us triage your report more quickly.

    -

    Data Security Standards (DSS)

    +

    Data Security Standards (DSS) +

    Please make sure that while reporting issues in the form a bug, feature, or pull request, all sensitive information such as PII, PHI, and PCI is completely removed from any text and attachments, including pictures and videos.

    + + - + + - + + diff --git a/main/articles/index.html b/main/articles/index.html index f188c1efbd..df4804e2a7 100644 --- a/main/articles/index.html +++ b/main/articles/index.html @@ -1,5 +1,26 @@ - -Articles • tern + + + + + + +Articles • tern + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +36,66 @@ + + @@ -48,28 +109,37 @@

    All vignettes

    -
    Missing Values in Tern
    +
    +
    Missing Values in Tern
    -
    Tabulation
    + +
    Tabulation
    -
    Formatting Functions
    + +
    Formatting Functions
    -
    Understanding `tern` functions
    + +
    Understanding `tern` functions
    -
    Introduction to tern
    + +
    Introduction to tern
    -
    - + +
    + + + - + + - + + diff --git a/main/articles/missing_values.html b/main/articles/missing_values.html index 5495ce0a8b..f37d894493 100644 --- a/main/articles/missing_values.html +++ b/main/articles/missing_values.html @@ -1,5 +1,4 @@ - - + @@ -57,7 +56,38 @@
  • Non-CRAN unit test report
  • - +
    + - +
    + - +
    + - +
    + - +
    + + @@ -47,7 +108,8 @@

    Authors

    -
    + +

    Citation

    @@ -121,17 +184,19 @@

    Citation

    + + - + + - + + diff --git a/main/index.html b/main/index.html index 3c0d841ae0..734990b06a 100644 --- a/main/index.html +++ b/main/index.html @@ -1,5 +1,4 @@ - - + @@ -60,7 +59,38 @@
  • Non-CRAN unit test report
  • - +
    + + @@ -46,10 +107,13 @@
    -

    tern 0.9.6.9015

    +

    tern 0.9.6.9015 +

    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    +

    Bug Fixes +

    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.9.6

    CRAN release: 2024-09-24

    -
    -

    Enhancements

    - +
    -

    Bug Fixes

    -
    + +
    -

    tern 0.9.5

    CRAN release: 2024-06-21

    -
    -

    Enhancements

    - +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    +

    Miscellaneous +

    + +
    -

    tern 0.9.4

    CRAN release: 2024-04-17

    -
    -

    New Features

    - +
    -

    Enhancements

    -
    +

    Enhancements +

    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.9.3

    CRAN release: 2023-12-08

    -
    -

    New Features

    - +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.9.2

    -
    -

    New Features

    -
    +

    tern 0.9.2 +

    +
    +

    New Features +

    + +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    +

    Bug Fixes +

    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.9.1

    +

    tern 0.9.1 +

    -

    New Features

    -
    + +
    -

    Enhancements

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.9.0

    CRAN release: 2023-09-01

    -
    -

    New Features

    - +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.8.5

    +

    tern 0.8.5 +

    -

    Enhancements

    -
    + +
    -

    Miscellaneous

    -
    +

    Miscellaneous +

    + +
    -

    tern 0.8.4

    CRAN release: 2023-06-27

    -
    -

    Enhancements

    -
    +

    tern 0.8.4 +

    +

    CRAN release: 2023-06-27

    +
    +

    Enhancements +

    + +
    -

    Miscellaneous

    -
    + +
    -

    Bug Fixes

    -
    +

    Bug Fixes +

    + +
    -

    tern 0.8.3

    CRAN release: 2023-06-19

    -
    -

    Enhancements

    - +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.8.2

    -
    -

    Breaking Changes

    -
    +

    tern 0.8.2 +

    +
    +

    Breaking Changes +

    + +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.8.0

    +

    tern 0.8.0 +

    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.7.10

    +

    tern 0.7.10 +

    -

    New Features

    -
    + +
    -

    Enhancements

    -
    + +

    Migration from assertthat to checkmate -

    -
    + +
    -

    Documentation and NAMESPACE Polishing

    -
    + + + +
    -

    Bug Fixes

    -
    + +
    -

    tern 0.7.8

    +

    tern 0.7.8 +

    -

    Fix

    -
    + +
    -

    Documentation and NAMESPACE polishing

    -
    + +
    -

    Enhancements

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.7.7

    -
    -

    Breaking changes

    -
    +

    tern 0.7.7 +

    +
    +

    Breaking changes +

    + +
    -

    New features

    -
    + +
    -

    Enhancements

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.7.6

    +

    tern 0.7.6 +

    -

    New features

    -
    + +
    -

    Enhancements

    -
    + +
    -

    Bug fixes

    -
    +

    Bug fixes +

    + +
    -

    Miscellaneous

    -
    +

    Miscellaneous +

    + +
    -

    tern 0.7.5

    +

    tern 0.7.5 +

    -

    New features

    -
    + +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + + + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.7.4

    -
    -

    New features

    - +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.7.3

    +

    tern 0.7.3 +

    -

    New Features

    -
    + + + +
    -

    Enhancements

    -
    + +
    -

    Bug Fixes

    -
    + +
    -

    Miscellaneous

    -
    + +
    -

    tern 0.7.2

    -
    +

    tern 0.7.2 +

    + +
    -

    tern 0.7.1

    -
    -

    tern 0.6.9

    -
    +

    tern 0.6.9 +

    + +
    -

    tern 0.6.8

    -
    +

    tern 0.6.6 +

    + +
    -

    tern 0.6.5

    -
    + +
    -

    tern 0.6.3

    -
    + +
    -

    tern 0.6.1

    -
    + +
    -

    tern 0.5.0.3

    +

    tern 0.5.0.3 +

    -
    New TLGs
    -
    + +
    -
    TLG changes
    -
    + +
    -
    Deprecated Functions
    -
    + +
    -

    tern 0.5.0

    -
    +

    tern 0.5.0 +

    + + + + - + + - + + diff --git a/main/reference/abnormal.html b/main/reference/abnormal.html index c4aaa83914..803034b58a 100644 --- a/main/reference/abnormal.html +++ b/main/reference/abnormal.html @@ -1,5 +1,22 @@ - -Count patients with abnormal range values — abnormal • tern + + + + + +Count patients with abnormal range values — abnormal • tern + + + + + + + + + + + + + +This function assumes that df has been filtered to only include post-baseline records."> + + + + + Skip to contents @@ -41,26 +64,66 @@ + + @@ -81,13 +144,17 @@ id (defaults to USUBJID), a variable to indicate unique subject identifiers, and baseline (defaults to BNRIND), a variable to indicate baseline reference ranges.

    For each direction specified via the abnormal parameter (e.g. High or Low), a fraction of -patient counts is returned, with numerator and denominator calculated as follows:

    +

    This function assumes that df has been filtered to only include post-baseline records.

    -

    Usage

    +

    Usage +

    count_abnormal(
       lyt,
       var,
    @@ -122,106 +189,139 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    abnormal
    +
    abnormal +

    (named list)
    list identifying the abnormal range level(s) in var. Defaults to list(Low = "LOW", High = "HIGH") but you can also group different levels into the named list, for example, abnormal = list(Low = c("LOW", "LOW LOW"), High = c("HIGH", "HIGH HIGH")).

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    exclude_base_abn
    +
    exclude_base_abn +

    (flag)
    whether to exclude subjects with baseline abnormality from numerator and denominator.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'fraction'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'fraction'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    + +
    -

    Value

    +

    Value +

    -
    + + + +
    -

    Functions

    +

    Functions +

    -
    + +
    -

    Note

    +

    Note +

    -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     #> 
     #> Attaching package: ‘dplyr’
    @@ -284,17 +384,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/abnormal_by_baseline.html b/main/reference/abnormal_by_baseline.html index c62e47a071..db54d3cd6e 100644 --- a/main/reference/abnormal_by_baseline.html +++ b/main/reference/abnormal_by_baseline.html @@ -1,5 +1,22 @@ - -Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline • tern + + + + + +Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline • tern + + + + + + + + + + + + + +This function assumes that df has been filtered to only include post-baseline records."> + + + + + Skip to contents @@ -67,26 +90,66 @@ + + @@ -108,22 +171,38 @@ variable to indicate baseline reference ranges.

    For each direction specified via the abnormal parameter (e.g. High or Low), we condition on baseline range result and count patients in the numerator and denominator as follows for each of the following -categories:

    +

    This function assumes that df has been filtered to only include post-baseline records.

    -

    Usage

    +

    Usage +

    count_abnormal_by_baseline(
       lyt,
       var,
    @@ -157,102 +236,135 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    abnormal
    +
    abnormal +

    (character)
    values identifying the abnormal range level(s) in .var.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    na_str
    +
    na_str +

    (string)
    the explicit na_level argument you used in the pre-processing steps (maybe with df_explicit_na()). The default is "<Missing>".

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'fraction'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'fraction'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_abnormal_by_baseline() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_abnormal_by_baseline() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_abnormal_by_baseline() to the table layout.

      • -
      • s_count_abnormal_by_baseline() returns statistic fraction which is a named list with 3 labeled elements: +

      +
        +
      • s_count_abnormal_by_baseline() returns statistic fraction which is a named list with 3 labeled elements: not_abnormal, abnormal, and total. Each element contains a vector with num and denom patient counts.

      • -
      • a_count_abnormal_by_baseline() returns the corresponding list with formatted rtables::CellValue().

      • -
    + +
      +
    • a_count_abnormal_by_baseline() returns the corresponding list with formatted rtables::CellValue().

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • count_abnormal_by_baseline(): Layout-creating function which can take statistics function arguments +

        +
      • count_abnormal_by_baseline(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_abnormal_by_baseline(): Statistics function for a single abnormal level.

      • a_count_abnormal_by_baseline(): Formatted analysis function which is used as afun in count_abnormal_by_baseline().

      • -
    + +
    -

    Note

    +

    Note +

    -
    • df should be filtered to include only post-baseline records.

    • +
        +
      • df should be filtered to include only post-baseline records.

      • If the baseline variable or analysis variable contains NA records, it is expected that df has been pre-processed using df_explicit_na() or explicit_na().

      • -
    + +
    -

    See also

    +

    See also +

    Relevant description function d_count_abnormal_by_baseline().

    -

    Examples

    +

    Examples +

    df <- data.frame(
       USUBJID = as.character(c(1:6)),
       ANRIND = factor(c(rep("LOW", 4), "NORMAL", "HIGH")),
    @@ -297,17 +409,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/abnormal_by_marked.html b/main/reference/abnormal_by_marked.html index 4a0eeab5da..fc2e4bdd2a 100644 --- a/main/reference/abnormal_by_marked.html +++ b/main/reference/abnormal_by_marked.html @@ -1,5 +1,22 @@ - -Count patients with marked laboratory abnormalities — abnormal_by_marked • tern + + + + + +Count patients with marked laboratory abnormalities — abnormal_by_marked • tern + + + + + + + + + + + + + +row splits, one on variable param and one on variable direction."> + + + + + Skip to contents @@ -55,26 +78,66 @@ + + @@ -98,17 +161,21 @@ variable to indicate parameter values, and direction (defaults to abn_dir), a variable to indicate abnormality directions.

    For each combination of param and direction levels, marked lab abnormality counts are calculated -as follows:

    • Single, not last & Last or replicated: The number of patients with Single, not last +as follows:

      +
        +
      • Single, not last & Last or replicated: The number of patients with Single, not last and Last or replicated values, respectively.

      • Any: The number of patients with either single or replicated marked abnormalities.

      • -

      Fractions are calculated by dividing the above counts by the number of patients with at least one +

    +

    Fractions are calculated by dividing the above counts by the number of patients with at least one valid measurement recorded during the analysis.

    Prior to using this function in your table layout you must use rtables::split_rows_by() to create two row splits, one on variable param and one on variable direction.

    -

    Usage

    +

    Usage +

    count_abnormal_by_marked(
       lyt,
       var,
    @@ -141,97 +208,127 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    category
    +
    category +

    (list)
    a list with different marked category names for single and last or replicated.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .spl_context
    +
    .spl_context +

    (data.frame)
    gives information about ancestor split states that is passed by rtables.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_abnormal_by_marked() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_abnormal_by_marked() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_abnormal_by_marked() to the table layout.

      • -
      • s_count_abnormal_by_marked() returns statistic count_fraction with Single, not last, +

      +
        +
      • s_count_abnormal_by_marked() returns statistic count_fraction with Single, not last, Last or replicated, and Any results.

      • -
    + +
      +
    • a_count_abnormal_by_marked() returns the corresponding list with formatted rtables::CellValue().

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • count_abnormal_by_marked(): Layout-creating function which can take statistics function arguments +

        +
      • count_abnormal_by_marked(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_abnormal_by_marked(): Statistics function for patients with marked lab abnormalities.

      • a_count_abnormal_by_marked(): Formatted analysis function which is used as afun in count_abnormal_by_marked().

      • -
    + +
    -

    Note

    +

    Note +

    Single, not last and Last or replicated levels are mutually exclusive. If a patient has abnormalities that meet both the Single, not last and Last or replicated criteria, then the patient will be counted only under the Last or replicated category.

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     df <- data.frame(
    @@ -347,17 +444,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/abnormal_by_worst_grade.html b/main/reference/abnormal_by_worst_grade.html index 723a1c3525..fe093af1a5 100644 --- a/main/reference/abnormal_by_worst_grade.html +++ b/main/reference/abnormal_by_worst_grade.html @@ -1,5 +1,22 @@ - -Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade • tern + + + + + +Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade • tern + + + + + + + + + + + + + +splits, one on variable param and one on variable grade_dir."> + + + + + Skip to contents @@ -55,26 +78,66 @@ + + @@ -96,9 +159,12 @@ to indicate parameter values, and grade_dir (defaults to GRADE_DIR), a variable to indicate directions (e.g. High or Low) for each toxicity grade supplied in var.

    For each combination of param and grade_dir levels, patient counts by worst -grade are calculated as follows:

    • 1 to 4: The number of patients with worst grades 1-4, respectively.

    • +grade are calculated as follows:

      +
        +
      • 1 to 4: The number of patients with worst grades 1-4, respectively.

      • Any: The number of patients with at least one abnormality (i.e. grade is not 0).

      • -

      Fractions are calculated by dividing the above counts by the number of patients with at least one +

    +

    Fractions are calculated by dividing the above counts by the number of patients with at least one valid measurement recorded during treatment.

    Pre-processing is crucial when using this function and can be done automatically using the h_adlb_abnormal_by_worst_grade() helper function. See the description of this function for details on the @@ -108,7 +174,8 @@

    -

    Usage

    +

    Usage +

    count_abnormal_by_worst_grade(
       lyt,
       var,
    @@ -138,91 +205,120 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .spl_context
    +
    .spl_context +

    (data.frame)
    gives information about ancestor split states that is passed by rtables.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_abnormal_by_worst_grade() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_abnormal_by_worst_grade() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_abnormal_by_worst_grade() to the table layout.

      • -
      • s_count_abnormal_by_worst_grade() returns the single statistic count_fraction with grades 1 to 4 and +

      +
        +
      • s_count_abnormal_by_worst_grade() returns the single statistic count_fraction with grades 1 to 4 and "Any" results.

      • -
      • a_count_abnormal_by_worst_grade() returns the corresponding list with formatted rtables::CellValue().

      • -
    + +
      +
    • a_count_abnormal_by_worst_grade() returns the corresponding list with formatted rtables::CellValue().

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • count_abnormal_by_worst_grade(): Layout-creating function which can take statistics function arguments +

        +
      • count_abnormal_by_worst_grade(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_abnormal_by_worst_grade(): Statistics function which counts patients by worst grade.

      • a_count_abnormal_by_worst_grade(): Formatted analysis function which is used as afun in count_abnormal_by_worst_grade().

      • -
    + +
    -

    See also

    +

    See also +

    h_adlb_abnormal_by_worst_grade() which pre-processes ADLB data frames to be used in count_abnormal_by_worst_grade().

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(forcats)
     adlb <- tern_ex_adlb
    @@ -289,17 +385,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/abnormal_by_worst_grade_worsen.html b/main/reference/abnormal_by_worst_grade_worsen.html index 94cfc66f4e..85cc4e364a 100644 --- a/main/reference/abnormal_by_worst_grade_worsen.html +++ b/main/reference/abnormal_by_worst_grade_worsen.html @@ -1,5 +1,22 @@ - -Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen • tern + + + + + +Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen • tern + + + + + + + + + + + + + +split on variable direction_var."> + + + + + Skip to contents @@ -51,26 +74,66 @@ + + @@ -92,17 +155,21 @@ baseline toxicity grades, and direction_var (defaults to GRADDIR), a variable to indicate toxicity grade directions of interest to include (e.g. "H" (high), "L" (low), or "B" (both)).

    For the direction(s) specified in direction_var, patient counts by worst grade for patients who have -worsened from baseline are calculated as follows:

    • 1 to 4: The number of patients who have worsened from their baseline grades with worst +worsened from baseline are calculated as follows:

      +
        +
      • 1 to 4: The number of patients who have worsened from their baseline grades with worst grades 1-4, respectively.

      • Any: The total number of patients who have worsened from their baseline grades.

      • -

      Fractions are calculated by dividing the above counts by the number of patients who's analysis toxicity grades +

    +

    Fractions are calculated by dividing the above counts by the number of patients who's analysis toxicity grades have worsened from baseline toxicity grades during treatment.

    Prior to using this function in your table layout you must use rtables::split_rows_by() to create a row split on variable direction_var.

    -

    Usage

    +

    Usage +

    count_abnormal_lab_worsen_by_baseline(
       lyt,
       var,
    @@ -131,97 +198,130 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    variables
    -

    (named list of string)
    list of additional analysis variables including:

    • id (string)
      subject variable name.

    • +
      variables +
      +
      +

      (named list of string)
      list of additional analysis variables including:

      +
        +
      • id (string)
        subject variable name.

      • baseline_var (string)
        name of the data column containing baseline toxicity variable.

      • direction_var (string)
        see direction_var for more details.

      • -
      +
    +
    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'fraction'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'fraction'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_abnormal_lab_worsen_by_baseline() returns a layout object suitable for passing to further layouting +

        +
      • count_abnormal_lab_worsen_by_baseline() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_abnormal_lab_worsen_by_baseline() to the table layout.

      • -
      • s_count_abnormal_lab_worsen_by_baseline() returns the counts and fraction of patients whose worst +

      +
        +
      • s_count_abnormal_lab_worsen_by_baseline() returns the counts and fraction of patients whose worst post-baseline lab grades are worse than their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".

      • -
      • a_count_abnormal_lab_worsen_by_baseline() returns the corresponding list with +

      +
        +
      • a_count_abnormal_lab_worsen_by_baseline() returns the corresponding list with formatted rtables::CellValue().

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • count_abnormal_lab_worsen_by_baseline(): Layout-creating function which can take statistics function +

        +
      • count_abnormal_lab_worsen_by_baseline(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_abnormal_lab_worsen_by_baseline(): Statistics function for patients whose worst post-baseline lab grades are worse than their baseline grades.

      • a_count_abnormal_lab_worsen_by_baseline(): Formatted analysis function which is used as afun in count_abnormal_lab_worsen_by_baseline().

      • -
    + +
    -

    See also

    +

    See also +

    Relevant helper functions h_adlb_worsen() and h_worsen_counter() which are used within s_count_abnormal_lab_worsen_by_baseline() to process input data.

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # The direction variable, GRADDR, is based on metadata
    @@ -291,17 +391,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/add_riskdiff.html b/main/reference/add_riskdiff.html index 002e828c14..e392cb7965 100644 --- a/main/reference/add_riskdiff.html +++ b/main/reference/add_riskdiff.html @@ -1,13 +1,36 @@ - -Split function to configure risk difference column — add_riskdiff • tern + + + + + +Split function to configure risk difference column — add_riskdiff • tern + + + + + + + + + + + + + +riskdiff to TRUE in all following analyze function calls."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    add_riskdiff(
       arm_x,
       arm_y,
    @@ -74,40 +138,50 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    arm_x
    +
    +
    arm_x +

    (string)
    name of reference arm to use in risk difference calculations.

    -
    arm_y
    +
    arm_y +

    (character)
    names of one or more arms to compare to reference arm in risk difference calculations. A new column will be added for each value of arm_y.

    -
    col_label
    +
    col_label +

    (character)
    labels to use when rendering the risk difference column within the table. If more than one comparison arm is specified in arm_y, default labels will specify which two arms are being compared (reference arm vs. comparison arm).

    -
    pct
    +
    pct +

    (flag)
    whether output should be returned as percentages. Defaults to TRUE.

    -
    + +
    -

    Value

    +

    Value +

    A closure suitable for use as a split function (split_fun) within rtables::split_cols_by() when creating a table layout.

    -

    See also

    +

    See also +

    stat_propdiff_ci() for details on risk difference calculation.

    -

    Examples

    +

    Examples +

    adae <- tern_ex_adae
     adae$AESEV <- factor(adae$AESEV)
     
    @@ -130,17 +204,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/add_rowcounts.html b/main/reference/add_rowcounts.html index d5cb041189..0484923546 100644 --- a/main/reference/add_rowcounts.html +++ b/main/reference/add_rowcounts.html @@ -1,9 +1,32 @@ - -Layout-creating function to add row total counts — add_rowcounts • tern + + + + + +Layout-creating function to add row total counts — add_rowcounts • tern + + + + + + + + + + + + + +is a wrapper for rtables::summarize_row_groups()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,36 +120,45 @@
    -

    Usage

    +

    Usage +

    add_rowcounts(lyt, alt_counts = FALSE)
    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    alt_counts
    +
    alt_counts +

    (flag)
    whether row counts should be taken from alt_counts_df (TRUE) or from df (FALSE). Defaults to FALSE.

    -
    + +
    -

    Value

    +

    Value +

    A modified layout where the latest row split labels now have the row-wise total counts (i.e. without column-based subsetting) attached in parentheses.

    -

    Note

    +

    Note +

    Row count values are contained in these row count rows but are not displayed so that they are not considered zero rows by default when pruning.

    -

    Examples

    +

    Examples +

    basic_table() %>%
       split_cols_by("ARM") %>%
       add_colcounts() %>%
    @@ -122,17 +194,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/aesi_label.html b/main/reference/aesi_label.html index ec14e21049..7211470ecf 100644 --- a/main/reference/aesi_label.html +++ b/main/reference/aesi_label.html @@ -1,5 +1,28 @@ - -Labels for adverse event baskets — aesi_label • tern + + + + + + +Labels for adverse event baskets — aesi_label • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,30 +114,38 @@
    -

    Usage

    +

    Usage +

    aesi_label(aesi, scope = NULL)
    -

    Arguments

    +

    Arguments +

    -
    aesi
    +
    +
    aesi +

    (character)
    vector with standardized MedDRA query name (e.g. SMQxxNAM) or customized query name (e.g. CQxxNAM).

    -
    scope
    +
    scope +

    (character)
    vector with scope of query (e.g. SMQxxSC).

    -
    + +
    -

    Value

    +

    Value +

    A string with the standard label for the AE basket.

    -

    Examples

    +

    Examples +

    adae <- tern_ex_adae
     
     # Standardized query label includes scope.
    @@ -88,17 +159,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/afun_riskdiff.html b/main/reference/afun_riskdiff.html index 22e1c97762..f2f9172f4f 100644 --- a/main/reference/afun_riskdiff.html +++ b/main/reference/afun_riskdiff.html @@ -1,13 +1,36 @@ - -Analysis function to calculate risk difference column values — afun_riskdiff • tern + + + + + +Analysis function to calculate risk difference column values — afun_riskdiff • tern + + + + + + + + + + + + + +function utilizes the stat_propdiff_ci() function to perform risk difference calculations."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    afun_riskdiff(
       df,
       labelstr = "",
    @@ -84,107 +148,131 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    .spl_context
    +
    .spl_context +

    (data.frame)
    gives information about ancestor split states that is passed by rtables.

    -
    .all_col_counts
    +
    .all_col_counts +

    (integer)
    vector where each value represents a global count for a column. Values are taken from alt_counts_df if specified (see rtables::build_table()).

    -
    .stats
    +
    .stats +

    (character)
    statistics to select for the table.

    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    afun
    +
    afun +

    (named list)
    a named list containing one name-value pair where the name corresponds to the name of the statistics function that should be used in calculations and the value is the corresponding analysis function.

    -
    s_args
    +
    s_args +

    (named list)
    additional arguments to be passed to the statistics function and analysis function supplied in afun.

    -
    + +
    -

    Value

    +

    Value +

    A list of formatted rtables::CellValue().

    -

    See also

    +

    See also +

    -
    + +
    + + - + + - + + diff --git a/main/reference/afun_selected_stats.html b/main/reference/afun_selected_stats.html index f03860e832..847ecf639f 100644 --- a/main/reference/afun_selected_stats.html +++ b/main/reference/afun_selected_stats.html @@ -1,5 +1,28 @@ - -Get selected statistics names — afun_selected_stats • tern + + + + + + +Get selected statistics names — afun_selected_stats • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,40 +114,49 @@
    -

    Usage

    +

    Usage +

    afun_selected_stats(.stats, all_stats)
    -

    Arguments

    +

    Arguments +

    -
    .stats
    +
    +
    .stats +

    (vector or NULL)
    input to the layout creating function. Note that NULL means in this context that all default statistics should be used.

    -
    all_stats
    +
    all_stats +

    (character)
    all statistics which can be selected here potentially.

    -
    + +
    -

    Value

    +

    Value +

    A character vector with the selected statistics.

    + + - + + - + + diff --git a/main/reference/analyze_colvars_functions.html b/main/reference/analyze_colvars_functions.html index e3aacbed47..ac601e9f7f 100644 --- a/main/reference/analyze_colvars_functions.html +++ b/main/reference/analyze_colvars_functions.html @@ -1,5 +1,22 @@ - -Analyze functions in columns — analyze_colvars_functions • tern + + + + + +Analyze functions in columns — analyze_colvars_functions • tern + + + + + + + + + + + + + +"> + + + + + Skip to contents @@ -55,26 +78,66 @@ + + @@ -89,7 +152,9 @@

    These functions are wrappers of rtables::analyze_colvars() which apply corresponding tern statistics functions to add an analysis to a given table layout. In particular, these functions -where designed to have the analysis methods split into different columns.

    • analyze_vars_in_cols(): fundamental tabulation of analysis methods onto columns. +where designed to have the analysis methods split into different columns.

      +
        +
      • analyze_vars_in_cols(): fundamental tabulation of analysis methods onto columns. In other words, the analysis methods are defined in the column space, i.e. they become column labels. By changing the variable vector, the list of functions can be applied on different variables, with the caveat of having the same number of statistical functions.

      • @@ -105,28 +170,34 @@ similarly to tabulate_* functions described above as it is designed to provide specific standard tables that may contain nested structure with a combination of summarize_row_groups() and rtables::analyze_colvars().

        -
    + +
    -

    See also

    +

    See also +

    -
    + +
    - + + - + + - + + diff --git a/main/reference/analyze_functions.html b/main/reference/analyze_functions.html index a2dd71bb30..bcb1b9f067 100644 --- a/main/reference/analyze_functions.html +++ b/main/reference/analyze_functions.html @@ -1,5 +1,22 @@ - -Analyze functions — analyze_functions • tern + + + + + +Analyze functions — analyze_functions • tern + + + + + + + + + + + + + +"> + + + + + Skip to contents @@ -83,26 +106,66 @@ + + @@ -116,7 +179,9 @@

    These functions are wrappers of rtables::analyze() which apply corresponding tern statistics functions -to add an analysis to a given table layout:

    + +
    -

    See also

    +

    See also +

    -
    + +
    - + + - + + - + + diff --git a/main/reference/analyze_variables.html b/main/reference/analyze_variables.html index f6efef1295..c2fa0a2b54 100644 --- a/main/reference/analyze_variables.html +++ b/main/reference/analyze_variables.html @@ -1,15 +1,38 @@ - -Analyze variables — analyze_variables • tern + +output summary table.'> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    analyze_vars(
       lyt,
       vars,
    @@ -150,140 +214,187 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    arguments passed to s_summary().

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    section_div
    +
    section_div +

    (string)
    string which should be repeated as a section divider after each group defined by this split instruction, or NA_character_ (the default) for no section divider.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    Options for numeric variables are: 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d'

    -

    Options for non-numeric variables are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq'

    +

    Options for non-numeric variables are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq'

    + -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Each element of the vector should be a name-value pair with name corresponding to a statistic specified in .stats and value the indentation for that statistic's row label.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    control
    -

    (list)
    parameters for descriptive statistics details, specified by using -the helper function control_analyze_vars(). Some possible parameter options are:

    • conf_level (proportion)
      confidence level of the interval for mean and median.

    • +
      control +
      +
      +

      (list)
      parameters for descriptive statistics details, specified by using +the helper function control_analyze_vars(). Some possible parameter options are:

      +
        +
      • conf_level (proportion)
        confidence level of the interval for mean and median.

      • quantiles (numeric(2))
        vector of length two to specify the quantiles.

      • quantile_type (numeric(1))
        between 1 and 9 selecting quantile algorithms to be used. See more about type in stats::quantile().

      • test_mean (numeric(1))
        value to test against the mean under the null hypothesis when calculating p-value.

      • -
      +
    +
    -
    verbose
    +
    verbose +

    (flag)
    defaults to TRUE, which prints out warnings and messages. It is mainly used to print out information about factor casting.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    compare
    +
    compare +

    (flag)
    whether comparison statistics should be analyzed instead of summary statistics (compare = TRUE adds pval statistic comparing against reference group).

    -
    + +
    -

    Value

    +

    Value +

    -
    • analyze_vars() returns a layout object suitable for passing to further layouting functions, +

        +
      • analyze_vars() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_summary() to the table layout.

      • -
      • s_summary() returns different statistics depending on the class of x.

      • -
      • If x is of class numeric, returns a list with the following named numeric items:

        +
          +
        • s_summary() returns different statistics depending on the class of x.

        • +
        +
          +
        • +

          If x is of class numeric, returns a list with the following named numeric items:

          +
            +
          • n: The length() of x.

          • sum: The sum() of x.

          • mean: The mean() of x.

          • sd: The stats::sd() of x.

          • @@ -307,30 +418,49 @@

            Value

            cv: The coefficient of variation of x, i.e.: (stats::sd() / mean() * 100).

          • geom_mean: The geometric mean of x, i.e.: (exp(mean(log(x)))).

          • geom_cv: The geometric coefficient of variation of x, i.e.: (sqrt(exp(sd(log(x)) ^ 2) - 1) * 100).

          • -
        • -
        • If x is of class factor or converted from character, returns a list with named numeric items:

          +
        • +
        +
          +
        • +

          If x is of class factor or converted from character, returns a list with named numeric items:

          +
            +
          • n: The length() of x.

          • count: A list with the number of cases for each level of the factor x.

          • count_fraction: Similar to count but also includes the proportion of cases for each level of the factor x relative to the denominator, or NA if the denominator is zero.

          • -
        • -
        • If x is of class logical, returns a list with named numeric items:

          • n: The length() of x (possibly after removing NAs).

          • +
          +
        • +
        +
          +
        • +

          If x is of class logical, returns a list with named numeric items:

          +
            +
          • n: The length() of x (possibly after removing NAs).

          • count: Count of TRUE in x.

          • count_fraction: Count and proportion of TRUE in x relative to the denominator, or NA if the denominator is zero. Note that NAs in x are never counted or leading to NA here.

          • -
        • -
    + + + + +
    -

    Details

    +

    Details +

    Automatic digit formatting: The number of digits to display can be automatically determined from the analyzed variable(s) (vars) for certain statistics by setting the statistic format to "auto" in .formats. This utilizes the format_auto() formatting function. Note that only data for the current row & variable (for all columns) will be considered (.df_row[[.var]], see rtables::additional_fun_params) and not the whole dataset.

    -

    Functions

    +

    Functions +

    -
    • analyze_vars(): Layout-creating function which can take statistics function arguments +

        +
      • analyze_vars(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_summary(): S3 generic function to produces a variable summary.

      • s_summary(numeric): Method for numeric class.

      • @@ -340,30 +470,41 @@

        Functionscompare_vars() and as cfun in summarize_colvars().

        -

    + +
    -

    Note

    +

    Note +

    -
    • If x is an empty vector, NA is returned. This is the expected feature so as to return rcell content in +

        +
      • If x is an empty vector, NA is returned. This is the expected feature so as to return rcell content in rtables when the intersection of a column and a row delimits an empty data selection.

      • When the mean function is applied to an empty vector, NA will be returned instead of NaN, the latter being standard behavior in R.

      • -
      • If x is an empty factor, a list is still returned for counts with one element +

      +
        +
      • If x is an empty factor, a list is still returned for counts with one element per factor level. If there are no levels in x, the function fails.

      • If factor variables contain NA, these NA values are excluded by default. To include NA values set na.rm = FALSE and missing values will be displayed as an NA level. Alternatively, an explicit factor level can be defined for NA values during pre-processing via df_explicit_na() - the default na_level ("<Missing>") will also be excluded when na.rm is set to TRUE.

      • -
      • Automatic conversion of character to factor does not guarantee that the table +

      +
        +
      • Automatic conversion of character to factor does not guarantee that the table can be generated correctly. In particular for sparse tables this very likely can fail. It is therefore better to always pre-process the dataset such that factors are manually created from character variables before passing the dataset to rtables::build_table().

      • -
      • To use for comparison (with additional p-value statistic), parameter compare must be set to TRUE.

      • +
      +
        +
      • To use for comparison (with additional p-value statistic), parameter compare must be set to TRUE.

      • Ensure that either all NA values are converted to an explicit NA level or all NA values are left as is.

      • -
    + +
    -

    Examples

    +

    Examples +

    ## Fabricated dataset.
     dta_test <- data.frame(
       USUBJID = rep(1:6, each = 3),
    @@ -2538,17 +2679,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/analyze_vars_in_cols.html b/main/reference/analyze_vars_in_cols.html index 4696d52001..d1d4d7301b 100644 --- a/main/reference/analyze_vars_in_cols.html +++ b/main/reference/analyze_vars_in_cols.html @@ -1,13 +1,36 @@ - -Analyze numeric variables in columns — analyze_vars_in_cols • tern + + + + + +Analyze numeric variables in columns — analyze_vars_in_cols • tern + + + + + + + + + + + + + +It was designed principally for PK tables."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    analyze_vars_in_cols(
       lyt,
       vars,
    @@ -86,116 +150,141 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    .stats
    +
    .stats +

    (character)
    statistics to select for the table.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    row_labels
    +
    row_labels +

    (character)
    as this function works in columns space, usually .labels character vector applies on the column space. You can change the row labels by defining this parameter to a named character vector with names corresponding to the split values. It defaults to NULL and if it contains only one string, it will duplicate that as a row label.

    -
    do_summarize_row_groups
    +
    do_summarize_row_groups +

    (flag)
    defaults to FALSE and applies the analysis to the current label rows. This is a wrapper of rtables::summarize_row_groups() and it can accept labelstr to define row labels. This behavior is not supported as we never need to overload row labels.

    -
    split_col_vars
    +
    split_col_vars +

    (flag)
    defaults to TRUE and puts the analysis results onto the columns. This option allows you to add multiple instances of this functions, also in a nested fashion, without adding more splits. This split must happen only one time on a single layout.

    -
    imp_rule
    +
    imp_rule +

    (string or NULL)
    imputation rule setting. Defaults to NULL for no imputation rule. Can also be "1/3" to implement 1/3 imputation rule or "1/2" to implement 1/2 imputation rule. In order to use an imputation rule, the avalcat_var argument must be specified. See imputation_rule() for more details on imputation.

    -
    avalcat_var
    +
    avalcat_var +

    (string)
    if imp_rule is not NULL, name of variable that indicates whether a row in the data corresponds to an analysis value in category "BLQ", "LTR", "<PCLLOQ", or none of the above (defaults to "AVALCAT1"). Variable must be present in the data and should match the variable used to calculate the n_blq statistic (if included in .stats).

    -
    cache
    +
    cache +

    (flag)
    whether to store computed values in a temporary caching environment. This will speed up calculations in large tables, but should be set to FALSE if the same rtable layout is used for multiple tables with different data. Defaults to FALSE.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .aligns
    +
    .aligns +

    (character or NULL)
    alignment for table contents (not including labels). When NULL, "center" is applied. See formatters::list_valid_aligns() for a list of all currently supported alignments.

    -
    + +
    -

    Value

    +

    Value +

    A layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will summarize the given variables, arrange the output in columns, and add it to the table layout.

    -

    Note

    +

    Note +

    -
    • This is an experimental implementation of rtables::summarize_row_groups() and rtables::analyze_colvars() +

        +
      • This is an experimental implementation of rtables::summarize_row_groups() and rtables::analyze_colvars() that may be subjected to changes as rtables extends its support to more complex analysis pipelines in the column space. We encourage users to read the examples carefully and file issues for different use cases.

      • In this function, labelstr behaves atypically. If labelstr = NULL (the default), row labels are assigned automatically as the split values if do_summarize_row_groups = FALSE (the default), and as the group label if do_summarize_row_groups = TRUE.

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # Data preparation
    @@ -345,17 +434,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/append_varlabels.html b/main/reference/append_varlabels.html index dbd400d9a9..fc77171c19 100644 --- a/main/reference/append_varlabels.html +++ b/main/reference/append_varlabels.html @@ -1,11 +1,34 @@ - -Add variable labels to top left corner in table — append_varlabels • tern + + + + + +Add variable labels to top left corner in table — append_varlabels • tern + + + + + + + + + + + + + +variable name itself is used instead. Multiple variable labels are concatenated with slashes."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,44 +123,55 @@
    -

    Usage

    +

    Usage +

    append_varlabels(lyt, df, vars, indent = 0L)
    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    vars
    +
    vars +

    (character)
    variable names of which the labels are to be looked up in df.

    -
    indent
    +
    indent +

    (integer(1))
    non-negative number of nested indent space, default to 0L which means no indent. 1L means two spaces indent, 2L means four spaces indent and so on.

    -
    + +
    -

    Value

    +

    Value +

    A modified layout with the new variable label(s) added to the top-left material.

    -

    Note

    +

    Note +

    This is not an optimal implementation of course, since we are using here the data set itself during the layout creation. When we have a more mature rtables implementation then this will also be improved or not necessary anymore.

    -

    Examples

    +

    Examples +

    lyt <- basic_table() %>%
       split_cols_by("ARM") %>%
       add_colcounts() %>%
    @@ -138,17 +212,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/apply_auto_formatting.html b/main/reference/apply_auto_formatting.html index aaea806518..f87b49a7f3 100644 --- a/main/reference/apply_auto_formatting.html +++ b/main/reference/apply_auto_formatting.html @@ -1,7 +1,30 @@ - -Apply automatic formatting — apply_auto_formatting • tern + + + + + + +Apply automatic formatting — apply_auto_formatting • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,46 +117,56 @@
    -

    Usage

    +

    Usage +

    apply_auto_formatting(.formats, x_stats, .df_row, .var)
    -

    Arguments

    +

    Arguments +

    -
    .formats
    +
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    x_stats
    +
    x_stats +

    (named list)
    a named list of statistics where each element corresponds to an element in .formats, with matching names.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    + + + + - + + - + + diff --git a/main/reference/argument_convention.html b/main/reference/argument_convention.html index d07254ff97..66bbd118bd 100644 --- a/main/reference/argument_convention.html +++ b/main/reference/argument_convention.html @@ -1,7 +1,30 @@ - -Standard arguments — argument_convention • tern + + + + + + +Standard arguments — argument_convention • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -55,212 +118,264 @@
    -

    Arguments

    +

    Arguments +

    -
    ...
    +
    +
    ... +

    additional arguments for the lower level functions.

    -
    .aligns
    +
    .aligns +

    (character or NULL)
    alignment for table contents (not including labels). When NULL, "center" is applied. See formatters::list_valid_aligns() for a list of all currently supported alignments.

    -
    .all_col_counts
    +
    .all_col_counts +

    (integer)
    vector where each value represents a global count for a column. Values are taken from alt_counts_df if specified (see rtables::build_table()).

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .spl_context
    +
    .spl_context +

    (data.frame)
    gives information about ancestor split states that is passed by rtables.

    -
    .stats
    +
    .stats +

    (character)
    statistics to select for the table.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    add_total_level
    +
    add_total_level +

    (flag)
    adds a "total" level after the others which includes all the levels that constitute the split. A custom label can be set for this level via the custom_label argument.

    -
    col_by
    +
    col_by +

    (factor)
    defining column groups.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    id
    +
    id +

    (string)
    subject variable name.

    -
    is_event
    +
    is_event +

    (flag)
    TRUE if event, FALSE if time to event is censored.

    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    lyt
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    method
    +
    method +

    (string or NULL)
    specifies the test used to calculate the p-value for the difference between two proportions. For options, see test_proportion_diff(). Default is NULL so no test is performed.

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    prune_zero_rows
    +
    prune_zero_rows +

    (flag)
    whether to prune all zero rows.

    -
    riskdiff
    +
    riskdiff +

    (flag)
    whether a risk difference column is present. When set to TRUE, add_riskdiff() must be used as split_fun in the prior column split of the table layout, specifying which columns should be compared. See stat_propdiff_ci() for details on risk difference calculation.

    -
    rsp
    +
    rsp +

    (logical)
    vector indicating whether each subject is a responder or not.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    section_div
    +
    section_div +

    (string)
    string which should be repeated as a section divider after each group defined by this split instruction, or NA_character_ (the default) for no section divider.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    tte
    +
    tte +

    (numeric)
    vector of time-to-event duration values.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    var
    +
    var +

    (string)
    single variable name for the primary analysis variable.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    xlim
    +
    xlim +

    (numeric(2))
    vector containing lower and upper limits for the x-axis, respectively. If NULL (default), the default scale range is used.

    -
    ylim
    +
    ylim +

    (numeric(2))
    vector containing lower and upper limits for the y-axis, respectively. If NULL (default), the default scale range is used.

    -
    + +
    -

    Details

    +

    Details +

    Although this function just returns NULL it has two uses, for the tern users it provides a documentation of arguments that are commonly and consistently used in the framework. For the developer it adds a @@ -269,17 +384,19 @@

    Details

    + + - + + - + + diff --git a/main/reference/arrange_grobs.html b/main/reference/arrange_grobs.html index 015a626ca7..75f93afa61 100644 --- a/main/reference/arrange_grobs.html +++ b/main/reference/arrange_grobs.html @@ -1,7 +1,30 @@ - -Arrange multiple grobs — arrange_grobs • tern + + + + + + +Arrange multiple grobs — arrange_grobs • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    arrange_grobs(
       ...,
       grobs = list(...),
    @@ -69,52 +133,66 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    ...
    +
    +
    ... +

    grobs.

    -
    grobs
    +
    grobs +

    (list of grob)
    a list of grobs.

    -
    ncol
    +
    ncol +

    (integer(1))
    number of columns in layout.

    -
    nrow
    +
    nrow +

    (integer(1))
    number of rows in layout.

    -
    padding_ht
    +
    padding_ht +

    (grid::unit)
    unit of length 1, vertical space between each grob.

    -
    padding_wt
    +
    padding_wt +

    (grid::unit)
    unit of length 1, horizontal space between each grob.

    -
    vp
    +
    vp +

    (viewport or NULL)
    a viewport() object (or NULL).

    -
    gp
    +
    gp +

    (gpar)
    a gpar() object.

    -
    name
    +
    name +

    (string)
    a character identifier for the grob.

    -
    + +
    -

    Value

    +

    Value +

    A grob.

    -

    Examples

    +

    Examples +

    library(grid)
     
     # \donttest{
    @@ -151,17 +229,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/as.rtable.html b/main/reference/as.rtable.html index 775a852cd6..f86267fbb0 100644 --- a/main/reference/as.rtable.html +++ b/main/reference/as.rtable.html @@ -1,7 +1,30 @@ - -Convert to rtable — as.rtable • tern + + + + + + +Convert to rtable — as.rtable • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,33 +40,74 @@ + +
    @@ -54,7 +118,8 @@
    -

    Usage

    +

    Usage +

    as.rtable(x, ...)
     
     # S3 method for class 'data.frame'
    @@ -62,33 +127,44 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (data.frame)
    the object which should be converted to an rtable.

    -
    ...
    +
    ... +

    additional arguments for methods.

    -
    format
    +
    format +

    (string or function)
    the format which should be used for the columns.

    -
    + +
    -

    Value

    +

    Value +

    An rtables table object. Note that the concrete class will depend on the method used.

    -

    Methods (by class)

    +

    Methods (by class) +

    -
    • as.rtable(data.frame): Method for converting a data.frame that contains numeric columns to rtable.

    • -
    +
      +
    • as.rtable(data.frame): Method for converting a data.frame that contains numeric columns to rtable.

    • +
    +
    -

    Examples

    +

    Examples +

    x <- data.frame(
       a = 1:10,
       b = rnorm(10)
    @@ -110,17 +186,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/as_factor_keep_attributes.html b/main/reference/as_factor_keep_attributes.html index 68304167ea..69bd38372c 100644 --- a/main/reference/as_factor_keep_attributes.html +++ b/main/reference/as_factor_keep_attributes.html @@ -1,9 +1,32 @@ - -Conversion of a vector to a factor — as_factor_keep_attributes • tern + + + + + +Conversion of a vector to a factor — as_factor_keep_attributes • tern + + + + + + + + + + + + + +factor levels)."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    as_factor_keep_attributes(
       x,
       x_name = deparse(substitute(x)),
    @@ -67,42 +131,52 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (vector)
    object to convert.

    -
    x_name
    +
    x_name +

    (string)
    name of x.

    -
    na_level
    +
    na_level +

    (string)
    the explicit missing level which should be used when converting a character vector.

    -
    verbose
    +
    verbose +

    (flag)
    defaults to TRUE. It prints out warnings and messages.

    -
    + +
    -

    Value

    +

    Value +

    A factor with same attributes (except class) as x. Does not modify x if already a factor.

    + + - + + - + + diff --git a/main/reference/assertions.html b/main/reference/assertions.html index 7d46e0ca73..ee61921f72 100644 --- a/main/reference/assertions.html +++ b/main/reference/assertions.html @@ -1,5 +1,28 @@ - -Additional assertions to use with checkmate — assertions • tern + + + + + + +Additional assertions to use with checkmate — assertions • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,33 +38,74 @@ + +
    @@ -51,7 +115,8 @@
    -

    Usage

    +

    Usage +

    assert_list_of_variables(x, .var.name = checkmate::vname(x), add = NULL)
     
     assert_df_with_variables(
    @@ -89,85 +154,104 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (any)
    object to test.

    -
    .var.name
    +
    .var.name +

    [character(1)]
    Name of the checked object to print in assertions. Defaults to the heuristic implemented in vname.

    -
    add
    +
    add +

    [AssertCollection]
    Collection to store assertion messages. See AssertCollection.

    -
    df
    +
    df +

    (data.frame)
    data set to test.

    -
    variables
    +
    variables +

    (named list of character)
    list of variables to test.

    -
    na_level
    +
    na_level +

    (string)
    the string you have been using to represent NA or missing data. For NA values please consider using directly is.na() or similar approaches.

    -
    min.levels
    +
    min.levels +

    [integer(1)]
    Minimum number of factor levels. Default is NULL (no check).

    -
    max.levels
    +
    max.levels +

    [integer(1)]
    Maximum number of factor levels. Default is NULL (no check).

    -
    null.ok
    +
    null.ok +

    [logical(1)]
    If set to TRUE, x may also be NULL. In this case only a type check of x is performed, all additional checks are disabled.

    -
    any.missing
    +
    any.missing +

    [logical(1)]
    Are vectors with missing values allowed? Default is TRUE.

    -
    n.levels
    +
    n.levels +

    [integer(1)]
    Exact number of factor levels. Default is NULL (no check).

    -
    len
    +
    len +

    [integer(1)]
    Exact expected length of x.

    -
    include_boundaries
    +
    include_boundaries +

    (flag)
    whether to include boundaries when testing for proportions.

    -
    + +
    -

    Value

    +

    Value +

    Nothing if assertion passes, otherwise prints the error message.

    -

    Functions

    +

    Functions +

    -
    • assert_list_of_variables(): Checks whether x is a valid list of variable names. +

        +
      • assert_list_of_variables(): Checks whether x is a valid list of variable names. NULL elements of the list x are dropped with Filter(Negate(is.null), x).

      • assert_df_with_variables(): Check whether df is a data frame with the analysis variables. Please notice how this produces an error when not all variables are present in the @@ -178,20 +262,23 @@

        Functionsfactor() will trim NA levels out of the vector list itself.

      • assert_proportion_value(): Check whether x is a proportion: number between 0 and 1.

      • -
    + +
    + + - + + - + + diff --git a/main/reference/bins_percent_labels.html b/main/reference/bins_percent_labels.html index 90cb471eab..f5b0cc8b51 100644 --- a/main/reference/bins_percent_labels.html +++ b/main/reference/bins_percent_labels.html @@ -1,7 +1,30 @@ - -Labels for bins in percent — bins_percent_labels • tern + + + + + + +Labels for bins in percent — bins_percent_labels • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,41 +117,50 @@
    -

    Usage

    +

    Usage +

    bins_percent_labels(probs, digits = 0)
    -

    Arguments

    +

    Arguments +

    -
    probs
    +
    +
    probs +

    (numeric)
    the probabilities identifying the quantiles. This is a sorted vector of unique proportion values, i.e. between 0 and 1, where the boundaries 0 and 1 must not be included.

    -
    digits
    +
    digits +

    (integer(1))
    number of decimal places to round the percent numbers.

    -
    + +
    -

    Value

    +

    Value +

    A character vector with labels in the format [0%,20%], (20%,50%], etc.

    + + - + + - + + diff --git a/main/reference/c_label_n.html b/main/reference/c_label_n.html index a996650262..74f8981381 100644 --- a/main/reference/c_label_n.html +++ b/main/reference/c_label_n.html @@ -1,9 +1,32 @@ - -Content row function to add row total to labels — c_label_n • tern + + + + + +Content row function to add row total to labels — c_label_n • tern + + + + + + + + + + + + + +alt_counts_df, and is used by add_rowcounts() when alt_counts is set to FALSE."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,56 +120,68 @@
    -

    Usage

    +

    Usage +

    c_label_n(df, labelstr, .N_row)
    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    + +
    -

    Value

    +

    Value +

    A list with formatted rtables::CellValue() with the row count value and the correct label.

    -

    Note

    +

    Note +

    It is important here to not use df but rather .N_row in the implementation, because the former is already split by columns and will refer to the first column of the data only.

    -

    See also

    +

    See also +

    c_label_n_alt() which performs the same function but retrieves row counts from alt_counts_df instead of df.

    + + - + + - + + diff --git a/main/reference/c_label_n_alt.html b/main/reference/c_label_n_alt.html index c240df9b67..5ad808fe2f 100644 --- a/main/reference/c_label_n_alt.html +++ b/main/reference/c_label_n_alt.html @@ -1,9 +1,32 @@ - -Content row function to add alt_counts_df row total to labels — c_label_n_alt • tern + + + + + +Content row function to add alt_counts_df row total to labels — c_label_n_alt • tern + + + + + + + + + + + + + +rather than df, and is used by add_rowcounts() when alt_counts is set to TRUE."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,46 +120,56 @@
    -

    Usage

    +

    Usage +

    c_label_n_alt(df, labelstr, .alt_df_row)
    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    + +
    -

    Value

    +

    Value +

    A list with formatted rtables::CellValue() with the row count value and the correct label.

    -

    See also

    +

    See also +

    c_label_n() which performs the same function but retrieves row counts from df instead of alt_counts_df.

    + + - + + - + + diff --git a/main/reference/cfun_by_flag.html b/main/reference/cfun_by_flag.html index 2fd5bb597b..8bc81730c6 100644 --- a/main/reference/cfun_by_flag.html +++ b/main/reference/cfun_by_flag.html @@ -1,5 +1,28 @@ - -Constructor for content functions given a data frame with flag input — cfun_by_flag • tern + + + + + + +Constructor for content functions given a data frame with flag input — cfun_by_flag • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,45 +114,55 @@
    -

    Usage

    +

    Usage +

    cfun_by_flag(analysis_var, flag_var, format = "xx", .indent_mods = NULL)
    -

    Arguments

    +

    Arguments +

    -
    analysis_var
    +
    +
    analysis_var +

    (string)
    variable name for the column containing values to be returned by the content function.

    -
    flag_var
    +
    flag_var +

    (string)
    variable name for the logical column identifying which row should be returned.

    -
    format
    +
    format +

    (string)
    rtables format to use.

    -
    + +
    -

    Value

    +

    Value +

    A content function which gives df$analysis_var at the row identified by .df_row$flag in the given format.

    + + - + + - + + diff --git a/main/reference/check_diff_prop_ci.html b/main/reference/check_diff_prop_ci.html index 4dd4756549..15d9c2c749 100644 --- a/main/reference/check_diff_prop_ci.html +++ b/main/reference/check_diff_prop_ci.html @@ -1,7 +1,30 @@ - -Check proportion difference arguments — check_diff_prop_ci • tern + + + + + + +Check proportion difference arguments — check_diff_prop_ci • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,49 +117,60 @@
    -

    Usage

    +

    Usage +

    check_diff_prop_ci(rsp, grp, strata = NULL, conf_level, correct = NULL)
    -

    Arguments

    +

    Arguments +

    -
    rsp
    +
    +
    rsp +

    (logical)
    vector indicating whether each subject is a responder or not.

    -
    grp
    +
    grp +

    (factor)
    vector assigning observations to one out of two groups (e.g. reference and treatment group).

    -
    strata
    +
    strata +

    (factor)
    variable with one level per stratum and same length as rsp.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    correct
    +
    correct +

    (flag)
    whether to include the continuity correction. For further information, see stats::prop.test().

    -
    + + + + - + + - + + diff --git a/main/reference/check_same_n.html b/main/reference/check_same_n.html index c18c2695bb..f077ba46e3 100644 --- a/main/reference/check_same_n.html +++ b/main/reference/check_same_n.html @@ -1,5 +1,28 @@ - -Check element dimension — check_same_n • tern + + + + + + +Check element dimension — check_same_n • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,39 +114,48 @@
    -

    Usage

    +

    Usage +

    check_same_n(..., omit_null = TRUE)
    -

    Arguments

    +

    Arguments +

    -
    ...
    +
    +
    ... +

    (data.frame or vector)
    any data frames or vectors.

    -
    omit_null
    +
    omit_null +

    (flag)
    whether NULL elements in ... should be omitted from the check.

    -
    + +
    -

    Value

    +

    Value +

    A logical value.

    + + - + + - + + diff --git a/main/reference/combination_function.html b/main/reference/combination_function.html index fa8964c798..a8e4288f57 100644 --- a/main/reference/combination_function.html +++ b/main/reference/combination_function.html @@ -1,9 +1,32 @@ - -Class for CombinationFunction — combination_function • tern + + + + + +Class for CombinationFunction — combination_function • tern + + + + + + + + + + + + + +can be combined and negated with the logical operators."> + + + + + Skip to contents @@ -19,33 +42,74 @@ + +
    @@ -57,7 +121,8 @@
    -

    Usage

    +

    Usage +

    # S4 method for class 'CombinationFunction,CombinationFunction'
     e1 & e2
     
    @@ -69,29 +134,38 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    e1
    +
    +
    e1 +

    (CombinationFunction)
    left hand side of logical operator.

    -
    e2
    +
    e2 +

    (CombinationFunction)
    right hand side of logical operator.

    -
    x
    +
    x +

    (CombinationFunction)
    the function which should be negated.

    -
    + +
    -

    Value

    +

    Value +

    A logical value indicating whether the left hand side of the equation equals the right hand side.

    -

    Functions

    +

    Functions +

    -
    • e1 & e2: Logical "AND" combination of CombinationFunction functions. +

        +
      • e1 & e2: Logical "AND" combination of CombinationFunction functions. The resulting object is of the same class, and evaluates the two argument functions. The result is then the "AND" of the two individual results.

      • e1 | e2: Logical "OR" combination of CombinationFunction functions. @@ -100,10 +174,12 @@

        Functions -

        Examples

        +

        Examples +

        higher <- function(a) {
           force(a)
           CombinationFunction(
        @@ -131,17 +207,19 @@ 

        Examples

        + +
    - + + - + + diff --git a/main/reference/combine_counts.html b/main/reference/combine_counts.html index 2ff08b170d..1bd8700649 100644 --- a/main/reference/combine_counts.html +++ b/main/reference/combine_counts.html @@ -1,5 +1,28 @@ - -Combine counts — combine_counts • tern + + + + + + +Combine counts — combine_counts • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,34 +114,43 @@
    -

    Usage

    +

    Usage +

    combine_counts(fct, groups_list = NULL)
    -

    Arguments

    +

    Arguments +

    -
    fct
    +
    +
    fct +

    (factor)
    the variable with levels which needs to be grouped.

    -
    groups_list
    +
    groups_list +

    (named list of character)
    specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    + +
    -

    Value

    +

    Value +

    A vector of column counts.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    ref <- c("A: Drug X", "B: Placebo")
     groups <- combine_groups(fct = DM$ARM, ref = ref)
     
    @@ -123,17 +195,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/combine_groups.html b/main/reference/combine_groups.html index 6c682ec004..efb69c8f0d 100644 --- a/main/reference/combine_groups.html +++ b/main/reference/combine_groups.html @@ -1,9 +1,32 @@ - -Reference and treatment group combination — combine_groups • tern + + + + + +Reference and treatment group combination — combine_groups • tern + + + + + + + + + + + + + +columns in the rtables framework and teal modules."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,33 +120,42 @@
    -

    Usage

    +

    Usage +

    combine_groups(fct, ref = NULL, collapse = "/")
    -

    Arguments

    +

    Arguments +

    -
    fct
    +
    +
    fct +

    (factor)
    the variable with levels which needs to be grouped.

    -
    ref
    +
    ref +

    (character)
    the reference level(s).

    -
    collapse
    +
    collapse +

    (string)
    a character string to separate fct and ref.

    -
    + +
    -

    Value

    +

    Value +

    A list with first item ref (reference) and second item trt (treatment).

    -

    Examples

    +

    Examples +

    groups <- combine_groups(
       fct = DM$ARM,
       ref = c("B: Placebo")
    @@ -105,17 +177,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/combine_levels.html b/main/reference/combine_levels.html index 8419c2c418..37d155d11c 100644 --- a/main/reference/combine_levels.html +++ b/main/reference/combine_levels.html @@ -1,7 +1,30 @@ - -Combine factor levels — combine_levels • tern + + + + + + +Combine factor levels — combine_levels • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,33 +117,42 @@
    -

    Usage

    +

    Usage +

    combine_levels(x, levels, new_level = paste(levels, collapse = "/"))
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (factor)
    factor variable.

    -
    levels
    +
    levels +

    (character)
    level names to be combined.

    -
    new_level
    +
    new_level +

    (string)
    name of new level.

    -
    + +
    -

    Value

    +

    Value +

    A factor with the new levels.

    -

    Examples

    +

    Examples +

    x <- factor(letters[1:5], levels = letters[5:1])
     combine_levels(x, levels = c("a", "b"))
     #> [1] a/b a/b c   d   e  
    @@ -93,17 +165,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/combine_vectors.html b/main/reference/combine_vectors.html index fc2e8e1e90..6e09449e2e 100644 --- a/main/reference/combine_vectors.html +++ b/main/reference/combine_vectors.html @@ -1,5 +1,28 @@ - -Element-wise combination of two vectors — combine_vectors • tern + + + + + + +Element-wise combination of two vectors — combine_vectors • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,29 +114,37 @@
    -

    Usage

    +

    Usage +

    combine_vectors(x, y)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (vector)
    first vector to combine.

    -
    y
    +
    y +

    (vector)
    second vector to combine.

    -
    + +
    -

    Value

    +

    Value +

    A list where each element combines corresponding elements of x and y.

    -

    Examples

    +

    Examples +

    combine_vectors(1:3, 4:6)
     #> [[1]]
     #> [1] 1 4
    @@ -88,17 +159,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/compare_variables.html b/main/reference/compare_variables.html index b2e70ba7d2..3b2a85f167 100644 --- a/main/reference/compare_variables.html +++ b/main/reference/compare_variables.html @@ -1,5 +1,22 @@ - -Compare variables between groups — compare_variables • tern + +statistic.'> + + + + + Skip to contents @@ -33,26 +56,66 @@ + + @@ -78,7 +141,8 @@
    -

    Usage

    +

    Usage +

    compare_vars(
       lyt,
       vars,
    @@ -121,113 +185,145 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    arguments passed to s_compare().

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    section_div
    +
    section_div +

    (string)
    string which should be repeated as a section divider after each group defined by this split instruction, or NA_character_ (the default) for no section divider.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    Options for numeric variables are: 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d', 'pval'

    -

    Options for non-numeric variables are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq', 'pval_counts'

    +

    Options for non-numeric variables are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq', 'pval_counts'

    + -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Each element of the vector should be a name-value pair with name corresponding to a statistic specified in .stats and value the indentation for that statistic's row label.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    denom
    +
    denom +

    (string)
    choice of denominator for factor proportions, can only be n (number of values in this row and column intersection).

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    verbose
    +
    verbose +

    (flag)
    whether warnings and messages should be printed. Mainly used to print out information about factor casting. Defaults to TRUE.

    -
    + +
    -

    Value

    +

    Value +

    -
    • compare_vars() returns a layout object suitable for passing to further layouting functions, +

        +
      • compare_vars() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_compare() to the table layout.

      • -
      • s_compare() returns output of s_summary() and comparisons versus the reference group in the form of p-values.

      • -
    + +
      +
    • s_compare() returns output of s_summary() and comparisons versus the reference group in the form of p-values.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • compare_vars(): Layout-creating function which can take statistics function arguments +

        +
      • compare_vars(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_compare(): S3 generic function to produce a comparison summary.

      • s_compare(numeric): Method for numeric class. This uses the standard t-test @@ -238,11 +334,14 @@

        Functions -

        Note

        +

        Note +

        -
        • For factor variables, denom for factor proportions can only be n since the purpose is to compare proportions +

            +
          • For factor variables, denom for factor proportions can only be n since the purpose is to compare proportions between columns, therefore a row-based proportion would not make sense. Proportion based on N_col would be difficult since we use counts for the chi-squared test statistic, therefore missing values should be accounted for as explicit factor levels.

          • @@ -255,15 +354,18 @@

            Note

            Therefore it is always better to manually convert character variables to factors during pre-processing.

          • For compare_vars(), the column split must define a reference group via ref_group so that the comparison is well defined.

          • -
    + +
    -

    See also

    +

    See also +

    s_summary() which is used internally to compute a summary within s_compare(), and a_summary() which is used (with compare = TRUE) as the analysis function for compare_vars().

    -

    Examples

    +

    Examples +

    # `compare_vars()` in `rtables` pipelines
     
     ## Default output within a `rtables` pipeline.
    @@ -1097,17 +1199,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_analyze_vars.html b/main/reference/control_analyze_vars.html index 5158bdbf12..9d6fe4c831 100644 --- a/main/reference/control_analyze_vars.html +++ b/main/reference/control_analyze_vars.html @@ -1,9 +1,32 @@ - -Control function for descriptive statistics — control_analyze_vars • tern + + + + + +Control function for descriptive statistics — control_analyze_vars • tern + + + + + + + + + + + + + +details for s_summary(). This function family is mainly used by analyze_vars()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_analyze_vars(
       conf_level = 0.95,
       quantiles = c(0.25, 0.75),
    @@ -67,45 +131,55 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    quantiles
    +
    quantiles +

    (numeric(2))
    vector of length two to specify the quantiles to calculate.

    -
    quantile_type
    +
    quantile_type +

    (numeric(1))
    number between 1 and 9 selecting quantile algorithms to be used. Default is set to 2 as this matches the default quantile algorithm in SAS proc univariate set by QNTLDEF=5. This differs from R's default. See more about type in stats::quantile().

    -
    test_mean
    +
    test_mean +

    (numeric(1))
    number to test against the mean under the null hypothesis when calculating p-value.

    -
    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    + + - + + - + + diff --git a/main/reference/control_annot.html b/main/reference/control_annot.html index 8e8afa8f79..4897bceed7 100644 --- a/main/reference/control_annot.html +++ b/main/reference/control_annot.html @@ -1,9 +1,32 @@ - -Control functions for Kaplan-Meier plot annotation tables — control_annot • tern + + + + + +Control functions for Kaplan-Meier plot annotation tables — control_annot • tern + + + + + + + + + + + + + +generated via g_km()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_surv_med_annot(x = 0.8, y = 0.85, w = 0.32, h = 0.16, fill = TRUE)
     
     control_coxph_annot(
    @@ -71,56 +135,71 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (proportion)
    x-coordinate for center of annotation table.

    -
    y
    +
    y +

    (proportion)
    y-coordinate for center of annotation table.

    -
    w
    +
    w +

    (proportion)
    relative width of the annotation table.

    -
    h
    +
    h +

    (proportion)
    relative height of the annotation table.

    -
    fill
    +
    fill +

    (flag or character)
    whether the annotation table should have a background fill color. Can also be a color code to use as the background fill color. If TRUE, color code defaults to "#00000020".

    -
    ref_lbls
    +
    ref_lbls +

    (flag)
    whether the reference group should be explicitly printed in labels for the annotation table. If FALSE (default), only comparison groups will be printed in the table labels.

    -
    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    -

    Functions

    +

    Functions +

    -
    • control_surv_med_annot(): Control function for formatting the median survival time annotation table. This annotation +

        +
      • control_surv_med_annot(): Control function for formatting the median survival time annotation table. This annotation table can be added in g_km() by setting annot_surv_med=TRUE, and can be configured using the control_surv_med_annot() function by setting it as the control_annot_surv_med argument.

      • control_coxph_annot(): Control function for formatting the Cox-PH annotation table. This annotation table can be added in g_km() by setting annot_coxph=TRUE, and can be configured using the control_coxph_annot() function by setting it as the control_annot_coxph argument.

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    control_surv_med_annot()
     #> $x
     #> [1] 0.8
    @@ -161,17 +240,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_coxph.html b/main/reference/control_coxph.html index c8aa28b381..75d63c6d54 100644 --- a/main/reference/control_coxph.html +++ b/main/reference/control_coxph.html @@ -1,9 +1,32 @@ - -Control function for Cox-PH model — control_coxph • tern + + + + + +Control function for Cox-PH model — control_coxph • tern + + + + + + + + + + + + + +details of Cox-PH model for s_coxph_pairwise(). conf_level refers to Hazard Ratio estimation."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_coxph(
       pval_method = c("log-rank", "wald", "likelihood"),
       ties = c("efron", "breslow", "exact"),
    @@ -66,40 +130,49 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    pval_method
    +
    +
    pval_method +

    (string)
    p-value method for testing hazard ratio = 1. Default method is "log-rank", can also be set to "wald" or "likelihood".

    -
    ties
    +
    ties +

    (string)
    string specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in survival::coxph().

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    + + - + + - + + diff --git a/main/reference/control_coxreg.html b/main/reference/control_coxreg.html index 4062302741..8e27e163a8 100644 --- a/main/reference/control_coxreg.html +++ b/main/reference/control_coxreg.html @@ -1,7 +1,30 @@ - -Control function for Cox regression — control_coxreg • tern + + + + + + +Control function for Cox regression — control_coxreg • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    control_coxreg(
       pval_method = c("wald", "likelihood"),
       ties = c("exact", "efron", "breslow"),
    @@ -64,39 +128,49 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    pval_method
    +
    +
    pval_method +

    (string)
    the method used for estimation of p.values; wald (default) or likelihood.

    -
    ties
    +
    ties +

    (string)
    among exact (equivalent to DISCRETE in SAS), efron and breslow, see survival::coxph(). Note: there is no equivalent of SAS EXACT method in R.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    interaction
    +
    interaction +

    (flag)
    if TRUE, the model includes the interaction between the studied treatment and candidate covariate. Note that for univariate models without treatment arm, and multivariate models, no interaction can be used so that this needs to be FALSE.

    -
    + +
    -

    Value

    +

    Value +

    A list of items with names corresponding to the arguments.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    control_coxreg()
     #> $pval_method
     #> [1] "wald"
    @@ -114,17 +188,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_incidence_rate.html b/main/reference/control_incidence_rate.html index 32f9a601b4..45c07e894d 100644 --- a/main/reference/control_incidence_rate.html +++ b/main/reference/control_incidence_rate.html @@ -1,9 +1,32 @@ - -Control function for incidence rate — control_incidence_rate • tern + + + + + +Control function for incidence rate — control_incidence_rate • tern + + + + + + + + + + + + + +internally to specify details in s_incidence_rate()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_incidence_rate(
       conf_level = 0.95,
       conf_type = c("normal", "normal_log", "exact", "byar"),
    @@ -67,38 +131,48 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    conf_type
    +
    conf_type +

    (string)
    normal (default), normal_log, exact, or byar for confidence interval type.

    -
    input_time_unit
    +
    input_time_unit +

    (string)
    day, week, month, or year (default) indicating time unit for data input.

    -
    num_pt_year
    +
    num_pt_year +

    (numeric(1))
    number of patient-years to use when calculating adverse event rates.

    -
    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    control_incidence_rate(0.9, "exact", "month", 100)
     #> $conf_level
     #> [1] 0.9
    @@ -116,17 +190,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_lineplot_vars.html b/main/reference/control_lineplot_vars.html index 8de0c4b908..042de1ca4e 100644 --- a/main/reference/control_lineplot_vars.html +++ b/main/reference/control_lineplot_vars.html @@ -1,9 +1,32 @@ - -Control function for g_lineplot() — control_lineplot_vars • tern + + + + + +Control function for g_lineplot() — control_lineplot_vars • tern + + + + + + + + + + + + + +A variable's default value can be overwritten for any variable."> + + + + + Skip to contents @@ -19,33 +42,74 @@ + +
    @@ -57,7 +121,8 @@
    -

    Usage

    +

    Usage +

    control_lineplot_vars(
       x = "AVISIT",
       y = "AVAL",
    @@ -70,44 +135,56 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (string)
    x-variable name.

    -
    y
    +
    y +

    (string)
    y-variable name.

    -
    group_var
    +
    group_var +

    (string or NA)
    group variable name.

    -
    facet_var
    +
    facet_var +

    (string or NA)
    faceting variable name.

    -
    paramcd
    +
    paramcd +

    (string or NA)
    parameter code variable name.

    -
    y_unit
    +
    y_unit +

    (string or NA)
    y-axis unit variable name.

    -
    subject_var
    +
    subject_var +

    (string or NA)
    subject variable name.

    -
    + +
    -

    Value

    +

    Value +

    A named character vector of variable names.

    -

    Examples

    +

    Examples +

    control_lineplot_vars()
     #>           x           y   group_var     paramcd      y_unit subject_var 
     #>    "AVISIT"      "AVAL"       "ARM"   "PARAMCD"     "AVALU"   "USUBJID" 
    @@ -122,17 +199,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_logistic.html b/main/reference/control_logistic.html index d8baa2ac8c..de256f8377 100644 --- a/main/reference/control_logistic.html +++ b/main/reference/control_logistic.html @@ -1,9 +1,32 @@ - -Control function for logistic regression model fitting — control_logistic • tern + + + + + +Control function for logistic regression model fitting — control_logistic • tern + + + + + + + + + + + + + +conf_level refers to the confidence level used for the Odds Ratio CIs."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,15 +120,19 @@
    -

    Usage

    +

    Usage +

    control_logistic(response_definition = "response", conf_level = 0.95)
    -

    Arguments

    +

    Arguments +

    -
    response_definition
    +
    +
    response_definition +

    (string)
    the definition of what an event is in terms of response. This will be used when fitting the logistic regression model on the left hand side of the formula. Note that the evaluated expression should result in either a logical vector or a factor with 2 @@ -73,17 +140,21 @@

    Argumentsconf_level +
    conf_level +

    (proportion)
    confidence level of the interval.

    -

    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    -

    Examples

    +

    Examples +

    # Standard options.
     control_logistic()
     #> $response_definition
    @@ -114,17 +185,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_riskdiff.html b/main/reference/control_riskdiff.html index add45e682a..7407494d4d 100644 --- a/main/reference/control_riskdiff.html +++ b/main/reference/control_riskdiff.html @@ -1,9 +1,32 @@ - -Control function for risk difference column — control_riskdiff • tern + + + + + +Control function for risk difference column — control_riskdiff • tern + + + + + + + + + + + + + +riskdiff parameter of tabulate_rsp_subgroups() and tabulate_survival_subgroups()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_riskdiff(
       arm_x = NULL,
       arm_y = NULL,
    @@ -68,45 +132,56 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    arm_x
    +
    +
    arm_x +

    (string)
    name of reference arm to use in risk difference calculations.

    -
    arm_y
    +
    arm_y +

    (character)
    names of one or more arms to compare to reference arm in risk difference calculations. A new column will be added for each value of arm_y.

    -
    format
    +
    format +

    (string or function)
    the format label (string) or formatting function to apply to the risk difference statistic. See the 3d string options in formatters::list_valid_format_labels() for possible format strings. Defaults to "xx.x (xx.x - xx.x)".

    -
    col_label
    +
    col_label +

    (character)
    labels to use when rendering the risk difference column within the table. If more than one comparison arm is specified in arm_y, default labels will specify which two arms are being compared (reference arm vs. comparison arm).

    -
    pct
    +
    pct +

    (flag)
    whether output should be returned as percentages. Defaults to TRUE.

    -
    + +
    -

    Value

    +

    Value +

    A list of items with names corresponding to the arguments.

    -

    Examples

    +

    Examples +

    control_riskdiff()
     #> $arm_x
     #> NULL
    @@ -143,17 +218,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_step.html b/main/reference/control_step.html index 41a0306fb5..086cf3eb07 100644 --- a/main/reference/control_step.html +++ b/main/reference/control_step.html @@ -1,7 +1,30 @@ - -Control function for subgroup treatment effect pattern (STEP) calculations — control_step • tern + + + + + + +Control function for subgroup treatment effect pattern (STEP) calculations — control_step • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    control_step(
       biomarker = NULL,
       use_percentile = TRUE,
    @@ -65,22 +129,27 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    biomarker
    +
    +
    biomarker +

    (numeric or NULL)
    optional provision of the numeric biomarker variable, which could be used to infer bandwidth, see below.

    -
    use_percentile
    +
    use_percentile +

    (flag)
    if TRUE, the running windows are created according to quantiles rather than actual values, i.e. the bandwidth refers to the percentage of data covered in each window. Suggest TRUE if the biomarker variable is not uniformly distributed.

    -
    bandwidth
    +
    bandwidth +

    (numeric(1) or NULL)
    indicating the bandwidth of each window. Depending on the argument use_percentile, it can be either the length of actual-value windows on the real biomarker scale, or percentage windows. @@ -90,25 +159,30 @@

    Argumentsdegree +
    degree +

    (integer(1))
    the degree of polynomial function of the biomarker as an interaction term with the treatment arm fitted at each window. If 0 (default), then the biomarker variable is not included in the model fitted in each biomarker window.

    -
    num_points
    +
    num_points +

    (integer(1))
    the number of points at which the hazard ratios are estimated. The smallest number is 2.

    -

    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments, except biomarker which is just used to calculate the bandwidth in case that actual biomarker windows are requested.

    -

    Examples

    +

    Examples +

    # Provide biomarker values and request actual values to be used,
     # so that bandwidth is chosen from range.
     control_step(biomarker = 1:10, use_percentile = FALSE)
    @@ -158,17 +232,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/control_surv_time.html b/main/reference/control_surv_time.html index 8a32b47510..fea38fe987 100644 --- a/main/reference/control_surv_time.html +++ b/main/reference/control_surv_time.html @@ -1,9 +1,32 @@ - -Control function for survfit models for survival time — control_surv_time • tern + + + + + +Control function for survfit models for survival time — control_surv_time • tern + + + + + + + + + + + + + +details of survfit model for s_surv_time(). conf_level refers to survival time estimation."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_surv_time(
       conf_level = 0.95,
       conf_type = c("plain", "log", "log-log"),
    @@ -66,39 +130,48 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    conf_type
    +
    conf_type +

    (string)
    confidence interval type. Options are "plain" (default), "log", "log-log", see more in survival::survfit(). Note option "none" is no longer supported.

    -
    quantiles
    +
    quantiles +

    (numeric(2))
    vector of length two specifying the quantiles of survival time.

    -
    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    + + - + + - + + diff --git a/main/reference/control_surv_timepoint.html b/main/reference/control_surv_timepoint.html index a07e78ee0c..f076b5e83a 100644 --- a/main/reference/control_surv_timepoint.html +++ b/main/reference/control_surv_timepoint.html @@ -1,9 +1,32 @@ - -Control function for survfit models for patients' survival rate at time points — control_surv_timepoint • tern + + + + + +Control function for survfit models for patients' survival rate at time points — control_surv_timepoint • tern + + + + + + + + + + + + + +details of survfit model for s_surv_timepoint(). conf_level refers to patient risk estimation at a time point."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    control_surv_timepoint(
       conf_level = 0.95,
       conf_type = c("plain", "log", "log-log")
    @@ -65,35 +129,43 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    conf_type
    +
    conf_type +

    (string)
    confidence interval type. Options are "plain" (default), "log", "log-log", see more in survival::survfit(). Note option "none" is no longer supported.

    -
    + +
    -

    Value

    +

    Value +

    A list of components with the same names as the arguments.

    + + - + + - + + diff --git a/main/reference/count_cumulative.html b/main/reference/count_cumulative.html index cb3dac2699..abbb897b57 100644 --- a/main/reference/count_cumulative.html +++ b/main/reference/count_cumulative.html @@ -1,19 +1,42 @@ - -Cumulative counts of numeric variable by thresholds — count_cumulative • tern + + + + + +Cumulative counts of numeric variable by thresholds — count_cumulative • tern + + + + + + + + + + + + + +parameters, respectively."> + + + + + Skip to contents @@ -29,26 +52,66 @@ + + @@ -72,7 +135,8 @@
    -

    Usage

    +

    Usage +

    count_cumulative(
       lyt,
       vars,
    @@ -115,123 +179,163 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    thresholds
    +
    thresholds +

    (numeric)
    vector of cutoff values for the counts.

    -
    lower_tail
    +
    lower_tail +

    (flag)
    whether to count lower tail, default is TRUE.

    -
    include_eq
    +
    include_eq +

    (flag)
    whether to include value equal to the threshold in count, default is TRUE.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    + +
    -

    Value

    +

    Value +

    -
    • count_cumulative() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_cumulative() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_cumulative() to the table layout.

      • -
      • s_count_cumulative() returns a named list of count_fractions: a list with each thresholds value as a +

      +
        +
      • s_count_cumulative() returns a named list of count_fractions: a list with each thresholds value as a component, each component containing a vector for the count and fraction.

      • -
    + + +
    -

    Functions

    +

    Functions +

    -
    • count_cumulative(): Layout-creating function which can take statistics function arguments +

        +
      • count_cumulative(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_cumulative(): Statistics function that produces a named list given a numeric vector of thresholds.

      • a_count_cumulative(): Formatted analysis function which is used as afun in count_cumulative().

      • -
    + +
    -

    See also

    +

    See also +

    Relevant helper function h_count_cumulative(), and descriptive function d_count_cumulative().

    -

    Examples

    +

    Examples +

    basic_table() %>%
       split_cols_by("ARM") %>%
       add_colcounts() %>%
    @@ -250,17 +354,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_missed_doses.html b/main/reference/count_missed_doses.html index 2e7c001996..7b6b32f0d8 100644 --- a/main/reference/count_missed_doses.html +++ b/main/reference/count_missed_doses.html @@ -1,15 +1,38 @@ - -Count number of patients with missed doses by thresholds — count_missed_doses • tern + + + + + +Count number of patients with missed doses by thresholds — count_missed_doses • tern + + + + + + + + + + + + + +assumes that every row of the given data frame corresponds to a unique patient."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    count_missed_doses(
       lyt,
       vars,
    @@ -103,119 +167,161 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    thresholds
    +
    thresholds +

    (numeric)
    minimum number of missed doses the patients had.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'count_fraction', 'count_fraction_fixed_dp'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'count_fraction', 'count_fraction_fixed_dp'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    + +
    -

    Value

    +

    Value +

    -
    • count_missed_doses() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_missed_doses() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_missed_doses() to the table layout.

      • -
      • s_count_nonmissing() returns the statistic n which is the count of non-missing values in x.

      • -
      • s_count_missed_doses() returns the statistics n and count_fraction with one element for each threshold.

      • -
    + +
      +
    • s_count_nonmissing() returns the statistic n which is the count of non-missing values in x.

    • +
    +
      +
    • s_count_missed_doses() returns the statistics n and count_fraction with one element for each threshold.

    • +
    + +
    -

    Functions

    +

    Functions +

    -
    • count_missed_doses(): Layout-creating function which can take statistics function arguments +

        +
      • count_missed_doses(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_nonmissing(): Statistics function to count non-missing values.

      • s_count_missed_doses(): Statistics function to count patients with missed doses.

      • a_count_missed_doses(): Formatted analysis function which is used as afun in count_missed_doses().

      • -
    + +
    -

    See also

    +

    See also +

    -
    • Relevant description function d_count_missed_doses() which generates labels for count_missed_doses().

    • +
        +
      • Relevant description function d_count_missed_doses() which generates labels for count_missed_doses().

      • Similar analyze function count_cumulative() which more generally counts cumulative values and has more options for threshold handling, but uses different labels.

      • -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     
     anl <- tern_ex_adsl %>%
    @@ -245,17 +351,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_occurrences.html b/main/reference/count_occurrences.html index 225385c0e0..522ffa075d 100644 --- a/main/reference/count_occurrences.html +++ b/main/reference/count_occurrences.html @@ -1,5 +1,22 @@ - -Count occurrences — count_occurrences • tern + + + + + +Count occurrences — count_occurrences • tern + + + + + + + + + + + + + +the latest row split or the root of the table if no row splits have occurred."> + + + + + Skip to contents @@ -31,26 +54,66 @@ + + @@ -75,7 +138,8 @@
    -

    Usage

    +

    Usage +

    count_occurrences(
       lyt,
       vars,
    @@ -138,133 +202,179 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    id
    +
    id +

    (string)
    subject variable name.

    -
    drop
    +
    drop +

    (flag)
    whether non-appearing occurrence levels should be dropped from the resulting table. Note that in that case the remaining occurrence levels in the table are sorted alphabetically.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    riskdiff
    +
    riskdiff +

    (flag)
    whether a risk difference column is present. When set to TRUE, add_riskdiff() must be used as split_fun in the prior column split of the table layout, specifying which columns should be compared. See stat_propdiff_ci() for details on risk difference calculation.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • N_col: total number of patients in this column across rows.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • N_col: total number of patients in this column across rows.

      • n: number of patients with any occurrences.

      • N_row: total number of patients in this row across columns.

      • -
      +
    +
    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_occurrences() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_occurrences() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_occurrences() to the table layout.

      • -
      • summarize_occurrences() returns a layout object suitable for passing to further layouting functions, +

      +
        +
      • summarize_occurrences() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted content rows containing the statistics from s_count_occurrences() to the table layout.

      • -
      • s_count_occurrences() returns a list with:

        • count: list of counts with one element per occurrence.

        • +
        +
          +
        • +

          s_count_occurrences() returns a list with:

          +
            +
          • count: list of counts with one element per occurrence.

          • count_fraction: list of counts and fractions with one element per occurrence.

          • fraction: list of numerators and denominators with one element per occurrence.

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • count_occurrences(): Layout-creating function which can take statistics function arguments +

        +
      • count_occurrences(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • summarize_occurrences(): Layout-creating function which can take content function arguments and additional format arguments. This function is a wrapper for rtables::summarize_row_groups().

      • @@ -272,9 +382,11 @@

        Functions -

        Note

        +

        Note +

        By default, occurrences which don't appear in a given row split are dropped from the table and the occurrences in the table are sorted alphabetically per row split. Therefore, the corresponding layout needs to use split_fun = drop_split_levels in the split_rows_by calls. Use drop = FALSE if you would @@ -282,7 +394,8 @@

        Note

    -

    Examples

    +

    Examples +

    library(dplyr)
     df <- data.frame(
       USUBJID = as.character(c(
    @@ -428,17 +541,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_occurrences_by_grade.html b/main/reference/count_occurrences_by_grade.html index 04902f8e8f..a02cffa169 100644 --- a/main/reference/count_occurrences_by_grade.html +++ b/main/reference/count_occurrences_by_grade.html @@ -1,5 +1,22 @@ - -Count occurrences by grade — count_occurrences_by_grade • tern + + + + + +Count occurrences by grade — count_occurrences_by_grade • tern + + + + + + + + + + + + + +occurred."> + + + + + Skip to contents @@ -35,26 +58,66 @@ + + @@ -81,7 +144,8 @@
    -

    Usage

    +

    Usage +

    count_occurrences_by_grade(
       lyt,
       var,
    @@ -152,138 +216,181 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    id
    +
    id +

    (string)
    subject variable name.

    -
    grade_groups
    +
    grade_groups +

    (named list of character)
    list containing groupings of grades.

    -
    remove_single
    +
    remove_single +

    (flag)
    TRUE to not include the elements of one-element grade groups in the the output list; in this case only the grade groups names will be included in the output. If only_grade_groups is set to TRUE this argument is ignored.

    -
    only_grade_groups
    +
    only_grade_groups +

    (flag)
    whether only the specified grade groups should be included, with individual grade rows removed (TRUE), or all grades and grade groups should be displayed (FALSE).

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    riskdiff
    +
    riskdiff +

    (flag)
    whether a risk difference column is present. When set to TRUE, add_riskdiff() must be used as split_fun in the prior column split of the table layout, specifying which columns should be compared. See stat_propdiff_ci() for details on risk difference calculation.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'count_fraction', 'count_fraction_fixed_dp'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • N_col: total number of patients in this column across rows.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • N_col: total number of patients in this column across rows.

      • n: number of patients with any occurrences.

      • N_row: total number of patients in this row across columns.

      • -
      +
    +
    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_occurrences_by_grade() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_occurrences_by_grade() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_occurrences_by_grade() to the table layout.

      • -
      • summarize_occurrences_by_grade() returns a layout object suitable for passing to further layouting functions, +

      +
        +
      • summarize_occurrences_by_grade() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted content rows containing the statistics from s_count_occurrences_by_grade() to the table layout.

      • -
      • s_count_occurrences_by_grade() returns a list of counts and fractions with one element per grade level or +

      +
        +
      • s_count_occurrences_by_grade() returns a list of counts and fractions with one element per grade level or grade level grouping.

      • -
      • a_count_occurrences_by_grade() returns the corresponding list with formatted rtables::CellValue().

      • -
    + +
      +
    • a_count_occurrences_by_grade() returns the corresponding list with formatted rtables::CellValue().

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • count_occurrences_by_grade(): Layout-creating function which can take statistics function +

        +
      • count_occurrences_by_grade(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • summarize_occurrences_by_grade(): Layout-creating function which can take content function arguments and additional format arguments. This function is a wrapper for rtables::summarize_row_groups().

      • @@ -291,14 +398,17 @@

        Functions -

        See also

        +

        See also +

        Relevant helper function h_append_grade_groups().

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     df <- data.frame(
    @@ -461,17 +571,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_patients_events_in_cols.html b/main/reference/count_patients_events_in_cols.html index c1c85d0629..83a5ac8762 100644 --- a/main/reference/count_patients_events_in_cols.html +++ b/main/reference/count_patients_events_in_cols.html @@ -1,17 +1,40 @@ - -Count patient events in columns — count_patients_events_in_cols • tern + + + + + +Count patient events in columns — count_patients_events_in_cols • tern + + + + + + + + + + + + + +If there are multiple occurrences of the same event recorded for a patient, the event is only counted once."> + + + + + Skip to contents @@ -27,26 +50,66 @@ + + @@ -69,7 +132,8 @@
    -

    Usage

    +

    Usage +

    summarize_patients_events_in_cols(
       lyt,
       id = "USUBJID",
    @@ -94,89 +158,119 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    id
    +
    id +

    (string)
    subject variable name.

    -
    filters_list
    +
    filters_list +

    (named list of character)
    list where each element in this list describes one type of event describe by filters, in the same format as s_count_patients_with_event(). If it has a label, then this will be used for the column title.

    -
    empty_stats
    +
    empty_stats +

    (character)
    optional names of the statistics that should be returned empty such that corresponding table cells will stay blank.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    In addition to any statistics added using filters_list, statistic options are: -'unique', 'all'

    +'unique', 'all'

    + -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    col_split
    +
    col_split +

    (flag)
    whether the columns should be split. Set to FALSE when the required column split has been done already earlier in the layout pipe.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    custom_label
    +
    custom_label +

    (string or NULL)
    if provided and labelstr is empty then this will be used as label.

    -
    + +
    -

    Value

    +

    Value +

    -
    • summarize_patients_events_in_cols() returns a layout object suitable for passing to further layouting functions, +

        +
      • summarize_patients_events_in_cols() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted content rows containing the statistics from s_count_patients_and_multiple_events() to the table layout.

      • -
      • s_count_patients_and_multiple_events() returns a list with the statistics:

        • unique: number of unique patients in df.

        • +
        +
          +
        • +

          s_count_patients_and_multiple_events() returns a list with the statistics:

          +
            +
          • unique: number of unique patients in df.

          • all: number of rows in df.

          • one element with the same name as in filters_list: number of rows in df, i.e. events, fulfilling the filter condition.

          • -
        • -
    + + + +
    -

    Functions

    +

    Functions +

    -
    • summarize_patients_events_in_cols(): Layout-creating function which can take statistics function +

        +
      • summarize_patients_events_in_cols(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::summarize_row_groups().

      • s_count_patients_and_multiple_events(): Statistics function which counts numbers of patients and multiple events defined by filters. Used as analysis function afun in summarize_patients_events_in_cols().

      • -
    + +
    -

    Examples

    +

    Examples +

    df <- data.frame(
       USUBJID = rep(c("id1", "id2", "id3", "id4"), c(2, 3, 1, 1)),
       ARM = c("A", "A", "B", "B", "B", "B", "A"),
    @@ -205,17 +299,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_patients_with_event.html b/main/reference/count_patients_with_event.html index 91b94ce2bb..0c4c3fe27c 100644 --- a/main/reference/count_patients_with_event.html +++ b/main/reference/count_patients_with_event.html @@ -1,17 +1,40 @@ - -Count the number of patients with a particular event — count_patients_with_event • tern + + + + + +Count the number of patients with a particular event — count_patients_with_event • tern + + + + + + + + + + + + + +If there are multiple records with the same event recorded for a patient, only one occurrence is counted."> + + + + + Skip to contents @@ -27,26 +50,66 @@ + + @@ -69,7 +132,8 @@
    -

    Usage

    +

    Usage +

    count_patients_with_event(
       lyt,
       vars,
    @@ -112,18 +176,23 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    filters
    +
    filters +

    (character)
    a character vector specifying the column names and flag variables to be used for counting the number of unique identifiers satisfying such conditions. Multiple column names and flags are accepted in this format @@ -131,111 +200,146 @@

    Argumentsriskdiff +
    riskdiff +

    (flag)
    whether a risk difference column is present. When set to TRUE, add_riskdiff() must be used as split_fun in the prior column split of the table layout, specifying which columns should be compared. See stat_propdiff_ci() for details on risk difference calculation.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    name of the column that contains the unique identifier.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -

    + +
    -

    Value

    +

    Value +

    -
    • count_patients_with_event() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_patients_with_event() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_patients_with_event() to the table layout.

      • -
      • s_count_patients_with_event() returns the count and fraction of unique identifiers with the defined event.

      • -
    + +
      +
    • s_count_patients_with_event() returns the count and fraction of unique identifiers with the defined event.

    • +
    +
      +
    • a_count_patients_with_event() returns the corresponding list with formatted rtables::CellValue().

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • count_patients_with_event(): Layout-creating function which can take statistics function +

        +
      • count_patients_with_event(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_patients_with_event(): Statistics function which counts the number of patients for which the defined event has occurred.

      • a_count_patients_with_event(): Formatted analysis function which is used as afun in count_patients_with_event().

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    lyt <- basic_table() %>%
       split_cols_by("ARM") %>%
       add_colcounts() %>%
    @@ -349,17 +453,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_patients_with_flags.html b/main/reference/count_patients_with_flags.html index 75db59b6ea..7c48c3d171 100644 --- a/main/reference/count_patients_with_flags.html +++ b/main/reference/count_patients_with_flags.html @@ -1,17 +1,40 @@ - -Count the number of patients with particular flags — count_patients_with_flags • tern + + + + + +Count the number of patients with particular flags — count_patients_with_flags • tern + + + + + + + + + + + + + +If there are multiple records with the same flag present for a patient, only one occurrence is counted."> + + + + + Skip to contents @@ -27,26 +50,66 @@ + + @@ -69,7 +132,8 @@
    -

    Usage

    +

    Usage +

    count_patients_with_flags(
       lyt,
       var,
    @@ -117,149 +181,193 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    var
    +
    var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    flag_variables
    +
    flag_variables +

    (character)
    a vector specifying the names of logical variables from analysis dataset used for counting the number of unique identifiers.

    -
    flag_labels
    +
    flag_labels +

    (character)
    vector of labels to use for flag variables. If any labels are also specified via the .labels parameter, the .labels values will take precedence and replace these labels.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    riskdiff
    +
    riskdiff +

    (flag)
    whether a risk difference column is present. When set to TRUE, add_riskdiff() must be used as split_fun in the prior column split of the table layout, specifying which columns should be compared. See stat_propdiff_ci() for details on risk difference calculation.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    name of the column that contains the unique identifier.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    + +
    -

    Value

    +

    Value +

    -
    • count_patients_with_flags() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_patients_with_flags() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_patients_with_flags() to the table layout.

      • -
      • s_count_patients_with_flags() returns the count and the fraction of unique identifiers with each particular +

      +
        +
      • s_count_patients_with_flags() returns the count and the fraction of unique identifiers with each particular flag as a list of statistics n, count, count_fraction, and n_blq, with one element per flag.

      • -
    + +
      +
    • a_count_patients_with_flags() returns the corresponding list with formatted rtables::CellValue().

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • count_patients_with_flags(): Layout-creating function which can take statistics function +

        +
      • count_patients_with_flags(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_patients_with_flags(): Statistics function which counts the number of patients for which a particular flag variable is TRUE.

      • a_count_patients_with_flags(): Formatted analysis function which is used as afun in count_patients_with_flags().

      • -
    + +
    -

    Note

    +

    Note +

    If flag_labels is not specified, variables labels will be extracted from df. If variables are not labeled, variable names will be used instead. Alternatively, a named vector can be supplied to flag_variables such that within each name-value pair the name corresponds to the variable name and the value is the label to use for this variable.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    # Add labelled flag variables to analysis dataset.
     adae <- tern_ex_adae %>%
       dplyr::mutate(
    @@ -411,17 +519,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/count_values.html b/main/reference/count_values.html index 8ef6e58eac..62a85789ce 100644 --- a/main/reference/count_values.html +++ b/main/reference/count_values.html @@ -1,15 +1,38 @@ - -Count specific values — count_values • tern + + + + + +Count specific values — count_values • tern + + + + + + + + + + + + + +counts will be generated for each variable."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    count_values(
       lyt,
       vars,
    @@ -110,97 +174,131 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    values
    +
    values +

    (character)
    specific values that should be counted.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .N_row
    +
    .N_row +

    (integer(1))
    row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

    -
    denom
    -

    (string)
    choice of denominator for proportion. Options are:

    • n: number of values in this row and column intersection.

    • +
      denom +
      +
      +

      (string)
      choice of denominator for proportion. Options are:

      +
        +
      • n: number of values in this row and column intersection.

      • N_row: total number of values in this row across columns.

      • N_col: total number of values in this column across rows.

      • -
      +
    +
    -
    + +
    -

    Value

    +

    Value +

    -
    • count_values() returns a layout object suitable for passing to further layouting functions, +

        +
      • count_values() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_count_values() to the table layout.

      • -
      • s_count_values() returns output of s_summary() for specified values of a non-numeric variable.

      • -
    + +
      +
    • s_count_values() returns output of s_summary() for specified values of a non-numeric variable.

    • +
    + +
    -

    Functions

    +

    Functions +

    -
    • count_values(): Layout-creating function which can take statistics function arguments +

        +
      • count_values(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_count_values(): S3 generic function to count values.

      • s_count_values(character): Method for character class.

      • @@ -209,18 +307,23 @@

        Functions -

        Note

        +

        Note +

        -
        • For factor variables, s_count_values checks whether values are all included in the levels of x +

            +
          • For factor variables, s_count_values checks whether values are all included in the levels of x and fails otherwise.

          • For count_values(), variable labels are shown when there is more than one element in vars, otherwise they are hidden.

          • -
    + +
    -

    Examples

    +

    Examples +

    # `count_values`
     basic_table() %>%
       count_values("Species", values = "setosa") %>%
    @@ -300,17 +403,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/cox_regression.html b/main/reference/cox_regression.html index e15f68b110..3886d5124d 100644 --- a/main/reference/cox_regression.html +++ b/main/reference/cox_regression.html @@ -1,7 +1,30 @@ - -Cox proportional hazards regression — cox_regression • tern + + + + + + +Cox proportional hazards regression — cox_regression • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    summarize_coxreg(
       lyt,
       variables,
    @@ -92,130 +156,166 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    control
    +
    control +

    (list)
    a list of parameters as returned by the helper function control_coxreg().

    -
    at
    +
    at +

    (list of numeric)
    when the candidate covariate is a numeric, use at to specify the value of the covariate at which the effect should be estimated.

    -
    multivar
    +
    multivar +

    (flag)
    whether multivariate Cox regression should run (defaults to FALSE), otherwise univariate Cox regression will run.

    -
    common_var
    +
    common_var +

    (string)
    the name of a factor variable in the dataset which takes the same value for all rows. This should be created during pre-processing if no such variable currently exists.

    -
    .stats
    -

    (character)
    the names of statistics to be reported among:

    • n: number of observations (univariate only)

    • +
      .stats +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n: number of observations (univariate only)

      • hr: hazard ratio

      • ci: confidence interval

      • pval: p-value of the treatment effect

      • pval_inter: p-value of the interaction effect between the treatment and the covariate (univariate only)

      • -
      +
    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    varlabels
    +
    varlabels +

    (list)
    a named list corresponds to the names of variables found in data, passed as a named list and corresponding to time, event, arm, strata, and covariates terms. If arm is missing from variables, then only Cox model(s) including the covariates will be fitted and the corresponding effect estimates will be tabulated later.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    na_str
    +
    na_str +

    (string)
    custom string to replace all NA values with. Defaults to "".

    -
    .section_div
    +
    .section_div +

    (string or NA)
    string which should be repeated as a section divider between sections. Defaults to NA for no section divider. If a vector of two strings are given, the first will be used between treatment and covariate sections and the second between different covariates.

    -
    model_df
    +
    model_df +

    (data.frame)
    contains the resulting model fit from a fit_coxreg function with tidying applied via broom::tidy().

    -
    .which_vars
    +
    .which_vars +

    (character)
    which rows should statistics be returned for from the given model. Defaults to "all". Other options include "var_main" for main effects, "inter" for interaction effects, and "multi_lvl" for multivariate model covariate level rows. When .which_vars is "all", specific variables can be selected by specifying .var_nms.

    -
    .var_nms
    +
    .var_nms +

    (character)
    the term value of rows in df for which .stats should be returned. Typically this is the name of a variable. If using variable labels, var should be a vector of both the desired variable name and the variable label in that order to see all .stats related to that variable. When .which_vars is "var_main", .var_nms should be only the variable name.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    eff
    +
    eff +

    (flag)
    whether treatment effect should be calculated. Defaults to FALSE.

    -
    var_main
    +
    var_main +

    (flag)
    whether main effects should be calculated. Defaults to FALSE.

    -
    .spl_context
    +
    .spl_context +

    (data.frame)
    gives information about ancestor split states that is passed by rtables.

    -
    cache_env
    +
    cache_env +

    (environment)
    an environment object used to cache the regression model in order to avoid repeatedly fitting the same model for every row in the table. Defaults to NULL (no caching).

    -
    + +
    -

    Value

    +

    Value +

    -
    • summarize_coxreg() returns a layout object suitable for passing to further layouting functions, +

        +
      • summarize_coxreg() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add a Cox regression table containing the chosen statistics to the table layout.

      • -
      • s_coxreg() returns the selected statistic for from the Cox regression model for the selected variable(s).

      • -
    + +
      +
    • s_coxreg() returns the selected statistic for from the Cox regression model for the selected variable(s).

    • +
    + +
    -

    Details

    +

    Details +

    Cox models are the most commonly used methods to estimate the magnitude of the effect in survival analysis. It assumes proportional hazards: the ratio of the hazards between groups (e.g., two arms) is constant over time. @@ -224,27 +324,34 @@

    Details

    -

    Functions

    +

    Functions +

    -
    + +
    -

    See also

    -

    fit_coxreg for relevant fitting functions, h_cox_regression for relevant +

    See also +

    +
    +

    fit_coxreg for relevant fitting functions, h_cox_regression for relevant helper functions, and tidy_coxreg for custom tidy methods.

    fit_coxreg_univar() and fit_coxreg_multivar() which also take the variables, data, at (univariate only), and control arguments but return unformatted univariate and multivariate -Cox regression models, respectively.

    +Cox regression models, respectively.

    +
    -

    Examples

    +

    Examples +

    library(survival)
     
     # Testing dataset [survival::bladder].
    @@ -493,17 +600,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/cox_regression_inter.html b/main/reference/cox_regression_inter.html index 09756d6206..7ef31c765a 100644 --- a/main/reference/cox_regression_inter.html +++ b/main/reference/cox_regression_inter.html @@ -1,11 +1,34 @@ - -Cox regression helper function for interactions — cox_regression_inter • tern + + + + + +Cox regression helper function for interactions — cox_regression_inter • tern + + + + + + + + + + + + + +of the covariate, in comparison to the treatment control."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,7 +123,8 @@
    -

    Usage

    +

    Usage +

    h_coxreg_inter_effect(x, effect, covar, mod, label, control, ...)
     
     # S3 method for class 'numeric'
    @@ -85,89 +149,121 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric or factor)
    the values of the covariate to be tested.

    -
    effect
    +
    effect +

    (string)
    the name of the effect to be tested and estimated.

    -
    covar
    +
    covar +

    (string)
    the name of the covariate in the model.

    -
    mod
    +
    mod +

    (coxph)
    a fitted Cox regression model (see survival::coxph()).

    -
    label
    +
    label +

    (string)
    the label to be returned as term_label.

    -
    control
    +
    control +

    (list)
    a list of controls as returned by control_coxreg().

    -
    ...
    +
    ... +

    see methods.

    -
    at
    +
    at +

    (list)
    a list with items named after the covariate, every item is a vector of levels at which the interaction should be estimated.

    -
    data
    +
    data +

    (data.frame)
    the data frame on which the model was fit.

    -
    variable, given
    +
    variable, given +

    (string)
    the name of variables in interaction. We seek the estimation of the levels of variable given the levels of given.

    -
    lvl_var, lvl_given
    +
    lvl_var, lvl_given +

    (character)
    corresponding levels as given by levels().

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    +

    Value +

    -
    • h_coxreg_inter_effect() returns a data.frame of covariate interaction effects consisting of the following +

        +
      • h_coxreg_inter_effect() returns a data.frame of covariate interaction effects consisting of the following variables: effect, term, term_label, level, n, hr, lcl, ucl, pval, and pval_inter.

      • -
      • h_coxreg_extract_interaction() returns the result of an interaction test and the estimated values. If +

      +
        +
      • h_coxreg_extract_interaction() returns the result of an interaction test and the estimated values. If no interaction, h_coxreg_univar_extract() is applied instead.

      • -
      • h_coxreg_inter_estimations() returns a list of matrices (one per level of variable) with rows corresponding -to the combinations of variable and given, with columns:

        • coef_hat: Estimation of the coefficient.

        • +
        +
          +
        • +

          h_coxreg_inter_estimations() returns a list of matrices (one per level of variable) with rows corresponding +to the combinations of variable and given, with columns:

          +
            +
          • coef_hat: Estimation of the coefficient.

          • coef_se: Standard error of the estimation.

          • hr: Hazard ratio.

          • lcl, ucl: Lower/upper confidence limit of the hazard ratio.

          • -
        • -
    + + + +
    -

    Details

    +

    Details +

    Given the cox regression investigating the effect of Arm (A, B, C; reference A) and Sex (F, M; reference Female) and the model being abbreviated: y ~ Arm + Sex + Arm:Sex. -The cox regression estimates the coefficients along with a variance-covariance matrix for:

    • b1 (arm b), b2 (arm c)

    • +The cox regression estimates the coefficients along with a variance-covariance matrix for:

      +
        +
      • b1 (arm b), b2 (arm c)

      • b3 (sex m)

      • b4 (arm b: sex m), b5 (arm c: sex m)

      • -

      The estimation of the Hazard Ratio for arm C/sex M is given in reference +

    +

    The estimation of the Hazard Ratio for arm C/sex M is given in reference to arm A/Sex M by exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5). The interaction coefficient is deduced by b2 + b5 while the standard error is obtained as $sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$.

    -

    Functions

    +

    Functions +

    -
    • h_coxreg_inter_effect(): S3 generic helper function to determine interaction effect.

    • +
        +
      • h_coxreg_inter_effect(): S3 generic helper function to determine interaction effect.

      • h_coxreg_inter_effect(numeric): Method for numeric class. Estimates the interaction with a numeric covariate.

      • h_coxreg_inter_effect(factor): Method for factor class. Estimate the interaction with a factor covariate.

      • h_coxreg_inter_effect(character): Method for character class. Estimate the interaction with a character covariate. @@ -175,17 +271,22 @@

        Functions -

        Note

        +

        Note +

        -
        • Automatic conversion of character to factor does not guarantee results can be generated correctly. It is +

            +
          • Automatic conversion of character to factor does not guarantee results can be generated correctly. It is therefore better to always pre-process the dataset such that factors are manually created from character variables before passing the dataset to rtables::build_table().

          • -
    + +
    -

    Examples

    +

    Examples +

    library(survival)
     
     set.seed(1, kind = "Mersenne-Twister")
    @@ -256,17 +357,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/cut_quantile_bins.html b/main/reference/cut_quantile_bins.html index 03c5beb654..6fe3d66e39 100644 --- a/main/reference/cut_quantile_bins.html +++ b/main/reference/cut_quantile_bins.html @@ -1,7 +1,30 @@ - -Cut numeric vector into empirical quantile bins — cut_quantile_bins • tern + + + + + + +Cut numeric vector into empirical quantile bins — cut_quantile_bins • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    cut_quantile_bins(
       x,
       probs = c(0.25, 0.5, 0.75),
    @@ -65,47 +129,58 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    the continuous variable values which should be cut into quantile bins. This may contain NA values, which are then not used for the quantile calculations, but included in the return vector.

    -
    probs
    +
    probs +

    (numeric)
    the probabilities identifying the quantiles. This is a sorted vector of unique proportion values, i.e. between 0 and 1, where the boundaries 0 and 1 must not be included.

    -
    labels
    +
    labels +

    (character)
    the unique labels for the quantile bins. When there are n probabilities in probs, then this must be n + 1 long.

    -
    type
    +
    type +

    (integer(1))
    type of quantiles to use, see stats::quantile() for details.

    -
    ordered
    +
    ordered +

    (flag)
    should the result be an ordered factor.

    -
    + +
    -

    Value

    +

    Value +

    A factor variable with appropriately-labeled bins as levels.

    -

    Note

    +

    Note +

    Intervals are closed on the right side. That is, the first bin is the interval [-Inf, q1] where q1 is the first quantile, the second bin is then (q1, q2], etc., and the last bin is (qn, +Inf] where qn is the last quantile.

    -

    Examples

    +

    Examples +

    # Default is to cut into quartile bins.
     cut_quantile_bins(cars$speed)
     #>  [1] [0%,25%]   [0%,25%]   [0%,25%]   [0%,25%]   [0%,25%]   [0%,25%]  
    @@ -176,17 +251,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/d_count_abnormal_by_baseline.html b/main/reference/d_count_abnormal_by_baseline.html index 3a4dee7e0c..7ae5bdcf47 100644 --- a/main/reference/d_count_abnormal_by_baseline.html +++ b/main/reference/d_count_abnormal_by_baseline.html @@ -1,7 +1,30 @@ - -Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline • tern + + + + + + +Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,33 +40,74 @@ + +
    @@ -54,25 +118,32 @@
    -

    Usage

    +

    Usage +

    d_count_abnormal_by_baseline(abnormal)
    -

    Arguments

    +

    Arguments +

    -
    abnormal
    +
    +
    abnormal +

    (character)
    values identifying the abnormal range level(s) in .var.

    -
    + +
    -

    Value

    +

    Value +

    Abnormal category labels for s_count_abnormal_by_baseline().

    -

    Examples

    +

    Examples +

    d_count_abnormal_by_baseline("LOW")
     #> $not_abnormal
     #> [1] "Not low"
    @@ -87,17 +158,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/d_count_cumulative.html b/main/reference/d_count_cumulative.html index 1b357f2f45..8dd624f531 100644 --- a/main/reference/d_count_cumulative.html +++ b/main/reference/d_count_cumulative.html @@ -1,7 +1,30 @@ - -Description of cumulative count — d_count_cumulative • tern + + + + + + +Description of cumulative count — d_count_cumulative • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,44 +117,54 @@
    -

    Usage

    +

    Usage +

    d_count_cumulative(threshold, lower_tail = TRUE, include_eq = TRUE)
    -

    Arguments

    +

    Arguments +

    -
    threshold
    +
    +
    threshold +

    (numeric(1))
    a cutoff value as threshold to count values of x.

    -
    lower_tail
    +
    lower_tail +

    (flag)
    whether to count lower tail, default is TRUE.

    -
    include_eq
    +
    include_eq +

    (flag)
    whether to include value equal to the threshold in count, default is TRUE.

    -
    + +
    -

    Value

    +

    Value +

    Labels for s_count_cumulative().

    + + - + + - + + diff --git a/main/reference/d_count_missed_doses.html b/main/reference/d_count_missed_doses.html index 64197d190e..2dfea68596 100644 --- a/main/reference/d_count_missed_doses.html +++ b/main/reference/d_count_missed_doses.html @@ -1,5 +1,28 @@ - -Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses • tern + + + + + + +Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,33 +38,74 @@ + +
    @@ -51,39 +115,48 @@
    -

    Usage

    +

    Usage +

    d_count_missed_doses(thresholds)
    -

    Arguments

    +

    Arguments +

    -
    thresholds
    +
    +
    thresholds +

    (numeric)
    minimum number of missed doses the patients had.

    -
    + +
    -

    Value

    +

    Value +

    d_count_missed_doses() returns a named character vector with the labels.

    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/d_onco_rsp_label.html b/main/reference/d_onco_rsp_label.html index 3ea5d6847b..753e7f2bd7 100644 --- a/main/reference/d_onco_rsp_label.html +++ b/main/reference/d_onco_rsp_label.html @@ -1,7 +1,30 @@ - -Description of standard oncology response — d_onco_rsp_label • tern + + + + + + +Description of standard oncology response — d_onco_rsp_label • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,29 +117,37 @@
    -

    Usage

    +

    Usage +

    d_onco_rsp_label(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (character)
    the standard oncology codes to be described.

    -
    + +
    -

    Value

    +

    Value +

    Response labels.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    d_onco_rsp_label(
       c("CR", "PR", "SD", "NON CR/PD", "PD", "NE", "Missing", "<Missing>", "NE/Missing")
     )
    @@ -106,17 +177,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/d_pkparam.html b/main/reference/d_pkparam.html index 310849b5ec..1a34b6cc75 100644 --- a/main/reference/d_pkparam.html +++ b/main/reference/d_pkparam.html @@ -1,5 +1,28 @@ - -Generate PK reference dataset — d_pkparam • tern + + + + + + +Generate PK reference dataset — d_pkparam • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,33 +114,38 @@
    -

    Usage

    +

    Usage +

    d_pkparam()
    -

    Value

    +

    Value +

    A data.frame of PK parameters.

    -

    Examples

    +

    Examples +

    pk_reference_dataset <- d_pkparam()
     
     
    + + - + + - + + diff --git a/main/reference/d_proportion.html b/main/reference/d_proportion.html index 6ee8a0e11b..6a4032f93e 100644 --- a/main/reference/d_proportion.html +++ b/main/reference/d_proportion.html @@ -1,7 +1,30 @@ - -Description of the proportion summary — d_proportion • tern + + + + + + +Description of the proportion summary — d_proportion • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,45 +117,55 @@
    -

    Usage

    +

    Usage +

    d_proportion(conf_level, method, long = FALSE)
    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string)
    the method used to construct the confidence interval for proportion of successful outcomes; one of waldcc, wald, clopper-pearson, wilson, wilsonc, strat_wilson, strat_wilsonc, agresti-coull or jeffreys.

    -
    long
    +
    long +

    (flag)
    whether a long or a short (default) description is required.

    -
    + +
    -

    Value

    +

    Value +

    String describing the analysis.

    + + - + + - + + diff --git a/main/reference/d_proportion_diff.html b/main/reference/d_proportion_diff.html index 51b2603ef9..8ebbc6febf 100644 --- a/main/reference/d_proportion_diff.html +++ b/main/reference/d_proportion_diff.html @@ -1,9 +1,32 @@ - -Description of method used for proportion comparison — d_proportion_diff • tern + + + + + +Description of method used for proportion comparison — d_proportion_diff • tern + + + + + + + + + + + + + +s_proportion_diff()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,47 +120,58 @@
    -

    Usage

    +

    Usage +

    d_proportion_diff(conf_level, method, long = FALSE)
    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string)
    the method used for the confidence interval estimation.

    -
    long
    +
    long +

    (flag)
    whether a long (TRUE) or a short (FALSE, default) description is required.

    -
    + +
    -

    Value

    +

    Value +

    A string describing the analysis.

    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/d_rsp_subgroups_colvars.html b/main/reference/d_rsp_subgroups_colvars.html index 8e18517d00..7d6b9dd351 100644 --- a/main/reference/d_rsp_subgroups_colvars.html +++ b/main/reference/d_rsp_subgroups_colvars.html @@ -1,7 +1,30 @@ - -Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars • tern + + + + + + +Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,44 +117,54 @@
    -

    Usage

    +

    Usage +

    d_rsp_subgroups_colvars(vars, conf_level = NULL, method = NULL)
    -

    Arguments

    +

    Arguments +

    -
    vars
    +
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string or NULL)
    specifies the test used to calculate the p-value for the difference between two proportions. For options, see test_proportion_diff(). Default is NULL so no test is performed.

    -
    + +
    -

    Value

    +

    Value +

    A list of variables to tabulate and their labels.

    + + - + + - + + diff --git a/main/reference/d_survival_subgroups_colvars.html b/main/reference/d_survival_subgroups_colvars.html index 4c6dd41b52..c4627e9f17 100644 --- a/main/reference/d_survival_subgroups_colvars.html +++ b/main/reference/d_survival_subgroups_colvars.html @@ -1,7 +1,30 @@ - -Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars • tern + + + + + + +Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,16 +117,23 @@
    -

    Usage

    +

    Usage +

    d_survival_subgroups_colvars(vars, conf_level, method, time_unit = NULL)
    -

    Arguments

    +

    Arguments +

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n_tot_events: Total number of events per group.

    • +
      +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n_tot_events: Total number of events per group.

      • n_events: Number of events per group.

      • n_tot: Total number of observations per group.

      • n: Number of observations per group.

      • @@ -73,42 +143,51 @@

        Argumentsconf_level +
        conf_level +

        (proportion)
        confidence level of the interval.

        -
        method
        +
        method +

        (string)
        p-value method for testing hazard ratio = 1.

        -
        time_unit
        +
        time_unit +

        (string)
        label with unit of median survival time. Default NULL skips displaying unit.

        -

    + +
    -

    Value

    +

    Value +

    A list of variables and their labels to tabulate.

    -

    Note

    +

    Note +

    At least one of n_tot and n_tot_events must be provided in vars.

    + + - + + - + + diff --git a/main/reference/d_test_proportion_diff.html b/main/reference/d_test_proportion_diff.html index cc9b7da094..933e4d828d 100644 --- a/main/reference/d_test_proportion_diff.html +++ b/main/reference/d_test_proportion_diff.html @@ -1,7 +1,30 @@ - -Description of the difference test between two proportions — d_test_proportion_diff • tern + + + + + + +Description of the difference test between two proportions — d_test_proportion_diff • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,36 +117,44 @@
    -

    Usage

    +

    Usage +

    d_test_proportion_diff(method)
    -

    Arguments

    +

    Arguments +

    -
    method
    +
    +
    method +

    (string)
    one of chisq, cmh, fisher, or schouten; specifies the test used to calculate the p-value.

    -
    + +
    -

    Value

    +

    Value +

    A string describing the test from which the p-value is derived.

    + + - + + - + + diff --git a/main/reference/day2month.html b/main/reference/day2month.html index b91b4e6bec..809e08dd5b 100644 --- a/main/reference/day2month.html +++ b/main/reference/day2month.html @@ -1,5 +1,28 @@ - -Conversion of days to months — day2month • tern + + + + + + +Conversion of days to months — day2month • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,25 +114,32 @@
    -

    Usage

    +

    Usage +

    day2month(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric(1))
    time in days.

    -
    + +
    -

    Value

    +

    Value +

    A numeric vector with the time in months.

    -

    Examples

    +

    Examples +

    x <- c(403, 248, 30, 86)
     day2month(x)
     #> [1] 13.2402464  8.1478439  0.9856263  2.8254620
    @@ -77,17 +147,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/decorate_grob.html b/main/reference/decorate_grob.html index 271a4ab0de..c16b37d3af 100644 --- a/main/reference/decorate_grob.html +++ b/main/reference/decorate_grob.html @@ -1,9 +1,32 @@ - -Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob • tern + + + + + +Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob • tern + + + + + + + + + + + + + +with title, footnote, and page numbers."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    decorate_grob(
       grob,
       titles,
    @@ -78,92 +142,113 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    grob
    +
    +
    grob +

    (grob)
    a grid grob object, optionally NULL if only a grob with the decoration should be shown.

    -
    titles
    +
    titles +

    (character)
    titles given as a vector of strings that are each separated by a newline and wrapped according to the page width.

    -
    footnotes
    +
    footnotes +

    (character)
    footnotes. Uses the same formatting rules as titles.

    -
    page
    +
    page +

    (string or NULL)
    page numeration. If NULL then no page number is displayed.

    -
    width_titles
    +
    width_titles +

    (grid::unit)
    width of titles. Usually defined as all the available space grid::unit(1, "npc"), it is affected by the parameter outer_margins. Right margins (outer_margins[4]) need to be subtracted to the allowed width.

    -
    width_footnotes
    +
    width_footnotes +

    (grid::unit)
    width of footnotes. Same default and margin correction as width_titles.

    -
    border
    +
    border +

    (flag)
    whether a border should be drawn around the plot or not.

    -
    padding
    +
    padding +

    (grid::unit)
    padding. A unit object of length 4. Innermost margin between the plot (grob) and, possibly, the border of the plot. Usually expressed in 4 identical values (usually "lines"). It defaults to grid::unit(rep(1, 4), "lines").

    -
    margins
    +
    margins +

    (grid::unit)
    margins. A unit object of length 4. Margins between the plot and the other elements in the list (e.g. titles, plot, and footers). This is usually expressed in 4 "lines", where the lateral ones are 0s, while top and bottom are 1s. It defaults to grid::unit(c(1, 0, 1, 0), "lines").

    -
    outer_margins
    +
    outer_margins +

    (grid::unit)
    outer margins. A unit object of length 4. It defines the general margin of the plot, considering also decorations like titles, footnotes, and page numbers. It defaults to grid::unit(c(2, 1.5, 3, 1.5), "cm").

    -
    gp_titles
    +
    gp_titles +

    (gpar)
    a gpar object. Mainly used to set different "fontsize".

    -
    gp_footnotes
    +
    gp_footnotes +

    (gpar)
    a gpar object. Mainly used to set different "fontsize".

    -
    name
    +
    name +

    a character identifier for the grob. Used to find the grob on the display list and/or as a child of another grob.

    -
    gp
    +
    gp +

    A "gpar" object, typically the output from a call to the function gpar. This is basically a list of graphical parameter settings.

    -
    vp
    +
    vp +

    a viewport object (or NULL).

    -
    + +
    -

    Value

    +

    Value +

    A grid grob (gTree).

    -

    Details

    +

    Details +

    The titles and footnotes will be ragged, i.e. each title will be wrapped individually.

    -

    Examples

    +

    Examples +

    library(grid)
     
     titles <- c(
    @@ -283,17 +368,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/decorate_grob_factory.html b/main/reference/decorate_grob_factory.html index 9795ac9080..22ee390289 100644 --- a/main/reference/decorate_grob_factory.html +++ b/main/reference/decorate_grob_factory.html @@ -1,5 +1,28 @@ - -Update page number — decorate_grob_factory • tern + + + + + + +Update page number — decorate_grob_factory • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,39 +114,48 @@
    -

    Usage

    +

    Usage +

    decorate_grob_factory(npages, ...)
    -

    Arguments

    +

    Arguments +

    -
    npages
    +
    +
    npages +

    (numeric(1))
    total number of pages.

    -
    ...
    +
    ... +

    arguments passed on to decorate_grob().

    -
    + +
    -

    Value

    +

    Value +

    Closure that increments the page number.

    + + - + + - + + diff --git a/main/reference/decorate_grob_set.html b/main/reference/decorate_grob_set.html index 04fdc9b6ec..f4d8bf4842 100644 --- a/main/reference/decorate_grob_set.html +++ b/main/reference/decorate_grob_set.html @@ -1,7 +1,30 @@ - -Decorate set of grobs and add page numbering — decorate_grob_set • tern + + + + + + +Decorate set of grobs and add page numbering — decorate_grob_set • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,29 +117,37 @@
    -

    Usage

    +

    Usage +

    decorate_grob_set(grobs, ...)
    -

    Arguments

    +

    Arguments +

    -
    grobs
    +
    +
    grobs +

    (list of grob)
    a list of grid grobs.

    -
    ...
    +
    ... +

    arguments passed on to decorate_grob().

    -
    + +
    -

    Value

    +

    Value +

    A decorated grob.

    -

    Examples

    +

    Examples +

    library(ggplot2)
     library(grid)
     g <- with(data = iris, {
    @@ -121,17 +192,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/default_na_str.html b/main/reference/default_na_str.html index 4495479e34..bbe4356b2d 100644 --- a/main/reference/default_na_str.html +++ b/main/reference/default_na_str.html @@ -1,15 +1,38 @@ - -Default string replacement for NA values — default_na_str • tern + + + + + +Default string replacement for NA values — default_na_str • tern + + + + + + + + + + + + + +then NA is used."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,39 +129,53 @@
    -

    Usage

    +

    Usage +

    default_na_str()
     
     set_default_na_str(na_str)
    -

    Arguments

    +

    Arguments +

    -
    na_str
    +
    +
    na_str +

    (string)
    single string value to set in the R environment options as the default value to replace NAs. Use getOption("tern_default_na_str") to check the current value set in the R environment (defaults to NULL if not set).

    -
    + +
    -

    Value

    +

    Value +

    -
    • default_na_str returns the current value if an R environment option has been set +

        +
      • default_na_str returns the current value if an R environment option has been set for "tern_default_na_str", or NA_character_ otherwise.

      • -
      • set_default_na_str has no return value.

      • -
    + +
      +
    • set_default_na_str has no return value.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • default_na_str(): Accessor for default NA value replacement string.

    • +
        +
      • default_na_str(): Accessor for default NA value replacement string.

      • set_default_na_str(): Setter for default NA value replacement string. Sets the option "tern_default_na_str" within the R environment.

      • -
    + +
    -

    Examples

    +

    Examples +

    # Default settings
     default_na_str()
     #> [1] NA
    @@ -117,17 +194,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/default_stats_formats_labels.html b/main/reference/default_stats_formats_labels.html index 49426ed452..c1cd0df64d 100644 --- a/main/reference/default_stats_formats_labels.html +++ b/main/reference/default_stats_formats_labels.html @@ -1,13 +1,36 @@ - -Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels • tern + + + + + +Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels • tern + + + + + + + + + + + + + +seen in analyze_vars(). See notes to understand why this is experimental."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    get_stats(
       method_groups = "analyze_vars_numeric",
       stats_in = NULL,
    @@ -88,48 +152,64 @@ 

    Usage

    -

    Format

    +

    Format +

    -
    • tern_default_stats is a named list of available statistics, with each element +

        +
      • tern_default_stats is a named list of available statistics, with each element named for their corresponding statistical method group.

      • -
      • tern_default_formats is a named vector of available default formats, with each element +

      +
        +
      • tern_default_formats is a named vector of available default formats, with each element named for their corresponding statistic.

      • -
      • tern_default_labels is a named character vector of available default labels, with each element +

      +
        +
      • tern_default_labels is a named character vector of available default labels, with each element named for their corresponding statistic.

      • -
    + +
    -

    Arguments

    +

    Arguments +

    -
    method_groups
    +
    +
    method_groups +

    (character)
    indicates the statistical method group (tern analyze function) to retrieve default statistics for. A character vector can be used to specify more than one statistical method group.

    -
    stats_in
    +
    stats_in +

    (character)
    statistics to retrieve for the selected method group.

    -
    add_pval
    +
    add_pval +

    (flag)
    should "pval" (or "pval_counts" if method_groups contains "analyze_vars_counts") be added to the statistical methods?

    -
    stats
    +
    stats +

    (character)
    statistical methods to get defaults for.

    -
    formats_in
    +
    formats_in +

    (named vector)
    inserted formats to replace defaults. It can be a character vector from formatters::list_valid_format_labels() or a custom format function.

    -
    labels_in
    +
    labels_in +

    (named character)
    inserted labels to replace defaults.

    -
    row_nms
    +
    row_nms +

    (character)
    row names. Levels of a factor or character variable, each of which the statistics in .stats will be calculated for. If this parameter is set, these variable levels will be used as the defaults, and the names of the given custom values should @@ -137,42 +217,62 @@

    Argumentsindents_in +
    indents_in +

    (named vector)
    inserted indent modifiers to replace defaults (default is 0L).

    -
    type
    +
    type +

    (string)
    "numeric" or "counts".

    -
    include_pval
    +
    include_pval +

    (flag)
    same as the add_pval argument in get_stats().

    -

    + +
    -

    Value

    - -
    • get_stats() returns a character vector of statistical methods.

    • -
    • get_formats_from_stats() returns a named vector of formats (if present in either +

      Value +

      + +
        +
      • get_stats() returns a character vector of statistical methods.

      • +
      +
      • get_labels_from_stats() returns a named character vector of labels (if present in either +

      +
        +
      • get_labels_from_stats() returns a named character vector of labels (if present in either tern_default_labels or labels_in, otherwise NULL).

      • -
      • get_indents_from_stats() returns a single indent modifier value to apply to all rows +

      +
        +
      • get_indents_from_stats() returns a single indent modifier value to apply to all rows or a named numeric vector of indent modifiers (if present, otherwise NULL).

      • -
      • summary_formats() returns a named vector of default statistic formats for the given data type.

      • -
      • summary_labels returns a named vector of default statistic labels for the given data type.

      • -
    + +
      +
    • summary_formats() returns a named vector of default statistic formats for the given data type.

    • +
    +
      +
    • summary_labels returns a named vector of default statistic labels for the given data type.

    • +
    +
    -

    Details

    +

    Details +

    Current choices for type are counts and numeric for analyze_vars() and affect get_stats().

    summary_* quick get functions for labels or formats uses get_stats and get_labels_from_stats or get_formats_from_stats respectively to retrieve relevant information.

    -

    Functions

    +

    Functions +

    -
    • get_stats(): Get statistics available for a given method +

        +
      • get_stats(): Get statistics available for a given method group (analyze function). To check available defaults see tern::tern_default_stats list.

      • get_formats_from_stats(): Get formats corresponding to a list of statistics. To check available defaults see tern::tern_default_formats list.

      • @@ -190,21 +290,25 @@

        Functions[Stable] Quick function to retrieve default labels for summary statistics. Returns labels of descriptive statistics which are understood by rtables. Similar to summary_formats.

        -

    + +
    -

    Note

    +

    Note +

    These defaults are experimental because we use the names of functions to retrieve the default statistics. This should be generalized in groups of methods according to more reasonable groupings.

    Formats in tern and rtables can be functions that take in the table cell value and return a string. This is well documented in vignette("custom_appearance", package = "rtables").

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    # analyze_vars is numeric
     num_stats <- get_stats("analyze_vars_numeric") # also the default
     
    @@ -874,17 +978,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/desctools_binom.html b/main/reference/desctools_binom.html index 8415755e90..d3ccb8a12d 100644 --- a/main/reference/desctools_binom.html +++ b/main/reference/desctools_binom.html @@ -1,7 +1,30 @@ - -Confidence intervals for a difference of binomials — desctools_binom • tern + + + + + + +Confidence intervals for a difference of binomials — desctools_binom • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    desctools_binom(
       x1,
       n1,
    @@ -80,60 +144,80 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    conf.level
    +
    +
    conf.level +

    (proportion)
    confidence level, defaults to 0.95.

    -
    sides
    +
    sides +

    (string)
    side of the confidence interval to compute. Must be one of "two-sided" (default), "left", or "right".

    -
    method
    +
    method +

    (string)
    method to use. Can be one out of: "wald", "wilson", "wilsoncc", "agresti-coull", "jeffreys", "modified wilson", "modified jeffreys", "clopper-pearson", "arcsine", "logit", "witting", "pratt", "midp", "lik", and "blaker".

    -
    x
    +
    x +

    (integer(1))
    number of successes.

    -
    n
    +
    n +

    (integer(1))
    number of trials.

    -
    + +
    -

    Value

    -

    A matrix of 3 values:

    • est: estimate of proportion difference.

    • +

      Value +

      +

      A matrix of 3 values:

      +
        +
      • est: estimate of proportion difference.

      • lwr.ci: estimate of lower end of the confidence interval.

      • upr.ci: estimate of upper end of the confidence interval.

      • -

      A matrix with 3 columns containing:

      • est: estimate of proportion difference.

      • +
      +

      A matrix with 3 columns containing:

      +
        +
      • est: estimate of proportion difference.

      • lwr.ci: lower end of the confidence interval.

      • upr.ci: upper end of the confidence interval.

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • desctools_binom(): Several confidence intervals for the difference between proportions.

    • +
        +
      • desctools_binom(): Several confidence intervals for the difference between proportions.

      • desctools_binomci(): Compute confidence intervals for binomial proportions.

      • -
    + + + + - + + - + + diff --git a/main/reference/df2gg.html b/main/reference/df2gg.html index 57f22299de..5e88e3c799 100644 --- a/main/reference/df2gg.html +++ b/main/reference/df2gg.html @@ -1,9 +1,32 @@ - -Convert data.frame object to ggplot object — df2gg • tern + + + + + +Convert data.frame object to ggplot object — df2gg • tern + + + + + + + + + + + + + +functions from the ggplot2 package."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    df2gg(
       df,
       colwidths = NULL,
    @@ -70,48 +134,60 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    a data frame.

    -
    colwidths
    +
    colwidths +

    (numeric or NULL)
    a vector of column widths. Each element's position in colwidths corresponds to the column of df in the same position. If NULL, column widths are calculated according to maximum number of characters per column.

    -
    font_size
    +
    font_size +

    (numeric(1))
    font size.

    -
    col_labels
    +
    col_labels +

    (flag)
    whether the column names (labels) of df should be used as the first row of the output table.

    -
    col_lab_fontface
    +
    col_lab_fontface +

    (string)
    font face to apply to the first row (of column labels if col_labels = TRUE). Defaults to "bold".

    -
    hline
    +
    hline +

    (flag)
    whether a horizontal line should be printed below the first row of the table.

    -
    bg_fill
    +
    bg_fill +

    (string)
    table background fill color.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot object.

    -

    Examples

    +

    Examples +

    if (FALSE) { # \dontrun{
     df2gg(head(iris, 5))
     
    @@ -120,17 +196,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/df_explicit_na.html b/main/reference/df_explicit_na.html index 11b0e91a50..34c929b203 100644 --- a/main/reference/df_explicit_na.html +++ b/main/reference/df_explicit_na.html @@ -1,9 +1,32 @@ - -Encode categorical missing values in a data frame — df_explicit_na • tern + + + + + +Encode categorical missing values in a data frame — df_explicit_na • tern + + + + + + + + + + + + + +variables in a data frame."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    df_explicit_na(
       data,
       omit_columns = NULL,
    @@ -68,39 +132,49 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    data set.

    -
    omit_columns
    +
    omit_columns +

    (character)
    names of variables from data that should not be modified by this function.

    -
    char_as_factor
    +
    char_as_factor +

    (flag)
    whether to convert character variables in data to factors.

    -
    logical_as_factor
    +
    logical_as_factor +

    (flag)
    whether to convert logical variables in data to factors.

    -
    na_level
    +
    na_level +

    (string)
    string used to replace all NA or empty values inside non-omit_columns columns.

    -
    + +
    -

    Value

    +

    Value +

    A data.frame with the chosen modifications applied.

    -

    Details

    +

    Details +

    Missing entries are those with NA or empty strings and will be replaced with a specified value. If factor variables include missing values, the missing value will be inserted as the last level. @@ -109,12 +183,14 @@

    Details

    -

    See also

    +

    See also +

    sas_na() and explicit_na() for other missing data helper functions.

    -

    Examples

    +

    Examples +

    my_data <- data.frame(
       u = c(TRUE, FALSE, NA, TRUE),
       v = factor(c("A", NA, NA, NA), levels = c("Z", "A")),
    @@ -172,17 +248,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/dot-is_equal_float.html b/main/reference/dot-is_equal_float.html index 1d9385a364..a08a58ec61 100644 --- a/main/reference/dot-is_equal_float.html +++ b/main/reference/dot-is_equal_float.html @@ -1,5 +1,28 @@ - -Utility function to check if a float value is equal to another float value — .is_equal_float • tern + + + + + + +Utility function to check if a float value is equal to another float value — .is_equal_float • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,39 +114,48 @@
    -

    Usage

    +

    Usage +

    .is_equal_float(x, y)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric(1))
    a float number.

    -
    y
    +
    y +

    (numeric(1))
    a float number.

    -
    + +
    -

    Value

    +

    Value +

    TRUE if identical, otherwise FALSE.

    + + - + + - + + diff --git a/main/reference/draw_grob.html b/main/reference/draw_grob.html index f95289f0e1..f9957aad88 100644 --- a/main/reference/draw_grob.html +++ b/main/reference/draw_grob.html @@ -1,7 +1,30 @@ - -Draw grob — draw_grob • tern + + + + + + +Draw grob — draw_grob • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,33 +40,74 @@ + +
    @@ -54,33 +118,42 @@
    -

    Usage

    +

    Usage +

    draw_grob(grob, newpage = TRUE, vp = NULL)
    -

    Arguments

    +

    Arguments +

    -
    grob
    +
    +
    grob +

    (grob)
    grid object.

    -
    newpage
    +
    newpage +

    (flag)
    draw on a new page.

    -
    vp
    +
    vp +

    (viewport or NULL)
    a viewport() object (or NULL).

    -
    + +
    -

    Value

    +

    Value +

    A grob.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(grid)
     
    @@ -105,17 +178,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/empty_vector_if_na.html b/main/reference/empty_vector_if_na.html index 54ebe86934..3e5d693e12 100644 --- a/main/reference/empty_vector_if_na.html +++ b/main/reference/empty_vector_if_na.html @@ -1,5 +1,28 @@ - -Return an empty numeric if all elements are NA. — empty_vector_if_na • tern + + + + + + +Return an empty numeric if all elements are NA. — empty_vector_if_na • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,41 +114,50 @@
    -

    Usage

    +

    Usage +

    empty_vector_if_na(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector.

    -
    + +
    -

    Value

    +

    Value +

    An empty numeric if all elements of x are NA, otherwise x.

    -

    Examples

    +

    Examples +

    x <- c(NA, NA, NA)
     # Internal function - empty_vector_if_na
     
    + + - + + - + + diff --git a/main/reference/estimate_coef.html b/main/reference/estimate_coef.html index 5a1902b19f..1a7d417bd2 100644 --- a/main/reference/estimate_coef.html +++ b/main/reference/estimate_coef.html @@ -1,7 +1,30 @@ - -Hazard ratio estimation in interactions — estimate_coef • tern + + + + + + +Hazard ratio estimation in interactions — estimate_coef • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    estimate_coef(
       variable,
       given,
    @@ -68,61 +132,80 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variable, given
    +
    +
    variable, given +

    (character(2))
    names of the two variables in the interaction. We seek the estimation of the levels of variable given the levels of given.

    -
    lvl_var, lvl_given
    +
    lvl_var, lvl_given +

    (character)
    corresponding levels given by levels().

    -
    coef
    +
    coef +

    (numeric)
    vector of estimated coefficients.

    -
    mmat
    +
    mmat +

    (named numeric) a vector filled with 0s used as a template to obtain the design matrix.

    -
    vcov
    +
    vcov +

    (matrix)
    variance-covariance matrix of underlying model.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of estimate intervals.

    -
    + +
    -

    Value

    +

    Value +

    A list of matrices (one per level of variable) with rows corresponding to the combinations of -variable and given, with columns:

    • coef_hat: Estimation of the coefficient.

    • +variable and given, with columns:

      +
        +
      • coef_hat: Estimation of the coefficient.

      • coef_se: Standard error of the estimation.

      • hr: Hazard ratio.

      • lcl, ucl: Lower/upper confidence limit of the hazard ratio.

      • -
    + +
    -

    Details

    +

    Details +

    Given the cox regression investigating the effect of Arm (A, B, C; reference A) and Sex (F, M; reference Female). The model is abbreviated: y ~ Arm + Sex + Arm x Sex. -The cox regression estimates the coefficients along with a variance-covariance matrix for:

    • b1 (arm b), b2 (arm c)

    • +The cox regression estimates the coefficients along with a variance-covariance matrix for:

      +
        +
      • b1 (arm b), b2 (arm c)

      • b3 (sex m)

      • b4 (arm b: sex m), b5 (arm c: sex m)

      • -

      Given that I want an estimation of the Hazard Ratio for arm C/sex M, the estimation +

    +

    Given that I want an estimation of the Hazard Ratio for arm C/sex M, the estimation will be given in reference to arm A/Sex M by exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5), therefore the interaction coefficient is given by b2 + b5 while the standard error is obtained as $1.96 * sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$ for a confidence level of 0.95.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(survival)
     
    @@ -144,17 +227,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/estimate_multinomial_rsp.html b/main/reference/estimate_multinomial_rsp.html index e90da7a9f0..37b9d12b5e 100644 --- a/main/reference/estimate_multinomial_rsp.html +++ b/main/reference/estimate_multinomial_rsp.html @@ -1,11 +1,34 @@ - -Estimate proportions of each level of a variable — estimate_multinomial_rsp • tern + + + + + +Estimate proportions of each level of a variable — estimate_multinomial_rsp • tern + + + + + + + + + + + + + +var, should be a factor variable, the values of which will be used as labels within the output table."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,7 +123,8 @@
    -

    Usage

    +

    Usage +

    estimate_multinomial_response(
       lyt,
       var,
    @@ -81,96 +145,126 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    var
    +
    var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n_prop', 'prop_ci'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n_prop', 'prop_ci'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    x
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    + +
    -

    Value

    +

    Value +

    -
    • estimate_multinomial_response() returns a layout object suitable for passing to further layouting functions, +

        +
      • estimate_multinomial_response() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_length_proportion() to the table layout.

      • -
    + + + +
    -

    Functions

    +

    Functions +

    -
    • estimate_multinomial_response(): Layout-creating function which can take statistics function arguments +

        +
      • estimate_multinomial_response(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze() and rtables::summarize_row_groups().

      • s_length_proportion(): Statistics function which feeds the length of x as number of successes, and .N_col as total number of successes and failures into s_proportion().

      • a_length_proportion(): Formatted analysis function which is used as afun in estimate_multinomial_response().

      • -
    + +
    -

    See also

    +

    See also +

    Relevant description function d_onco_rsp_label().

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # Use of the layout creating function.
    @@ -238,17 +332,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/estimate_proportion.html b/main/reference/estimate_proportion.html index 521b2004a6..9fb9755333 100644 --- a/main/reference/estimate_proportion.html +++ b/main/reference/estimate_proportion.html @@ -1,15 +1,38 @@ - -Proportion estimation — estimate_proportion • tern + + + + + +Proportion estimation — estimate_proportion • tern + + + + + + + + + + + + + +argument."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    estimate_proportion(
       lyt,
       vars,
    @@ -114,89 +178,111 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string)
    the method used to construct the confidence interval for proportion of successful outcomes; one of waldcc, wald, clopper-pearson, wilson, wilsonc, strat_wilson, strat_wilsonc, agresti-coull or jeffreys.

    -
    weights
    +
    weights +

    (numeric or NULL)
    weights for each level of the strata. If NULL, they are estimated using the iterative algorithm proposed in Yan2010-jt;textualtern that minimizes the weighted squared length of the confidence interval.

    -
    max_iterations
    +
    max_iterations +

    (count)
    maximum number of iterations for the iterative procedure used to find estimates of optimal weights.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    long
    +
    long +

    (flag)
    whether a long description is required.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n_prop', 'prop_ci'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n_prop', 'prop_ci'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (logical or data.frame)
    if only a logical vector is used, it indicates whether each subject is a responder or not. TRUE represents a successful outcome. If a data.frame is provided, also the strata variable @@ -205,38 +291,52 @@

    Arguments.var +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -

    + +
    -

    Value

    +

    Value +

    -
    • estimate_proportion() returns a layout object suitable for passing to further layouting functions, +

        +
      • estimate_proportion() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_proportion() to the table layout.

      • -
      • s_proportion() returns statistics n_prop (n and proportion) and prop_ci (proportion CI) for a +

      +
        +
      • s_proportion() returns statistics n_prop (n and proportion) and prop_ci (proportion CI) for a given variable.

      • -
    + + +
    -

    Functions

    +

    Functions +

    -
    • estimate_proportion(): Layout-creating function which can take statistics function arguments +

        +
      • estimate_proportion(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_proportion(): Statistics function estimating a proportion along with its confidence interval.

      • a_proportion(): Formatted analysis function which is used as afun in estimate_proportion().

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    dta_test <- data.frame(
       USUBJID = paste0("S", 1:12),
       ARM     = rep(LETTERS[1:3], each = 4),
    @@ -298,17 +398,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/ex_data.html b/main/reference/ex_data.html index 6f680f410d..4fb0e2d87e 100644 --- a/main/reference/ex_data.html +++ b/main/reference/ex_data.html @@ -1,5 +1,28 @@ - -Simulated CDISC data for examples — ex_data • tern + + + + + + +Simulated CDISC data for examples — ex_data • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    tern_ex_adsl
     
     tern_ex_adae
    @@ -66,7 +130,8 @@ 

    Usage

    -

    Format

    +

    Format +

    rds (data.frame)

    An object of class tbl_df (inherits from tbl, data.frame) with 200 rows and 21 columns.

    An object of class tbl_df (inherits from tbl, data.frame) with 541 rows and 42 columns.

    @@ -76,28 +141,33 @@

    Format<

    An object of class tbl_df (inherits from tbl, data.frame) with 1000 rows and 28 columns.

    -

    Functions

    +

    Functions +

    -
    • tern_ex_adsl: ADSL data

    • +
        +
      • tern_ex_adsl: ADSL data

      • tern_ex_adae: ADAE data

      • tern_ex_adlb: ADLB data

      • tern_ex_adpp: ADPP data

      • tern_ex_adrs: ADRS data

      • tern_ex_adtte: ADTTE data

      • -
    + +
    + + - + + - + + diff --git a/main/reference/explicit_na.html b/main/reference/explicit_na.html index 5792a089a1..c6040f7db3 100644 --- a/main/reference/explicit_na.html +++ b/main/reference/explicit_na.html @@ -1,7 +1,30 @@ - -Missing data — explicit_na • tern + + + + + + +Missing data — explicit_na • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,29 +117,37 @@
    -

    Usage

    +

    Usage +

    explicit_na(x, label = "<Missing>")
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (factor or character)
    values for which any missing values should be substituted.

    -
    label
    +
    label +

    (string)
    string that missing data should be replaced with.

    -
    + +
    -

    Value

    +

    Value +

    x with any NA values substituted by label.

    -

    Examples

    +

    Examples +

    explicit_na(c(NA, "a", "b"))
     #> [1] "<Missing>" "a"         "b"        
     is.na(explicit_na(c(NA, "a", "b")))
    @@ -94,17 +165,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/extract_by_name.html b/main/reference/extract_by_name.html index 98ccee8e75..84a3de2abe 100644 --- a/main/reference/extract_by_name.html +++ b/main/reference/extract_by_name.html @@ -1,7 +1,30 @@ - -Extract elements by name — extract_by_name • tern + + + + + + +Extract elements by name — extract_by_name • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,46 +117,58 @@
    -

    Usage

    +

    Usage +

    extract_by_name(x, names)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (named vector)
    where to extract named elements from.

    -
    names
    +
    names +

    (character)
    vector of names to extract.

    -
    + +
    -

    Value

    +

    Value +

    NULL if x is NULL, otherwise the extracted elements from x.

    -

    Details

    +

    Details +

    -
    • If x is NULL, then still always NULL is returned (same as in base function).

    • +
        +
      • If x is NULL, then still always NULL is returned (same as in base function).

      • If x is not NULL, then the intersection of its names is made with names and those elements are returned. That is, names which don't appear in x are not returned as NAs.

      • -
    + + + + - + + - + + diff --git a/main/reference/extract_rsp_biomarkers.html b/main/reference/extract_rsp_biomarkers.html index bb2ad98169..451bad4109 100644 --- a/main/reference/extract_rsp_biomarkers.html +++ b/main/reference/extract_rsp_biomarkers.html @@ -1,19 +1,42 @@ - -Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers • tern + + + + + +Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers • tern + + + + + + + + + + + + + +groups_lists optionally specifies groupings for subgroups variables."> + + + + + Skip to contents @@ -29,26 +52,66 @@ + + @@ -72,7 +135,8 @@
    -

    Usage

    +

    Usage +

    extract_rsp_biomarkers(
       variables,
       data,
    @@ -83,51 +147,63 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    control
    +
    control +

    (named list)
    controls for the response definition and the confidence level produced by control_logistic().

    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    + +
    -

    Value

    +

    Value +

    A data.frame with columns biomarker, biomarker_label, n_tot, n_rsp, prop, or, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, and row_type.

    -

    Note

    +

    Note +

    You can also specify a continuous variable in rsp and then use the response_definition control to convert that internally to a logical variable reflecting binary response.

    -

    See also

    +

    See also +

    h_logistic_mult_cont_df() which is used internally.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(forcats)
     
    @@ -235,17 +311,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/extract_rsp_subgroups.html b/main/reference/extract_rsp_subgroups.html index 2384508914..0417086854 100644 --- a/main/reference/extract_rsp_subgroups.html +++ b/main/reference/extract_rsp_subgroups.html @@ -1,15 +1,38 @@ - -Prepare response data for population subgroups in data frames — extract_rsp_subgroups • tern + + + + + +Prepare response data for population subgroups in data frames — extract_rsp_subgroups • tern + + + + + + + + + + + + + +groups_lists optionally specifies groupings for subgroups variables."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    extract_rsp_subgroups(
       variables,
       data,
    @@ -78,60 +142,76 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string or NULL)
    specifies the test used to calculate the p-value for the difference between two proportions. For options, see test_proportion_diff(). Default is NULL so no test is performed.

    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    + +
    -

    Value

    -

    A named list of two elements:

    • prop: A data.frame containing columns arm, n, n_rsp, prop, subgroup, var, +

      Value +

      +

      A named list of two elements:

      +
        +
      • prop: A data.frame containing columns arm, n, n_rsp, prop, subgroup, var, var_label, and row_type.

      • or: A data.frame containing columns arm, n_tot, or, lcl, ucl, conf_level, subgroup, var, var_label, and row_type.

      • -
    + +
    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/extract_survival_biomarkers.html b/main/reference/extract_survival_biomarkers.html index 5765030a30..45cb75df26 100644 --- a/main/reference/extract_survival_biomarkers.html +++ b/main/reference/extract_survival_biomarkers.html @@ -1,15 +1,38 @@ - -Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers • tern + + + + + +Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers • tern + + + + + + + + + + + + + +groups_lists optionally specifies groupings for subgroups variables."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    extract_survival_biomarkers(
       variables,
       data,
    @@ -77,54 +141,66 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    control
    +
    control +

    (list)
    a list of parameters as returned by the helper function control_coxreg().

    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    + +
    -

    Value

    +

    Value +

    A data.frame with columns biomarker, biomarker_label, n_tot, n_tot_events, median, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, and row_type.

    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/extract_survival_subgroups.html b/main/reference/extract_survival_subgroups.html index 686cdc2894..cf228acad4 100644 --- a/main/reference/extract_survival_subgroups.html +++ b/main/reference/extract_survival_subgroups.html @@ -1,15 +1,38 @@ - -Prepare survival data for population subgroups in data frames — extract_survival_subgroups • tern + + + + + +Prepare survival data for population subgroups in data frames — extract_survival_subgroups • tern + + + + + + + + + + + + + +groups_lists optionally specifies groupings for subgroups variables."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    extract_survival_subgroups(
       variables,
       data,
    @@ -77,62 +141,81 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    control
    -

    (list)
    parameters for comparison details, specified by using the helper function -control_coxph(). Some possible parameter options are:

    • pval_method (string)
      p-value method for testing the null hypothesis that hazard ratio = 1. Default +

      control +
      +
      +

      (list)
      parameters for comparison details, specified by using the helper function +control_coxph(). Some possible parameter options are:

      +
        +
      • pval_method (string)
        p-value method for testing the null hypothesis that hazard ratio = 1. Default method is "log-rank" which comes from survival::survdiff(), can also be set to "wald" or "likelihood" (from survival::coxph()).

      • ties (string)
        specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in survival::coxph().

      • conf_level (proportion)
        confidence level of the interval for HR.

      • -
      +
    +
    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    + +
    -

    Value

    -

    A named list of two elements:

    • survtime: A data.frame containing columns arm, n, n_events, median, subgroup, var, +

      Value +

      +

      A named list of two elements:

      +
        +
      • survtime: A data.frame containing columns arm, n, n_events, median, subgroup, var, var_label, and row_type.

      • hr: A data.frame containing columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, and row_type.

      • -
    + +
    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/extreme_format.html b/main/reference/extreme_format.html index dbefe26e18..3ba1d7e29f 100644 --- a/main/reference/extreme_format.html +++ b/main/reference/extreme_format.html @@ -1,7 +1,30 @@ - -Format extreme values — extreme_format • tern + + + + + + +Format extreme values — extreme_format • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,49 +117,65 @@
    -

    Usage

    +

    Usage +

    h_get_format_threshold(digits = 2L)
     
     h_format_threshold(x, digits = 2L)
    -

    Arguments

    +

    Arguments +

    -
    digits
    +
    +
    digits +

    (integer(1))
    number of decimal places to display.

    -
    x
    +
    x +

    (numeric(1))
    value to format.

    -
    + +
    -

    Value

    +

    Value +

    -
    • h_get_format_threshold() returns a list of 2 elements: threshold, with low and high thresholds, +

        +
      • h_get_format_threshold() returns a list of 2 elements: threshold, with low and high thresholds, and format_string, with thresholds formatted as strings.

      • -
      • h_format_threshold() returns the given value, or if the value is not within the digit threshold the relation +

      +
        +
      • h_format_threshold() returns the given value, or if the value is not within the digit threshold the relation of the given value to the digit threshold, as a formatted string.

      • -
    + +
    -

    Details

    +

    Details +

    For each input, apply a format to the specified number of digits. If the value is below a threshold, it returns "<0.01" e.g. if the number of digits is 2. If the value is above a threshold, it returns ">999.99" e.g. if the number of digits is 2. If it is zero, then returns "0.00".

    -

    Functions

    +

    Functions +

    -
    • h_get_format_threshold(): Internal helper function to calculate the threshold and create formatted strings +

        +
      • h_get_format_threshold(): Internal helper function to calculate the threshold and create formatted strings used in Formatting Functions. Returns a list with elements threshold and format_string.

      • h_format_threshold(): Internal helper function to apply a threshold format to a value. Creates a formatted string to be used in Formatting Functions.

      • -
    + +
    -

    See also

    +

    See also +

    Other formatting functions: format_auto(), format_count_fraction(), @@ -113,7 +192,8 @@

    See also
    -

    Examples

    +

    Examples +

    h_get_format_threshold(2L)
     #> $threshold
     #>    low   high 
    @@ -132,17 +212,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/f_conf_level.html b/main/reference/f_conf_level.html index 975867a13a..f5a91150a6 100644 --- a/main/reference/f_conf_level.html +++ b/main/reference/f_conf_level.html @@ -1,5 +1,28 @@ - -Utility function to create label for confidence interval — f_conf_level • tern + + + + + + +Utility function to create label for confidence interval — f_conf_level • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,35 +114,43 @@
    -

    Usage

    +

    Usage +

    f_conf_level(conf_level)
    -

    Arguments

    +

    Arguments +

    -
    conf_level
    +
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    +

    Value +

    A string.

    + + - + + - + + diff --git a/main/reference/f_pval.html b/main/reference/f_pval.html index 4c0a7baceb..4136dd8aa8 100644 --- a/main/reference/f_pval.html +++ b/main/reference/f_pval.html @@ -1,5 +1,28 @@ - -Utility function to create label for p-value — f_pval • tern + + + + + + +Utility function to create label for p-value — f_pval • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,35 +114,43 @@
    -

    Usage

    +

    Usage +

    f_pval(test_mean)
    -

    Arguments

    +

    Arguments +

    -
    test_mean
    +
    +
    test_mean +

    (numeric(1))
    mean value to test under the null hypothesis.

    -
    + +
    -

    Value

    +

    Value +

    A string.

    + + - + + - + + diff --git a/main/reference/fct_collapse_only.html b/main/reference/fct_collapse_only.html index d201cd1193..ea4fe6dcc9 100644 --- a/main/reference/fct_collapse_only.html +++ b/main/reference/fct_collapse_only.html @@ -1,11 +1,34 @@ - -Collapse factor levels and keep only those new group levels — fct_collapse_only • tern + + + + + +Collapse factor levels and keep only those new group levels — fct_collapse_only • tern + + + + + + + + + + + + + +only be included if there are missing values)."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,45 +123,56 @@
    -

    Usage

    +

    Usage +

    fct_collapse_only(.f, ..., .na_level = "<Missing>")
    -

    Arguments

    +

    Arguments +

    -
    .f
    +
    +
    .f +

    (factor or character)
    original vector.

    -
    ...
    +
    ... +

    (named character)
    levels in each vector provided will be collapsed into the new level given by the respective name.

    -
    .na_level
    +
    .na_level +

    (string)
    which level to use for other levels, which should be missing in the new factor. Note that this level must not be contained in the new levels specified in ....

    -
    + +
    -

    Value

    +

    Value +

    A modified factor with collapsed levels. Values and levels which are not included in the given character vector input will be set to the missing level .na_level.

    -

    Note

    +

    Note +

    Any existing NAs in the input vector will not be replaced by the missing level. If needed, explicit_na() can be called separately on the result.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    fct_collapse_only(factor(c("a", "b", "c", "d")), TRT = "b", CTRL = c("c", "d"))
     #> [1] <Missing> TRT       CTRL      CTRL     
     #> Levels: TRT CTRL <Missing>
    @@ -106,17 +180,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/fct_discard.html b/main/reference/fct_discard.html index 9206ac428d..e1ff8c1b94 100644 --- a/main/reference/fct_discard.html +++ b/main/reference/fct_discard.html @@ -1,7 +1,30 @@ - -Discard specified levels of a factor — fct_discard • tern + + + + + + +Discard specified levels of a factor — fct_discard • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,29 +117,37 @@
    -

    Usage

    +

    Usage +

    fct_discard(x, discard)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (factor)
    the original factor.

    -
    discard
    +
    discard +

    (character)
    levels to discard.

    -
    + +
    -

    Value

    +

    Value +

    A modified factor with observations as well as levels from discard dropped.

    -

    Examples

    +

    Examples +

    fct_discard(factor(c("a", "b", "c")), "c")
     #> [1] a b
     #> Levels: a b
    @@ -84,17 +155,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/fct_explicit_na_if.html b/main/reference/fct_explicit_na_if.html index 9329f507cb..d35f9798a0 100644 --- a/main/reference/fct_explicit_na_if.html +++ b/main/reference/fct_explicit_na_if.html @@ -1,9 +1,32 @@ - -Insertion of explicit missing values in a factor — fct_explicit_na_if • tern + + + + + +Insertion of explicit missing values in a factor — fct_explicit_na_if • tern + + + + + + + + + + + + + +existing NA values will be explicitly converted to given na_level."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,37 +120,47 @@
    -

    Usage

    +

    Usage +

    fct_explicit_na_if(x, condition, na_level = "<Missing>")
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (factor)
    the original factor.

    -
    condition
    +
    condition +

    (logical)
    positions at which to insert missing values.

    -
    na_level
    +
    na_level +

    (string)
    which level to use for missing values.

    -
    + +
    -

    Value

    +

    Value +

    A modified factor with inserted and existing NA converted to na_level.

    -

    See also

    +

    See also +

    forcats::fct_na_value_to_level() which is used internally.

    -

    Examples

    +

    Examples +

    fct_explicit_na_if(factor(c("a", "b", NA)), c(TRUE, FALSE, FALSE))
     #> [1] <Missing> b         <Missing>
     #> Levels: a b <Missing>
    @@ -95,17 +168,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/fit_coxreg.html b/main/reference/fit_coxreg.html index b3fceb221c..c4815b9b7b 100644 --- a/main/reference/fit_coxreg.html +++ b/main/reference/fit_coxreg.html @@ -1,7 +1,30 @@ - -Fitting functions for Cox proportional hazards regression — fit_coxreg • tern + + + + + + +Fitting functions for Cox proportional hazards regression — fit_coxreg • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,70 +117,97 @@
    -

    Usage

    +

    Usage +

    fit_coxreg_univar(variables, data, at = list(), control = control_coxreg())
     
     fit_coxreg_multivar(variables, data, control = control_coxreg())
    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list)
    the names of the variables found in data, passed as a named list and corresponding to the time, event, arm, strata, and covariates terms. If arm is missing from variables, then only Cox model(s) including the covariates will be fitted and the corresponding effect estimates will be tabulated later.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to fit the models.

    -
    at
    +
    at +

    (list of numeric)
    when the candidate covariate is a numeric, use at to specify the value of the covariate at which the effect should be estimated.

    -
    control
    +
    control +

    (list)
    a list of parameters as returned by the helper function control_coxreg().

    -
    + +
    -

    Value

    +

    Value +

    -
    • fit_coxreg_univar() returns a coxreg.univar class object which is a named list -with 5 elements:

      • mod: Cox regression models fitted by survival::coxph().

      • +
          +
        • +

          fit_coxreg_univar() returns a coxreg.univar class object which is a named list +with 5 elements:

          +
            +
          • mod: Cox regression models fitted by survival::coxph().

          • data: The original data frame input.

          • control: The original control input.

          • vars: The variables used in the model.

          • at: Value of the covariate at which the effect should be estimated.

          • -
        • -
        • fit_coxreg_multivar() returns a coxreg.multivar class object which is a named list -with 4 elements:

          +
        • +
        +
          +
        • +

          fit_coxreg_multivar() returns a coxreg.multivar class object which is a named list +with 4 elements:

          +
            +
          • mod: Cox regression model fitted by survival::coxph().

          • data: The original data frame input.

          • control: The original control input.

          • vars: The variables used in the model.

          • -
        • -
    + + + +
    -

    Functions

    +

    Functions +

    -
    • fit_coxreg_univar(): Fit a series of univariate Cox regression models given the inputs.

    • +
        +
      • fit_coxreg_univar(): Fit a series of univariate Cox regression models given the inputs.

      • fit_coxreg_multivar(): Fit a multivariate Cox regression model.

      • -
    + +
    -

    Note

    +

    Note +

    When using fit_coxreg_univar there should be two study arms.

    -

    See also

    +

    See also +

    h_cox_regression for relevant helper functions, cox_regression.

    -

    Examples

    +

    Examples +

    library(survival)
     
     set.seed(1, kind = "Mersenne-Twister")
    @@ -212,17 +302,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/fit_logistic.html b/main/reference/fit_logistic.html index 8506b15fa7..d28e21bf4d 100644 --- a/main/reference/fit_logistic.html +++ b/main/reference/fit_logistic.html @@ -1,7 +1,30 @@ - -Fit for logistic regression — fit_logistic • tern + + + + + + +Fit for logistic regression — fit_logistic • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    fit_logistic(
       data,
       variables = list(response = "Response", arm = "ARMCD", covariates = NULL, interaction =
    @@ -64,41 +128,53 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    the data frame on which the model was fit.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    response_definition
    +
    response_definition +

    (string)
    the definition of what an event is in terms of response. This will be used when fitting the (conditional) logistic regression model on the left hand side of the formula.

    -
    + +
    -

    Value

    +

    Value +

    A fitted logistic regression model.

    -

    Model Specification

    +

    Model Specification +

    -

    The variables list needs to include the following elements:

    • arm: Treatment arm variable name.

    • +

      The variables list needs to include the following elements:

      +
        +
      • arm: Treatment arm variable name.

      • response: The response arm variable name. Usually this is a 0/1 variable.

      • covariates: This is either NULL (no covariates) or a character vector of covariate variable names.

      • interaction: This is either NULL (no interaction) or a string of a single covariate variable name already included in covariates. Then the interaction with the treatment arm is included in the model.

      • -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adrs_f <- tern_ex_adrs %>%
    @@ -133,17 +209,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/fit_rsp_step.html b/main/reference/fit_rsp_step.html index 8f82e8f656..0162aef15f 100644 --- a/main/reference/fit_rsp_step.html +++ b/main/reference/fit_rsp_step.html @@ -1,19 +1,42 @@ - -Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step • tern + + + + + +Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step • tern + + + + + + + + + + + + + +where degree is specified by control_step()."> + + + + + Skip to contents @@ -29,26 +52,66 @@ + + @@ -72,47 +135,58 @@
    -

    Usage

    +

    Usage +

    fit_rsp_step(variables, data, control = c(control_step(), control_logistic()))
    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of character)
    list of analysis variables: needs response, arm, biomarker, and optional covariates and strata.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    control
    +
    control +

    (named list)
    combined control list from control_step() and control_logistic().

    -
    + +
    -

    Value

    +

    Value +

    A matrix of class step. The first part of the columns describe the subgroup intervals used for the biomarker variable, including where the center of the intervals are and their bounds. The second part of the columns contain the estimates for the treatment arm comparison.

    -

    Note

    +

    Note +

    For the default degree 0 the biomarker variable is not included in the model.

    -

    See also

    +

    See also +

    control_step() and control_logistic() for the available customization options.

    -

    Examples

    +

    Examples +

    # Testing dataset with just two treatment arms.
     library(survival)
     library(dplyr)
    @@ -194,17 +268,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/fit_survival_step.html b/main/reference/fit_survival_step.html index 30380352f3..5feda50bdd 100644 --- a/main/reference/fit_survival_step.html +++ b/main/reference/fit_survival_step.html @@ -1,17 +1,40 @@ - -Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step • tern + + + + + +Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step • tern + + + + + + + + + + + + + +where degree is specified by control_step()."> + + + + + Skip to contents @@ -27,26 +50,66 @@ + + @@ -69,7 +132,8 @@
    -

    Usage

    +

    Usage +

    fit_survival_step(
       variables,
       data,
    @@ -78,39 +142,49 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of character)
    list of analysis variables: needs time, event, arm, biomarker, and optional covariates and strata.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    control
    +
    control +

    (named list)
    combined control list from control_step() and control_coxph().

    -
    + +
    -

    Value

    +

    Value +

    A matrix of class step. The first part of the columns describe the subgroup intervals used for the biomarker variable, including where the center of the intervals are and their bounds. The second part of the columns contain the estimates for the treatment arm comparison.

    -

    Note

    +

    Note +

    For the default degree 0 the biomarker variable is not included in the model.

    -

    See also

    +

    See also +

    control_step() and control_coxph() for the available customization options.

    -

    Examples

    +

    Examples +

    # Testing dataset with just two treatment arms.
     library(dplyr)
     
    @@ -183,17 +257,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/forest_viewport.html b/main/reference/forest_viewport.html index e6e5f577c7..1b3e4f40ae 100644 --- a/main/reference/forest_viewport.html +++ b/main/reference/forest_viewport.html @@ -1,5 +1,28 @@ - -Create a viewport tree for the forest plot — forest_viewport • tern + + + + + + +Create a viewport tree for the forest plot — forest_viewport • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    forest_viewport(
       tbl,
       width_row_names = NULL,
    @@ -64,44 +128,56 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    tbl
    +
    +
    tbl +

    (VTableTree)
    rtables table object.

    -
    width_row_names
    +
    width_row_names +

    (grid::unit)
    width of row names.

    -
    width_columns
    +
    width_columns +

    (grid::unit)
    width of column spans.

    -
    width_forest
    +
    width_forest +

    (grid::unit)
    width of the forest plot.

    -
    gap_column
    +
    gap_column +

    (grid::unit)
    gap width between the columns.

    -
    gap_header
    +
    gap_header +

    (grid::unit)
    gap width between the header.

    -
    mat_form
    +
    mat_form +

    (MatrixPrintForm)
    matrix print form of the table.

    -
    + +
    -

    Value

    +

    Value +

    A viewport tree.

    -

    Examples

    +

    Examples +

    library(grid)
     
     tbl <- rtable(
    @@ -134,17 +210,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/format_auto.html b/main/reference/format_auto.html index 9778700a16..4e716f2906 100644 --- a/main/reference/format_auto.html +++ b/main/reference/format_auto.html @@ -1,15 +1,38 @@ - -Format automatically using data significant digits — format_auto • tern + +.formats = c("mean" = "auto"). See details to see how this works with the inner function.'> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,37 +129,46 @@
    -

    Usage

    +

    Usage +

    format_auto(dt_var, x_stat)
    -

    Arguments

    +

    Arguments +

    -
    dt_var
    +
    +
    dt_var +

    (numeric)
    variable data the statistics were calculated from. Used only to find significant digits. In analyze_vars this comes from .df_row (see rtables::additional_fun_params), and it is the row data after the above row splits. No column split is considered.

    -
    x_stat
    +
    x_stat +

    (string)
    string indicating the current statistical method used.

    -
    + +
    -

    Value

    +

    Value +

    A string that rtables prints in a table cell.

    -

    Details

    +

    Details +

    The internal function is needed to work with rtables default structure for format functions, i.e. function(x, ...), where is x are results from statistical evaluation. It can be more than one element (e.g. for .stats = "mean_sd").

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_count_fraction(), @@ -113,7 +185,8 @@

    See also
    -

    Examples

    +

    Examples +

    x_todo <- c(0.001, 0.2, 0.0011000, 3, 4)
     res <- c(mean(x_todo[1:3]), sd(x_todo[1:3]))
     
    @@ -129,17 +202,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_count_fraction.html b/main/reference/format_count_fraction.html index c66a8eb712..c35e220ec6 100644 --- a/main/reference/format_count_fraction.html +++ b/main/reference/format_count_fraction.html @@ -1,7 +1,30 @@ - -Format count and fraction — format_count_fraction • tern + + + + + + +Format count and fraction — format_count_fraction • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,28 +117,36 @@
    -

    Usage

    +

    Usage +

    format_count_fraction(x, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric(2))
    vector of length 2 with count and fraction, respectively.

    -
    ...
    +
    ... +

    not used. Required for rtables interface.

    -
    + +
    -

    Value

    +

    Value +

    A string in the format count (fraction %). If count is 0, the format is 0.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -92,7 +163,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_count_fraction(x = c(2, 0.6667))
     #> [1] "2 (66.7%)"
     format_count_fraction(x = c(0, 0))
    @@ -101,17 +173,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_count_fraction_fixed_dp.html b/main/reference/format_count_fraction_fixed_dp.html index fc371f5ba8..b48b133c07 100644 --- a/main/reference/format_count_fraction_fixed_dp.html +++ b/main/reference/format_count_fraction_fixed_dp.html @@ -1,7 +1,30 @@ - -Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp • tern + + + + + + +Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,28 +117,36 @@
    -

    Usage

    +

    Usage +

    format_count_fraction_fixed_dp(x, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric(2))
    vector of length 2 with count and fraction, respectively.

    -
    ...
    +
    ... +

    not used. Required for rtables interface.

    -
    + +
    -

    Value

    +

    Value +

    A string in the format count (fraction %). If count is 0, the format is 0.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -92,7 +163,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_count_fraction_fixed_dp(x = c(2, 0.6667))
     #> [1] "2 (66.7%)"
     format_count_fraction_fixed_dp(x = c(2, 0.5))
    @@ -103,17 +175,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_count_fraction_lt10.html b/main/reference/format_count_fraction_lt10.html index 3c372f565f..9d6d640a6e 100644 --- a/main/reference/format_count_fraction_lt10.html +++ b/main/reference/format_count_fraction_lt10.html @@ -1,7 +1,30 @@ - -Format count and fraction with special case for count < 10 — format_count_fraction_lt10 • tern + + + + + + +Format count and fraction with special case for count < 10 — format_count_fraction_lt10 • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,28 +117,36 @@
    -

    Usage

    +

    Usage +

    format_count_fraction_lt10(x, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric(2))
    vector of length 2 with count and fraction, respectively.

    -
    ...
    +
    ... +

    not used. Required for rtables interface.

    -
    + +
    -

    Value

    +

    Value +

    A string in the format count (fraction %). If count is less than 10, only count is printed.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -92,7 +163,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_count_fraction_lt10(x = c(275, 0.9673))
     #> [1] "275 (96.7%)"
     format_count_fraction_lt10(x = c(2, 0.6667))
    @@ -103,17 +175,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_extreme_values.html b/main/reference/format_extreme_values.html index eda5aa5ea5..e2aafd91a6 100644 --- a/main/reference/format_extreme_values.html +++ b/main/reference/format_extreme_values.html @@ -1,7 +1,30 @@ - -Format a single extreme value — format_extreme_values • tern + + + + + + +Format a single extreme value — format_extreme_values • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,24 +117,31 @@
    -

    Usage

    +

    Usage +

    format_extreme_values(digits = 2L)
    -

    Arguments

    +

    Arguments +

    -
    digits
    +
    +
    digits +

    (integer(1))
    number of decimal places to display.

    -
    + +
    -

    Value

    +

    Value +

    An rtables formatting function that uses threshold digits to return a formatted extreme value.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -88,7 +158,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_fun <- format_extreme_values(2L)
     format_fun(x = 0.127)
     #> [1] "0.13"
    @@ -102,17 +173,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_extreme_values_ci.html b/main/reference/format_extreme_values_ci.html index 5720252023..1c20399951 100644 --- a/main/reference/format_extreme_values_ci.html +++ b/main/reference/format_extreme_values_ci.html @@ -1,9 +1,32 @@ - -Format extreme values part of a confidence interval — format_extreme_values_ci • tern + +are formatted as e.g. "(xx.xx, xx.xx)" if the number of digits is 2.'> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,25 +120,32 @@
    -

    Usage

    +

    Usage +

    format_extreme_values_ci(digits = 2L)
    -

    Arguments

    +

    Arguments +

    -
    digits
    +
    +
    digits +

    (integer(1))
    number of decimal places to display.

    -
    + +
    -

    Value

    +

    Value +

    An rtables formatting function that uses threshold digits to return a formatted extreme values confidence interval.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -92,7 +162,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_fun <- format_extreme_values_ci(2L)
     format_fun(x = c(0.127, Inf))
     #> [1] "(0.13, >999.99)"
    @@ -102,17 +173,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_fraction.html b/main/reference/format_fraction.html index 02b11facc2..b82dcadeda 100644 --- a/main/reference/format_fraction.html +++ b/main/reference/format_fraction.html @@ -1,7 +1,30 @@ - -Format fraction and percentage — format_fraction • tern + + + + + + +Format fraction and percentage — format_fraction • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,28 +117,36 @@
    -

    Usage

    +

    Usage +

    format_fraction(x, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (named integer)
    vector with elements num and denom.

    -
    ...
    +
    ... +

    not used. Required for rtables interface.

    -
    + +
    -

    Value

    +

    Value +

    A string in the format num / denom (ratio %). If num is 0, the format is num / denom.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -92,7 +163,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_fraction(x = c(num = 2L, denom = 3L))
     #> [1] "2/3 (66.7%)"
     format_fraction(x = c(num = 0L, denom = 3L))
    @@ -101,17 +173,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_fraction_fixed_dp.html b/main/reference/format_fraction_fixed_dp.html index e1f8c4a678..13d67ccaa4 100644 --- a/main/reference/format_fraction_fixed_dp.html +++ b/main/reference/format_fraction_fixed_dp.html @@ -1,9 +1,32 @@ - -Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp • tern + + + + + +Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp • tern + + + + + + + + + + + + + +Includes trailing zero in case of whole number percentages to always keep one decimal place."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,28 +120,36 @@
    -

    Usage

    +

    Usage +

    format_fraction_fixed_dp(x, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (named integer)
    vector with elements num and denom.

    -
    ...
    +
    ... +

    not used. Required for rtables interface.

    -
    + +
    -

    Value

    +

    Value +

    A string in the format num / denom (ratio %). If num is 0, the format is num / denom.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -95,7 +166,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_fraction_fixed_dp(x = c(num = 1L, denom = 2L))
     #> [1] "1/2 (50.0%)"
     format_fraction_fixed_dp(x = c(num = 1L, denom = 4L))
    @@ -106,17 +178,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_fraction_threshold.html b/main/reference/format_fraction_threshold.html index e979fa5d3b..35d75ac6eb 100644 --- a/main/reference/format_fraction_threshold.html +++ b/main/reference/format_fraction_threshold.html @@ -1,9 +1,32 @@ - -Format fraction with lower threshold — format_fraction_threshold • tern + + + + + +Format fraction with lower threshold — format_fraction_threshold • tern + + + + + + + + + + + + + +a lower threshold, below which it is just stated that the fraction is smaller than that."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,27 +120,34 @@
    -

    Usage

    +

    Usage +

    format_fraction_threshold(threshold)
    -

    Arguments

    +

    Arguments +

    -
    threshold
    +
    +
    threshold +

    (proportion)
    lower threshold.

    -
    + +
    -

    Value

    +

    Value +

    An rtables formatting function that takes numeric input x where the second element is the fraction that is formatted. If the fraction is above or equal to the threshold, then it is displayed in percentage. If it is positive but below the threshold, it returns, e.g. "<1" if the threshold is 0.01. If it is zero, then just "0" is returned.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -94,7 +164,8 @@

    See also
    -

    Examples

    +

    Examples +

    format_fun <- format_fraction_threshold(0.05)
     format_fun(x = c(20, 0.1))
     #> [1] 10
    @@ -106,17 +177,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_sigfig.html b/main/reference/format_sigfig.html index 034ceb20ad..b7a6d90c70 100644 --- a/main/reference/format_sigfig.html +++ b/main/reference/format_sigfig.html @@ -1,5 +1,28 @@ - -Format numeric values by significant figures — format_sigfig • tern + + + + + + +Format numeric values by significant figures — format_sigfig • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,37 +114,46 @@
    -

    Usage

    +

    Usage +

    format_sigfig(sigfig, format = "xx", num_fmt = "fg")
    -

    Arguments

    +

    Arguments +

    -
    sigfig
    +
    +
    sigfig +

    (integer(1))
    number of significant figures to display.

    -
    format
    +
    format +

    (string)
    the format label (string) to apply when printing the value. Decimal places in string are ignored in favor of formatting by significant figures. Formats options are: "xx", "xx / xx", "(xx, xx)", "xx - xx", and "xx (xx)".

    -
    num_fmt
    +
    num_fmt +

    (string)
    numeric format modifiers to apply to the value. Defaults to "fg" for standard significant figures formatting - fixed (non-scientific notation) format ("f") and sigfig equal to number of significant figures instead of decimal places ("g"). See the formatC() format argument for more options.

    -
    + +
    -

    Value

    +

    Value +

    An rtables formatting function.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -98,7 +170,8 @@

    See also
    -

    Examples

    +

    Examples +

    fmt_3sf <- format_sigfig(3)
     fmt_3sf(1.658)
     #> [1] "1.66"
    @@ -114,17 +187,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/format_xx.html b/main/reference/format_xx.html index 2a89f25cf2..3d8d2d37e0 100644 --- a/main/reference/format_xx.html +++ b/main/reference/format_xx.html @@ -1,7 +1,30 @@ - -Format XX as a formatting function — format_xx • tern + + + + + + +Format XX as a formatting function — format_xx • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,24 +117,31 @@
    -

    Usage

    +

    Usage +

    format_xx(str)
    -

    Arguments

    +

    Arguments +

    -
    str
    +
    +
    str +

    (string)
    template.

    -
    + +
    -

    Value

    +

    Value +

    An rtables formatting function.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -88,7 +158,8 @@

    See also
    -

    Examples

    +

    Examples +

    test <- list(c(1.658, 0.5761), c(1e1, 785.6))
     
     z <- format_xx("xx (xx.x)")
    @@ -106,17 +177,19 @@ 

    Examples

    + +

    - + +
    - + + diff --git a/main/reference/formatting_functions.html b/main/reference/formatting_functions.html index 7a966046ea..78e749799b 100644 --- a/main/reference/formatting_functions.html +++ b/main/reference/formatting_functions.html @@ -1,5 +1,28 @@ - -Formatting functions — formatting_functions • tern + + + + + + +Formatting functions — formatting_functions • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -52,12 +115,14 @@
    -

    Details

    +

    Details +

    Other available formats can be listed via formatters::list_valid_format_labels(). Additional custom formats can be created via the formatters::sprintf_format() function.

    -

    See also

    +

    See also +

    Other formatting functions: extreme_format, format_auto(), @@ -74,17 +139,19 @@

    See also

    + +
    - + + - + + diff --git a/main/reference/g_bland_altman.html b/main/reference/g_bland_altman.html index c70412f52f..30f0436491 100644 --- a/main/reference/g_bland_altman.html +++ b/main/reference/g_bland_altman.html @@ -1,7 +1,30 @@ - -Bland-Altman plot — g_bland_altman • tern + + + + + + +Bland-Altman plot — g_bland_altman • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,33 +117,42 @@
    -

    Usage

    +

    Usage +

    g_bland_altman(x, y, conf_level = 0.95)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    y
    +
    y +

    (numeric)
    vector of numbers we want to analyze, to be compared with x.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot Bland-Altman plot.

    -

    Examples

    +

    Examples +

    x <- seq(1, 60, 5)
     y <- seq(5, 50, 4)
     
    @@ -90,17 +162,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/g_forest.html b/main/reference/g_forest.html index cbfb870dc0..9bd744fddc 100644 --- a/main/reference/g_forest.html +++ b/main/reference/g_forest.html @@ -1,5 +1,28 @@ - -Create a forest plot from an rtable — g_forest • tern + + + + + + +Create a forest plot from an rtable — g_forest • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,33 +38,74 @@ + +
    @@ -51,7 +115,8 @@
    -

    Usage

    +

    Usage +

    g_forest(
       tbl,
       col_x = attr(tbl, "col_x"),
    @@ -78,127 +143,154 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    tbl
    +
    +
    tbl +

    (VTableTree)
    rtables table with at least one column with a single value and one column with 2 values.

    -
    col_x
    +
    col_x +

    (integer(1) or NULL)
    column index with estimator. By default tries to get this from tbl attribute col_x, otherwise needs to be manually specified. If NULL, points will be excluded from forest plot.

    -
    col_ci
    +
    col_ci +

    (integer(1) or NULL)
    column index with confidence intervals. By default tries to get this from tbl attribute col_ci, otherwise needs to be manually specified. If NULL, lines will be excluded from forest plot.

    -
    vline
    +
    vline +

    (numeric(1) or NULL)
    x coordinate for vertical line, if NULL then the line is omitted.

    -
    forest_header
    +
    forest_header +

    (character(2))
    text displayed to the left and right of vline, respectively. If vline = NULL then forest_header is not printed. By default tries to get this from tbl attribute forest_header. If NULL, defaults will be extracted from the table if possible, and set to "Comparison\nBetter" and "Treatment\nBetter" if not.

    -
    xlim
    +
    xlim +

    (numeric(2))
    limits for x axis.

    -
    logx
    +
    logx +

    (flag)
    show the x-values on logarithm scale.

    -
    x_at
    +
    x_at +

    (numeric)
    x-tick locations, if NULL, x_at is set to vline and both xlim values.

    -
    width_row_names
    +
    width_row_names +

    [Deprecated] Please use the lbl_col_padding argument instead.

    -
    width_columns
    +
    width_columns +

    (numeric)
    a vector of column widths. Each element's position in colwidths corresponds to the column of tbl in the same position. If NULL, column widths are calculated according to maximum number of characters per column.

    -
    width_forest
    +
    width_forest +

    [Deprecated] Please use the rel_width_forest argument instead.

    -
    lbl_col_padding
    +
    lbl_col_padding +

    (numeric)
    additional padding to use when calculating spacing between the first (label) column and the second column of tbl. If colwidths is specified, the width of the first column becomes colwidths[1] + lbl_col_padding. Defaults to 0.

    -
    rel_width_forest
    +
    rel_width_forest +

    (proportion)
    proportion of total width to allocate to the forest plot. Relative width of table is then 1 - rel_width_forest. If as_list = TRUE, this parameter is ignored.

    -
    font_size
    +
    font_size +

    (numeric(1))
    font size.

    -
    col_symbol_size
    +
    col_symbol_size +

    (numeric or NULL)
    column index from tbl containing data to be used to determine relative size for estimator plot symbol. Typically, the symbol size is proportional to the sample size used to calculate the estimator. If NULL, the same symbol size is used for all subgroups. By default tries to get this from tbl attribute col_symbol_size, otherwise needs to be manually specified.

    -
    col
    +
    col +

    (character)
    color(s).

    -
    ggtheme
    +
    ggtheme +

    (theme)
    a graphical theme as provided by ggplot2 to control styling of the plot.

    -
    as_list
    +
    as_list +

    (flag)
    whether the two ggplot objects should be returned as a list. If TRUE, a named list with two elements, table and plot, will be returned. If FALSE (default) the table and forest plot are printed side-by-side via cowplot::plot_grid().

    -
    gp
    +
    gp +

    [Deprecated] g_forest is now generated as a ggplot object. This argument is no longer used.

    -
    draw
    +
    draw +

    [Deprecated] g_forest is now generated as a ggplot object. This argument is no longer used.

    -
    newpage
    +
    newpage +

    [Deprecated] g_forest is now generated as a ggplot object. This argument is no longer used.

    -
    + +
    -

    Value

    +

    Value +

    ggplot forest plot and table.

    -

    Details

    +

    Details +

    Given a rtables::rtable() object with at least one column with a single value and one column with 2 values, converts table to a ggplot2::ggplot() object and generates an accompanying forest plot. The table and forest plot are printed side-by-side.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(forcats)
     
    @@ -312,17 +404,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/g_ipp.html b/main/reference/g_ipp.html index 58f4f21b1a..9aee3630aa 100644 --- a/main/reference/g_ipp.html +++ b/main/reference/g_ipp.html @@ -1,9 +1,32 @@ - -Individual patient plots — g_ipp • tern + + + + + +Individual patient plots — g_ipp • tern + + + + + + + + + + + + + +Patients' individual baseline values can be added to the plot(s) as reference."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    g_ipp(
       df,
       xvar,
    @@ -78,92 +142,116 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    xvar
    +
    xvar +

    (string)
    time point variable to be plotted on x-axis.

    -
    yvar
    +
    yvar +

    (string)
    continuous analysis variable to be plotted on y-axis.

    -
    xlab
    +
    xlab +

    (string)
    plot label for x-axis.

    -
    ylab
    +
    ylab +

    (string)
    plot label for y-axis.

    -
    id_var
    +
    id_var +

    (string)
    variable used as patient identifier.

    -
    title
    +
    title +

    (string)
    title for plot.

    -
    subtitle
    +
    subtitle +

    (string)
    subtitle for plot.

    -
    caption
    +
    caption +

    (string)
    optional caption below the plot.

    -
    add_baseline_hline
    +
    add_baseline_hline +

    (flag)
    adds horizontal line at baseline y-value on plot when TRUE.

    -
    yvar_baseline
    +
    yvar_baseline +

    (string)
    variable with baseline values only. Ignored when add_baseline_hline is FALSE.

    -
    ggtheme
    +
    ggtheme +

    (theme)
    optional graphical theme function as provided by ggplot2 to control outlook of plot. Use ggplot2::theme() to tweak the display.

    -
    plotting_choices
    +
    plotting_choices +

    (string)
    specifies options for displaying plots. Must be one of "all_in_one", "split_by_max_obs", or "separate_by_obs".

    -
    max_obs_per_plot
    +
    max_obs_per_plot +

    (integer(1))
    number of observations to be plotted on one plot. Ignored if plotting_choices is not "separate_by_obs".

    -
    col
    +
    col +

    (character)
    line colors.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot object or a list of ggplot objects.

    -

    Functions

    +

    Functions +

    -
    • g_ipp(): Plotting function for individual patient plots which, depending on user +

        +
      • g_ipp(): Plotting function for individual patient plots which, depending on user preference, renders a single graphic or compiles a list of graphics that show trends in individual's parameter values over time.

      • -
    + +
    -

    See also

    +

    See also +

    Relevant helper function h_g_ipp().

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # Select a small sample of data to plot.
    @@ -193,17 +281,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/g_km.html b/main/reference/g_km.html index 583250e04a..76bf86b174 100644 --- a/main/reference/g_km.html +++ b/main/reference/g_km.html @@ -1,11 +1,34 @@ - -Kaplan-Meier plot — g_km • tern + + + + + +Kaplan-Meier plot — g_km • tern + + + + + + + + + + + + + +per group."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,7 +123,8 @@
    -

    Usage

    +

    Usage +

    g_km(
       df,
       variables,
    @@ -108,226 +172,285 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    variables
    -

    (named list)
    variable names. Details are:

    • tte (numeric)
      variable indicating time-to-event duration values.

    • +
      variables +
      +
      +

      (named list)
      variable names. Details are:

      +
        +
      • tte (numeric)
        variable indicating time-to-event duration values.

      • is_event (logical)
        event variable. TRUE if event, FALSE if time to event is censored.

      • arm (factor)
        the treatment group variable.

      • strata (character or NULL)
        variable names indicating stratification factors.

      • -
      +
    +
    -
    control_surv
    -

    (list)
    parameters for comparison details, specified by using -the helper function control_surv_timepoint(). Some possible parameter options are:

    • conf_level (proportion)
      confidence level of the interval for survival rate.

    • +
      control_surv +
      +
      +

      (list)
      parameters for comparison details, specified by using +the helper function control_surv_timepoint(). Some possible parameter options are:

      +
        +
      • conf_level (proportion)
        confidence level of the interval for survival rate.

      • conf_type (string)
        "plain" (default), "log", "log-log" for confidence interval type, see more in survival::survfit(). Note that the option "none" is no longer supported.

      • -
      +
    +
    -
    col
    +
    col +

    (character)
    lines colors. Length of a vector should be equal to number of strata from survival::survfit().

    -
    lty
    +
    lty +

    (numeric)
    line type. If a vector is given, its length should be equal to the number of strata from survival::survfit().

    -
    lwd
    +
    lwd +

    (numeric)
    line width. If a vector is given, its length should be equal to the number of strata from survival::survfit().

    -
    censor_show
    +
    censor_show +

    (flag)
    whether to show censored observations.

    -
    pch
    +
    pch +

    (string)
    name of symbol or character to use as point symbol to indicate censored cases.

    -
    size
    +
    size +

    (numeric(1))
    size of censored point symbols.

    -
    max_time
    +
    max_time +

    (numeric(1))
    maximum value to show on x-axis. Only data values less than or up to this threshold value will be plotted (defaults to NULL).

    -
    xticks
    +
    xticks +

    (numeric or NULL)
    numeric vector of tick positions or a single number with spacing between ticks on the x-axis. If NULL (default), labeling::extended() is used to determine optimal tick positions on the x-axis.

    -
    xlab
    +
    xlab +

    (string)
    x-axis label.

    -
    yval
    +
    yval +

    (string)
    type of plot, to be plotted on the y-axis. Options are Survival (default) and Failure probability.

    -
    ylab
    +
    ylab +

    (string)
    y-axis label.

    -
    ylim
    +
    ylim +

    (numeric(2))
    vector containing lower and upper limits for the y-axis, respectively. If NULL (default), the default scale range is used.

    -
    title
    +
    title +

    (string)
    plot title.

    -
    footnotes
    +
    footnotes +

    (string)
    plot footnotes.

    -
    font_size
    +
    font_size +

    (numeric(1))
    font size to use for all text.

    -
    ci_ribbon
    +
    ci_ribbon +

    (flag)
    whether the confidence interval should be drawn around the Kaplan-Meier curve.

    -
    annot_at_risk
    +
    annot_at_risk +

    (flag)
    compute and add the annotation table reporting the number of patient at risk matching the main grid of the Kaplan-Meier curve.

    -
    annot_at_risk_title
    +
    annot_at_risk_title +

    (flag)
    whether the "Patients at Risk" title should be added above the annot_at_risk table. Has no effect if annot_at_risk is FALSE. Defaults to TRUE.

    -
    annot_surv_med
    +
    annot_surv_med +

    (flag)
    compute and add the annotation table on the Kaplan-Meier curve estimating the median survival time per group.

    -
    annot_coxph
    +
    annot_coxph +

    (flag)
    whether to add the annotation table from a survival::coxph() model.

    -
    annot_stats
    +
    annot_stats +

    (string or NULL)
    statistics annotations to add to the plot. Options are median (median survival follow-up time) and min (minimum survival follow-up time).

    -
    annot_stats_vlines
    +
    annot_stats_vlines +

    (flag)
    add vertical lines corresponding to each of the statistics specified by annot_stats. If annot_stats is NULL no lines will be added.

    -
    control_coxph_pw
    -

    (list)
    parameters for comparison details, specified using the helper function -control_coxph(). Some possible parameter options are:

    • pval_method (string)
      p-value method for testing hazard ratio = 1. +

      control_coxph_pw +
      +
      +

      (list)
      parameters for comparison details, specified using the helper function +control_coxph(). Some possible parameter options are:

      +
        +
      • pval_method (string)
        p-value method for testing hazard ratio = 1. Default method is "log-rank", can also be set to "wald" or "likelihood".

      • ties (string)
        method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in survival::coxph()

      • conf_level (proportion)
        confidence level of the interval for HR.

      • -
      +
    +
    -
    ref_group_coxph
    +
    ref_group_coxph +

    (string or NULL)
    level of arm variable to use as reference group in calculations for annot_coxph table. If NULL (default), uses the first level of the arm variable.

    -
    control_annot_surv_med
    +
    control_annot_surv_med +

    (list)
    parameters to control the position and size of the annotation table added to the plot when annot_surv_med = TRUE, specified using the control_surv_med_annot() function. Parameter options are: x, y, w, h, and fill. See control_surv_med_annot() for details.

    -
    control_annot_coxph
    +
    control_annot_coxph +

    (list)
    parameters to control the position and size of the annotation table added to the plot when annot_coxph = TRUE, specified using the control_coxph_annot() function. Parameter options are: x, y, w, h, fill, and ref_lbls. See control_coxph_annot() for details.

    -
    legend_pos
    +
    legend_pos +

    (numeric(2) or NULL)
    vector containing x- and y-coordinates, respectively, for the legend position relative to the KM plot area. If NULL (default), the legend is positioned in the bottom right corner of the plot, or the middle right of the plot if needed to prevent overlapping.

    -
    rel_height_plot
    +
    rel_height_plot +

    (proportion)
    proportion of total figure height to allocate to the Kaplan-Meier plot. Relative height of patients at risk table is then 1 - rel_height_plot. If annot_at_risk = FALSE or as_list = TRUE, this parameter is ignored.

    -
    ggtheme
    +
    ggtheme +

    (theme)
    a graphical theme as provided by ggplot2 to format the Kaplan-Meier plot.

    -
    as_list
    +
    as_list +

    (flag)
    whether the two ggplot objects should be returned as a list when annot_at_risk = TRUE. If TRUE, a named list with two elements, plot and table, will be returned. If FALSE (default) the patients at risk table is printed below the plot via cowplot::plot_grid().

    -
    draw
    +
    draw +

    [Deprecated] This function no longer generates grob objects.

    -
    newpage
    +
    newpage +

    [Deprecated] This function no longer generates grob objects.

    -
    gp
    +
    gp +

    [Deprecated] This function no longer generates grob objects.

    -
    vp
    +
    vp +

    [Deprecated] This function no longer generates grob objects.

    -
    name
    +
    name +

    [Deprecated] This function no longer generates grob objects.

    -
    annot_coxph_ref_lbls
    +
    annot_coxph_ref_lbls +

    [Deprecated] Please use the ref_lbls element of control_annot_coxph instead.

    -
    position_coxph
    +
    position_coxph +

    [Deprecated] Please use the x and y elements of control_annot_coxph instead.

    -
    position_surv_med
    +
    position_surv_med +

    [Deprecated] Please use the x and y elements of control_annot_surv_med instead.

    -
    width_annots
    +
    width_annots +

    [Deprecated] Please use the w element of control_annot_surv_med (for surv_med) and control_annot_coxph (for coxph)."

    -
    + +
    -

    Value

    +

    Value +

    A ggplot Kaplan-Meier plot and (optionally) summary table.

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     df <- tern_ex_adtte %>%
    @@ -375,17 +498,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/g_lineplot.html b/main/reference/g_lineplot.html index 95f4fc816b..da0831c309 100644 --- a/main/reference/g_lineplot.html +++ b/main/reference/g_lineplot.html @@ -1,7 +1,30 @@ - -Line plot with optional table — g_lineplot • tern + + + + + + +Line plot with optional table — g_lineplot • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    g_lineplot(
       df,
       alt_counts_df = NULL,
    @@ -96,20 +160,28 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    alt_counts_df
    +
    alt_counts_df +

    (data.frame or NULL)
    data set that will be used (only) to counts objects in groups for stratification.

    -
    variables
    -

    (named character) vector of variable names in df which should include:

    • x (string)
      name of x-axis variable.

    • +
      variables +
      +
      +

      (named character) vector of variable names in df which should include:

      +
        +
      • x (string)
        name of x-axis variable.

      • y (string)
        name of y-axis variable.

      • group_var (string or NULL)
        name of grouping variable (or strata), i.e. treatment arm. Can be NA to indicate lack of groups.

      • @@ -121,176 +193,213 @@

        Argumentsmid +
        mid +

        (character or NULL)
        names of the statistics that will be plotted as midpoints. All the statistics indicated in mid variable must be present in the object returned by sfun, and be of a double or numeric type vector of length one.

        -
        interval
        +
        interval +

        (character or NULL)
        names of the statistics that will be plotted as intervals. All the statistics indicated in interval variable must be present in the object returned by sfun, and be of a double or numeric type vector of length two. Set interval = NULL if intervals should not be added to the plot.

        -
        whiskers
        +
        whiskers +

        (character)
        names of the interval whiskers that will be plotted. Names must match names of the list element interval that will be returned by sfun (e.g. mean_ci_lwr element of sfun(x)[["mean_ci"]]). It is possible to specify one whisker only, or to suppress all whiskers by setting interval = NULL.

        -
        table
        +
        table +

        (character or NULL)
        names of the statistics that will be displayed in the table below the plot. All the statistics indicated in table variable must be present in the object returned by sfun.

        -
        sfun
        +
        sfun +

        (function)
        the function to compute the values of required statistics. It must return a named list with atomic vectors. The names of the list elements refer to the names of the statistics and are used by mid, interval, table. It must be able to accept as input a vector with data for which statistics are computed.

        -
        ...
        +
        ... +

        optional arguments to sfun.

        -
        mid_type
        +
        mid_type +

        (string)
        controls the type of the mid plot, it can be point ("p"), line ("l"), or point and line ("pl").

        -
        mid_point_size
        +
        mid_point_size +

        (numeric(1))
        font size of the mid plot points.

        -
        position
        +
        position +

        (character or call)
        geom element position adjustment, either as a string, or the result of a call to a position adjustment function.

        -
        legend_title
        +
        legend_title +

        (string)
        legend title.

        -
        legend_position
        +
        legend_position +

        (string)
        the position of the plot legend ("none", "left", "right", "bottom", "top", or a two-element numeric vector).

        -
        ggtheme
        +
        ggtheme +

        (theme)
        a graphical theme as provided by ggplot2 to control styling of the plot.

        -
        xticks
        +
        xticks +

        (numeric or NULL)
        numeric vector of tick positions or a single number with spacing between ticks on the x-axis, for use when variables$x is numeric. If NULL (default), labeling::extended() is used to determine optimal tick positions on the x-axis. If variables$x is not numeric, this argument is ignored.

        -
        xlim
        +
        xlim +

        (numeric(2))
        vector containing lower and upper limits for the x-axis, respectively. If NULL (default), the default scale range is used.

        -
        ylim
        +
        ylim +

        (numeric(2))
        vector containing lower and upper limits for the y-axis, respectively. If NULL (default), the default scale range is used.

        -
        x_lab
        +
        x_lab +

        (string or NULL)
        x-axis label. If NULL then no label will be added.

        -
        y_lab
        +
        y_lab +

        (string or NULL)
        y-axis label. If NULL then no label will be added.

        -
        y_lab_add_paramcd
        +
        y_lab_add_paramcd +

        (flag)
        whether paramcd, i.e. unique(df[[variables["paramcd"]]]) should be added to the y-axis label (y_lab).

        -
        y_lab_add_unit
        +
        y_lab_add_unit +

        (flag)
        whether y-axis unit, i.e. unique(df[[variables["y_unit"]]]) should be added to the y-axis label (y_lab).

        -
        title
        +
        title +

        (string)
        plot title.

        -
        subtitle
        +
        subtitle +

        (string)
        plot subtitle.

        -
        subtitle_add_paramcd
        +
        subtitle_add_paramcd +

        (flag)
        whether paramcd, i.e. unique(df[[variables["paramcd"]]]) should be added to the plot's subtitle (subtitle).

        -
        subtitle_add_unit
        +
        subtitle_add_unit +

        (flag)
        whether the y-axis unit, i.e. unique(df[[variables["y_unit"]]]) should be added to the plot's subtitle (subtitle).

        -
        caption
        +
        caption +

        (string)
        optional caption below the plot.

        -
        table_format
        +
        table_format +

        (named character or NULL)
        format patterns for descriptive statistics used in the (optional) table appended to the plot. It is passed directly to the h_format_row function through the format parameter. Names of table_format must match the names of statistics returned by sfun function.

        -
        table_labels
        +
        table_labels +

        (named character or NULL)
        labels for descriptive statistics used in the (optional) table appended to the plot. Names of table_labels must match the names of statistics returned by sfun function.

        -
        table_font_size
        +
        table_font_size +

        (numeric(1))
        font size of the text in the table.

        -
        errorbar_width
        +
        errorbar_width +

        (numeric(1))
        width of the error bars.

        -
        newpage
        +
        newpage +

        [Deprecated] not used.

        -
        col
        +
        col +

        (character)
        color(s). See ?ggplot2::aes_colour_fill_alpha for example values.

        -
        linetype
        +
        linetype +

        (character)
        line type(s). See ?ggplot2::aes_linetype_size_shape for example values.

        -
        rel_height_plot
        +
        rel_height_plot +

        (proportion)
        proportion of total figure height to allocate to the line plot. Relative height of annotation table is then 1 - rel_height_plot. If table = NULL, this parameter is ignored.

        -
        as_list
        +
        as_list +

        (flag)
        whether the two ggplot objects should be returned as a list when table is not NULL. If TRUE, a named list with two elements, plot and table, will be returned. If FALSE (default) the annotation table is printed below the plot via cowplot::plot_grid().

        -

    + +
    -

    Value

    +

    Value +

    A ggplot line plot (and statistics table if applicable).

    -

    Examples

    +

    Examples +

    
     adsl <- tern_ex_adsl
     adlb <- tern_ex_adlb %>% dplyr::filter(ANL01FL == "Y", PARAMCD == "ALT", AVISIT != "SCREENING")
    @@ -354,17 +463,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/g_step.html b/main/reference/g_step.html index 2c5f43b28c..298dbb7522 100644 --- a/main/reference/g_step.html +++ b/main/reference/g_step.html @@ -1,9 +1,32 @@ - -Create a STEP graph — g_step • tern + + + + + +Create a STEP graph — g_step • tern + + + + + + + + + + + + + +along the continuous biomarker value subgroups."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    g_step(
       df,
       use_percentile = "Percentile Center" %in% names(df),
    @@ -68,42 +132,53 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (tibble)
    result of tidy.step().

    -
    use_percentile
    +
    use_percentile +

    (flag)
    whether to use percentiles for the x axis or actual biomarker values.

    -
    est
    +
    est +

    (named list)
    col and lty settings for estimate line.

    -
    ci_ribbon
    +
    ci_ribbon +

    (named list or NULL)
    fill and alpha settings for the confidence interval ribbon area, or NULL to not plot a CI ribbon.

    -
    col
    +
    col +

    (character)
    color(s).

    -
    + +
    -

    Value

    +

    Value +

    A ggplot STEP graph.

    -

    See also

    +

    See also +

    Custom tidy method tidy.step().

    -

    Examples

    +

    Examples +

    library(survival)
     lung$sex <- factor(lung$sex)
     
    @@ -170,17 +245,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/g_waterfall.html b/main/reference/g_waterfall.html index 98bddc4966..58fff54bee 100644 --- a/main/reference/g_waterfall.html +++ b/main/reference/g_waterfall.html @@ -1,7 +1,30 @@ - -Horizontal waterfall plot — g_waterfall • tern + + + + + + +Horizontal waterfall plot — g_waterfall • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    g_waterfall(
       height,
       id,
    @@ -68,48 +132,61 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    height
    +
    +
    height +

    (numeric)
    vector containing values to be plotted as the waterfall bars.

    -
    id
    +
    id +

    (character)
    vector containing identifiers to use as the x-axis label for the waterfall bars.

    -
    col_var
    +
    col_var +

    (factor, character, or NULL)
    categorical variable for bar coloring. NULL by default.

    -
    col
    +
    col +

    (character)
    color(s).

    -
    xlab
    +
    xlab +

    (string)
    x label. Default is "ID".

    -
    ylab
    +
    ylab +

    (string)
    y label. Default is "Value".

    -
    col_legend_title
    +
    col_legend_title +

    (string)
    text to be displayed as legend title.

    -
    title
    +
    title +

    (string)
    text to be displayed as plot title.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot waterfall plot.

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     g_waterfall(height = c(3, 5, -1), id = letters[1:3])
    @@ -172,17 +249,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/get_covariates.html b/main/reference/get_covariates.html index 05b0915c93..1b77f4e192 100644 --- a/main/reference/get_covariates.html +++ b/main/reference/get_covariates.html @@ -1,5 +1,28 @@ - -Utility function to return a named list of covariate names — get_covariates • tern + + + + + + +Utility function to return a named list of covariate names — get_covariates • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,36 +114,44 @@
    -

    Usage

    +

    Usage +

    get_covariates(covariates)
    -

    Arguments

    +

    Arguments +

    -
    covariates
    +
    +
    covariates +

    (character)
    a vector that can contain single variable names (such as "X1"), and/or interaction terms indicated by "X1 * X2".

    -
    + +
    -

    Value

    +

    Value +

    A named list of character vector.

    + + - + + - + + diff --git a/main/reference/get_smooths.html b/main/reference/get_smooths.html index 3a07aa791b..dcbee53f48 100644 --- a/main/reference/get_smooths.html +++ b/main/reference/get_smooths.html @@ -1,7 +1,30 @@ - -Smooth function with optional grouping — get_smooths • tern + + + + + + +Smooth function with optional grouping — get_smooths • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,52 +117,64 @@
    -

    Usage

    +

    Usage +

    get_smooths(df, x, y, groups = NULL, level = 0.95)
    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    x
    +
    x +

    (string)
    x column name.

    -
    y
    +
    y +

    (string)
    y column name.

    -
    groups
    +
    groups +

    (character or NULL)
    vector with optional grouping variables names.

    -
    level
    +
    level +

    (proportion)
    level of confidence interval to use (0.95 by default).

    -
    + +
    -

    Value

    +

    Value +

    A data.frame with original x, smoothed y, ylow, and yhigh, and optional groups variables formatted as factor type.

    + + - + + - + + diff --git a/main/reference/groups_list_to_df.html b/main/reference/groups_list_to_df.html index 7955c46b45..ead875f7d1 100644 --- a/main/reference/groups_list_to_df.html +++ b/main/reference/groups_list_to_df.html @@ -1,5 +1,28 @@ - -Convert list of groups to a data frame — groups_list_to_df • tern + + + + + + +Convert list of groups to a data frame — groups_list_to_df • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,26 +114,33 @@
    -

    Usage

    +

    Usage +

    groups_list_to_df(groups_list)
    -

    Arguments

    +

    Arguments +

    -
    groups_list
    +
    +
    groups_list +

    (named list of character)
    specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    + +
    -

    Value

    +

    Value +

    A tibble in the required format.

    -

    Examples

    +

    Examples +

    grade_groups <- list(
       "Any Grade (%)" = c("1", "2", "3", "4", "5"),
       "Grade 3-4 (%)" = c("3", "4"),
    @@ -87,17 +157,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_adlb_abnormal_by_worst_grade.html b/main/reference/h_adlb_abnormal_by_worst_grade.html index 01f55e8b73..96ba0c1b11 100644 --- a/main/reference/h_adlb_abnormal_by_worst_grade.html +++ b/main/reference/h_adlb_abnormal_by_worst_grade.html @@ -1,5 +1,22 @@ - -Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade • tern + +'> + + + + + Skip to contents @@ -51,33 +74,74 @@ + +
    @@ -85,20 +149,28 @@

    [Stable]

    Helper function to prepare an ADLB data frame to be used as input in -count_abnormal_by_worst_grade(). The following pre-processing steps are applied:

    1. adlb is filtered on variable avisit to only include post-baseline visits.

    2. +count_abnormal_by_worst_grade(). The following pre-processing steps are applied:

      +
        +
      1. adlb is filtered on variable avisit to only include post-baseline visits.

      2. adlb is filtered on variables worst_flag_low and worst_flag_high so that only worst grades (in either direction) are included.

      3. From the standard lab grade variable atoxgr, the following two variables are derived and added to adlb:

      4. -
      • A grade direction variable (e.g. GRADE_DIR). The variable takes value "HIGH" when +

    +
      +
    • A grade direction variable (e.g. GRADE_DIR). The variable takes value "HIGH" when atoxgr > 0, "LOW" when atoxgr < 0, and "ZERO" otherwise.

    • A toxicity grade variable (e.g. GRADE_ANL) where all negative values from atoxgr are replaced by their absolute values.

    • -
    1. Unused factor levels are dropped from adlb via droplevels().

    2. -
    + +
      +
    1. Unused factor levels are dropped from adlb via droplevels().

    2. +
    +
    -

    Usage

    +

    Usage +

    h_adlb_abnormal_by_worst_grade(
       adlb,
       atoxgr = "ATOXGR",
    @@ -109,44 +181,55 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    adlb
    +
    +
    adlb +

    (data.frame)
    ADLB data frame.

    -
    atoxgr
    +
    atoxgr +

    (string)
    name of the analysis toxicity grade variable. This must be a factor variable.

    -
    avisit
    +
    avisit +

    (string)
    name of the analysis visit variable.

    -
    worst_flag_low
    +
    worst_flag_low +

    (string)
    name of the worst low lab grade flag variable. This variable is set to "Y" when indicating records of worst low lab grades.

    -
    worst_flag_high
    +
    worst_flag_high +

    (string)
    name of the worst high lab grade flag variable. This variable is set to "Y" when indicating records of worst high lab grades.

    -
    + +
    -

    Value

    +

    Value +

    h_adlb_abnormal_by_worst_grade() returns the adlb data frame with two new variables: GRADE_DIR and GRADE_ANL.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    h_adlb_abnormal_by_worst_grade(tern_ex_adlb) %>%
       dplyr::select(ATOXGR, GRADE_DIR, GRADE_ANL) %>%
       head(10)
    @@ -167,17 +250,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_adlb_worsen.html b/main/reference/h_adlb_worsen.html index ac2db0f59d..04bc6dc7d8 100644 --- a/main/reference/h_adlb_worsen.html +++ b/main/reference/h_adlb_worsen.html @@ -1,7 +1,30 @@ - -Helper function to prepare ADLB with worst labs — h_adlb_worsen • tern + + + + + + +Helper function to prepare ADLB with worst labs — h_adlb_worsen • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_adlb_worsen(
       adlb,
       worst_flag_low = NULL,
    @@ -64,33 +128,45 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    adlb
    +
    +
    adlb +

    (data.frame)
    ADLB data frame.

    -
    worst_flag_low
    +
    worst_flag_low +

    (named vector)
    worst low post-baseline lab grade flag variable. See how this is implemented in the following examples.

    -
    worst_flag_high
    +
    worst_flag_high +

    (named vector)
    worst high post-baseline lab grade flag variable. See how this is implemented in the following examples.

    -
    direction_var
    -

    (string)
    name of the direction variable specifying the direction of the shift table of -interest. Only lab records flagged by L, H or B are included in the shift table.

    • L: low direction only

    • +
      direction_var +
      +
      +

      (string)
      name of the direction variable specifying the direction of the shift table of +interest. Only lab records flagged by L, H or B are included in the shift table.

      +
        +
      • L: low direction only

      • H: high direction only

      • B: both low and high directions

      • -
      +
    +
    -
    + +
    -

    Value

    +

    Value +

    h_adlb_worsen() returns the adlb data.frame containing only the worst labs specified according to worst_flag_low or worst_flag_high for the direction specified according to direction_var. For instance, for a lab that is @@ -100,12 +176,14 @@

    Value

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # The direction variable, GRADDR, is based on metadata
    @@ -129,17 +207,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_adsl_adlb_merge_using_worst_flag.html b/main/reference/h_adsl_adlb_merge_using_worst_flag.html index ce36439f63..f7e309320f 100644 --- a/main/reference/h_adsl_adlb_merge_using_worst_flag.html +++ b/main/reference/h_adsl_adlb_merge_using_worst_flag.html @@ -1,11 +1,34 @@ - -Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag • tern + + + + + +Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag • tern + + + + + + + + + + + + + +done with df_explicit_na() to have the desired output."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,7 +123,8 @@
    -

    Usage

    +

    Usage +

    h_adsl_adlb_merge_using_worst_flag(
       adsl,
       adlb,
    @@ -71,48 +135,62 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    adsl
    +
    +
    adsl +

    (data.frame)
    ADSL data frame.

    -
    adlb
    +
    adlb +

    (data.frame)
    ADLB data frame.

    -
    worst_flag
    +
    worst_flag +

    (named character)
    worst post-baseline lab flag variable. See how this is implemented in the following examples.

    -
    by_visit
    +
    by_visit +

    (flag)
    defaults to FALSE to generate worst grade per patient. If worst grade per patient per visit is specified for worst_flag, then by_visit should be TRUE to generate worst grade patient per visit.

    -
    no_fillin_visits
    +
    no_fillin_visits +

    (named character)
    visits that are not considered for post-baseline worst toxicity grade. Defaults to c("SCREENING", "BASELINE").

    -
    + +
    -

    Value

    +

    Value +

    df containing variables shared between adlb and adsl along with variables PARAM, PARAMCD, ATOXGR, and BTOXGR relevant for analysis. Optionally, AVISIT are AVISITN are included when by_visit = TRUE and no_fillin_visits = c("SCREENING", "BASELINE").

    -

    Details

    -

    In the result data missing records will be created for the following situations:

    • Patients who are present in adsl but have no lab data in adlb (both baseline and post-baseline).

    • +

      Details +

      +

      In the result data missing records will be created for the following situations:

      +
        +
      • Patients who are present in adsl but have no lab data in adlb (both baseline and post-baseline).

      • Patients who do not have any post-baseline lab values.

      • Patients without any post-baseline values flagged as the worst.

      • -
    + +
    -

    Examples

    +

    Examples +

    # `h_adsl_adlb_merge_using_worst_flag`
     adlb_out <- h_adsl_adlb_merge_using_worst_flag(
       tern_ex_adsl,
    @@ -131,17 +209,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_ancova.html b/main/reference/h_ancova.html index 867b83e6c6..e7c0d24751 100644 --- a/main/reference/h_ancova.html +++ b/main/reference/h_ancova.html @@ -1,5 +1,28 @@ - -Helper function to return results of a linear model — h_ancova • tern + + + + + + +Helper function to return results of a linear model — h_ancova • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,43 +114,57 @@
    -

    Usage

    +

    Usage +

    h_ancova(.var, .df_row, variables, interaction_item = NULL)
    -

    Arguments

    +

    Arguments +

    -
    .var
    +
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data set that includes all the variables that are called in .var and variables.

    -
    variables
    -

    (named list of string)
    list of additional analysis variables, with expected elements:

    • arm (string)
      group variable, for which the covariate adjusted means of multiple groups will be +

      variables +
      +
      +

      (named list of string)
      list of additional analysis variables, with expected elements:

      +
        +
      • arm (string)
        group variable, for which the covariate adjusted means of multiple groups will be summarized. Specifically, the first level of arm variable is taken as the reference group.

      • covariates (character)
        a vector that can contain single variable names (such as "X1"), and/or interaction terms indicated by "X1 * X2".

      • -
      +
    +
    -
    interaction_item
    +
    interaction_item +

    (string or NULL)
    name of the variable that should have interactions with arm. if the interaction is not needed, the default option is NULL.

    -
    + +
    -

    Value

    +

    Value +

    The summary of a linear model.

    -

    Examples

    +

    Examples +

    h_ancova(
       .var = "Sepal.Length",
       .df_row = iris,
    @@ -103,17 +180,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_append_grade_groups.html b/main/reference/h_append_grade_groups.html index a35b19e90b..5f6841369f 100644 --- a/main/reference/h_append_grade_groups.html +++ b/main/reference/h_append_grade_groups.html @@ -1,13 +1,36 @@ - -Helper function for s_count_occurrences_by_grade() — h_append_grade_groups • tern + + + + + +Helper function for s_count_occurrences_by_grade() — h_append_grade_groups • tern + + + + + + + + + + + + + +the end. Grade groups names must be unique."> + + + + + Skip to contents @@ -23,33 +46,74 @@ + +
    @@ -63,7 +127,8 @@
    -

    Usage

    +

    Usage +

    h_append_grade_groups(
       grade_groups,
       refs,
    @@ -73,37 +138,46 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    grade_groups
    +
    +
    grade_groups +

    (named list of character)
    list containing groupings of grades.

    -
    refs
    +
    refs +

    (named list of numeric)
    named list where each name corresponds to a reference grade level and each entry represents a count.

    -
    remove_single
    +
    remove_single +

    (flag)
    TRUE to not include the elements of one-element grade groups in the the output list; in this case only the grade groups names will be included in the output. If only_grade_groups is set to TRUE this argument is ignored.

    -
    only_grade_groups
    +
    only_grade_groups +

    (flag)
    whether only the specified grade groups should be included, with individual grade rows removed (TRUE), or all grades and grade groups should be displayed (FALSE).

    -
    + +
    -

    Value

    +

    Value +

    Formatted list of grade groupings.

    -

    Examples

    +

    Examples +

    h_append_grade_groups(
       list(
         "Any Grade" = as.character(1:5),
    @@ -197,17 +271,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_col_indices.html b/main/reference/h_col_indices.html index e75c742b02..99efd5fecb 100644 --- a/main/reference/h_col_indices.html +++ b/main/reference/h_col_indices.html @@ -1,9 +1,32 @@ - -Obtain column indices — h_col_indices • tern + + + + + +Obtain column indices — h_col_indices • tern + + + + + + + + + + + + + +vector of column names."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,39 +120,48 @@
    -

    Usage

    +

    Usage +

    h_col_indices(table_tree, col_names)
    -

    Arguments

    +

    Arguments +

    -
    table_tree
    +
    +
    table_tree +

    (VTableTree)
    rtables table object to extract the indices from.

    -
    col_names
    +
    col_names +

    (character)
    vector of column names.

    -
    + +
    -

    Value

    +

    Value +

    A vector of column indices.

    + + - + + - + + diff --git a/main/reference/h_count_cumulative.html b/main/reference/h_count_cumulative.html index d4a3d4c482..6d0679dd55 100644 --- a/main/reference/h_count_cumulative.html +++ b/main/reference/h_count_cumulative.html @@ -1,7 +1,30 @@ - -Helper function for s_count_cumulative() — h_count_cumulative • tern + + + + + + +Helper function for s_count_cumulative() — h_count_cumulative • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,33 +40,74 @@ + +
    @@ -54,7 +118,8 @@
    -

    Usage

    +

    Usage +

    h_count_cumulative(
       x,
       threshold,
    @@ -66,48 +131,63 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    threshold
    +
    threshold +

    (numeric(1))
    a cutoff value as threshold to count values of x.

    -
    lower_tail
    +
    lower_tail +

    (flag)
    whether to count lower tail, default is TRUE.

    -
    include_eq
    +
    include_eq +

    (flag)
    whether to include value equal to the threshold in count, default is TRUE.

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    + +
    -

    Value

    -

    A named vector with items:

    • count: the count of values less than, less or equal to, greater than, or greater or equal to a threshold +

      Value +

      +

      A named vector with items:

      +
        +
      • count: the count of values less than, less or equal to, greater than, or greater or equal to a threshold of user specification.

      • fraction: the fraction of the count.

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    set.seed(1, kind = "Mersenne-Twister")
     x <- c(sample(1:10, 10), NA)
     .N_col <- length(x)
    @@ -128,17 +208,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_cox_regression.html b/main/reference/h_cox_regression.html index ef4b366344..93494e6974 100644 --- a/main/reference/h_cox_regression.html +++ b/main/reference/h_cox_regression.html @@ -1,7 +1,30 @@ - -Helper functions for Cox proportional hazards regression — h_cox_regression • tern + + + + + + +Helper functions for Cox proportional hazards regression — h_cox_regression • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_coxreg_univar_formulas(variables, interaction = FALSE)
     
     h_coxreg_multivar_formula(variables)
    @@ -65,58 +129,80 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    interaction
    +
    interaction +

    (flag)
    if TRUE, the model includes the interaction between the studied treatment and candidate covariate. Note that for univariate models without treatment arm, and multivariate models, no interaction can be used so that this needs to be FALSE.

    -
    effect
    +
    effect +

    (string)
    the treatment variable.

    -
    covar
    +
    covar +

    (string)
    the name of the covariate in the model.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    mod
    +
    mod +

    (coxph)
    Cox regression model fitted by survival::coxph().

    -
    control
    +
    control +

    (list)
    a list of controls as returned by control_coxreg().

    -
    var
    +
    var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    + +
    -

    Value

    - -
    • h_coxreg_univar_formulas() returns a character vector coercible into formulas (e.g stats::as.formula()).

    • -
    • h_coxreg_multivar_formula() returns a string coercible into a formula (e.g stats::as.formula()).

    • -
    • h_coxreg_univar_extract() returns a data.frame with variables effect, term, term_label, level, +

      Value +

      + +
        +
      • h_coxreg_univar_formulas() returns a character vector coercible into formulas (e.g stats::as.formula()).

      • +
      +
        +
      • h_coxreg_multivar_formula() returns a string coercible into a formula (e.g stats::as.formula()).

      • +
      +
        +
      • h_coxreg_univar_extract() returns a data.frame with variables effect, term, term_label, level, n, hr, lcl, ucl, and pval.

      • -
      • h_coxreg_multivar_extract() returns a data.frame with variables pval, hr, lcl, ucl, level, +

      +
        +
      • h_coxreg_multivar_extract() returns a data.frame with variables pval, hr, lcl, ucl, level, n, term, and term_label.

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • h_coxreg_univar_formulas(): Helper for Cox regression formula. Creates a list of formulas. It is used +

        +
      • h_coxreg_univar_formulas(): Helper for Cox regression formula. Creates a list of formulas. It is used internally by fit_coxreg_univar() for the comparison of univariate Cox regression models.

      • h_coxreg_multivar_formula(): Helper for multivariate Cox regression formula. Creates a formulas string. It is used internally by fit_coxreg_multivar() for the comparison of multivariate Cox @@ -125,14 +211,17 @@

        Functions -

        See also

        +

        See also +

    -

    Examples

    +

    Examples +

    # `h_coxreg_univar_formulas`
     
     ## Simple formulas.
    @@ -243,17 +332,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_data_plot.html b/main/reference/h_data_plot.html index 99e574af82..fbe92eb63a 100644 --- a/main/reference/h_data_plot.html +++ b/main/reference/h_data_plot.html @@ -1,5 +1,22 @@ - -Helper function to tidy survival fit data — h_data_plot • tern + + + + + +Helper function to tidy survival fit data — h_data_plot • tern + + + + + + + + + + + + + +"> + + + + + Skip to contents @@ -35,26 +58,66 @@ + + @@ -70,43 +133,55 @@

    [Stable]

    Convert the survival fit data into a data frame designed for plotting within g_km.

    -

    This starts from the broom::tidy() result, and then:

    • Post-processes the strata column into a factor.

    • +

      This starts from the broom::tidy() result, and then:

      +
        +
      • Post-processes the strata column into a factor.

      • Extends each stratum by an additional first row with time 0 and probability 1 so that downstream plot lines start at those coordinates.

      • Adds a censor column.

      • Filters the rows before max_time.

      • -
      +
    +
    -

    Usage

    +

    Usage +

    h_data_plot(fit_km, armval = "All", max_time = NULL)
    -

    Arguments

    +

    Arguments +

    -
    fit_km
    +
    +
    fit_km +

    (survfit)
    result of survival::survfit().

    -
    armval
    +
    armval +

    (string)
    used as strata name when treatment arm variable only has one level. Default is "All".

    -
    max_time
    +
    max_time +

    (numeric(1))
    maximum value to show on x-axis. Only data values less than or up to this threshold value will be plotted (defaults to NULL).

    -
    + +
    -

    Value

    +

    Value +

    A tibble with columns time, n.risk, n.event, n.censor, estimate, std.error, conf.high, conf.low, strata, and censor.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(survival)
     
    @@ -155,17 +230,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_decompose_gg.html b/main/reference/h_decompose_gg.html index ceec3167bf..4fd8fa0888 100644 --- a/main/reference/h_decompose_gg.html +++ b/main/reference/h_decompose_gg.html @@ -1,7 +1,30 @@ - -ggplot decomposition — h_decompose_gg • tern + + + + + + +ggplot decomposition — h_decompose_gg • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,33 +40,74 @@ + +
    @@ -54,30 +118,40 @@
    -

    Usage

    +

    Usage +

    h_decompose_gg(gg)
    -

    Arguments

    +

    Arguments +

    -
    gg
    +
    +
    gg +

    (ggplot)
    a graphic to decompose.

    -
    + +
    -

    Value

    -

    A named list with elements:

    • panel: The panel.

    • +

      Value +

      +

      A named list with elements:

      +
        +
      • panel: The panel.

      • yaxis: The y-axis.

      • xaxis: The x-axis.

      • xlab: The x-axis label.

      • ylab: The y-axis label.

      • guide: The legend.

      • -
    + +
    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -118,17 +192,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_format_row.html b/main/reference/h_format_row.html index a572e7725f..a4aa2387f2 100644 --- a/main/reference/h_format_row.html +++ b/main/reference/h_format_row.html @@ -1,5 +1,28 @@ - -Helper function to format the optional g_lineplot table — h_format_row • tern + + + + + + +Helper function to format the optional g_lineplot table — h_format_row • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,40 +114,49 @@
    -

    Usage

    +

    Usage +

    h_format_row(x, format, labels = NULL)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (named list)
    list of numerical values to be formatted and optionally labeled. Elements of x must be numeric vectors.

    -
    format
    +
    format +

    (named character or NULL)
    format patterns for x. Names of the format must match the names of x. This parameter is passed directly to the rtables::format_rcell function through the format parameter.

    -
    labels
    +
    labels +

    (named character or NULL)
    optional labels for x. Names of the labels must match the names of x. When a label is not specified for an element of x, then this function tries to use label or names (in this order) attribute of that element (depending on which one exists and it is not NULL or NA or NaN). If none of these attributes are attached to a given element of x, then the label is automatically generated.

    -
    + +
    -

    Value

    +

    Value +

    A single row data.frame object.

    -

    Examples

    +

    Examples +

    mean_ci <- c(48, 51)
     x <- list(mean = 50, mean_ci = mean_ci)
     format <- c(mean = "xx.x", mean_ci = "(xx.xx, xx.xx)")
    @@ -102,17 +174,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_g_ipp.html b/main/reference/h_g_ipp.html index 7b223cbddf..b88a95824a 100644 --- a/main/reference/h_g_ipp.html +++ b/main/reference/h_g_ipp.html @@ -1,7 +1,30 @@ - -Helper function to create simple line plot over time — h_g_ipp • tern + + + + + + +Helper function to create simple line plot over time — h_g_ipp • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_g_ipp(
       df,
       xvar,
    @@ -73,75 +137,94 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    xvar
    +
    xvar +

    (string)
    time point variable to be plotted on x-axis.

    -
    yvar
    +
    yvar +

    (string)
    continuous analysis variable to be plotted on y-axis.

    -
    xlab
    +
    xlab +

    (string)
    plot label for x-axis.

    -
    ylab
    +
    ylab +

    (string)
    plot label for y-axis.

    -
    id_var
    +
    id_var +

    (string)
    variable used as patient identifier.

    -
    title
    +
    title +

    (string)
    title for plot.

    -
    subtitle
    +
    subtitle +

    (string)
    subtitle for plot.

    -
    caption
    +
    caption +

    (string)
    optional caption below the plot.

    -
    add_baseline_hline
    +
    add_baseline_hline +

    (flag)
    adds horizontal line at baseline y-value on plot when TRUE.

    -
    yvar_baseline
    +
    yvar_baseline +

    (string)
    variable with baseline values only. Ignored when add_baseline_hline is FALSE.

    -
    ggtheme
    +
    ggtheme +

    (theme)
    optional graphical theme function as provided by ggplot2 to control outlook of plot. Use ggplot2::theme() to tweak the display.

    -
    col
    +
    col +

    (character)
    line colors.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot line plot.

    -

    See also

    +

    See also +

    g_ipp() which uses this function.

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # Select a small sample of data to plot.
    @@ -164,17 +247,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_ggkm.html b/main/reference/h_ggkm.html index c8fee643e4..4b3a76f99b 100644 --- a/main/reference/h_ggkm.html +++ b/main/reference/h_ggkm.html @@ -1,7 +1,30 @@ - -Helper function to create a KM plot — h_ggkm • tern + + + + + + +Helper function to create a KM plot — h_ggkm • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_ggkm(
       data,
       xticks = NULL,
    @@ -77,92 +141,114 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    survival data as pre-processed by h_data_plot.

    -
    xticks
    +
    xticks +

    (numeric or NULL)
    numeric vector of tick positions or a single number with spacing between ticks on the x-axis. If NULL (default), labeling::extended() is used to determine optimal tick positions on the x-axis.

    -
    yval
    +
    yval +

    (string)
    type of plot, to be plotted on the y-axis. Options are Survival (default) and Failure probability.

    -
    censor_show
    +
    censor_show +

    (flag)
    whether to show censored observations.

    -
    xlab
    +
    xlab +

    (string)
    x-axis label.

    -
    ylab
    +
    ylab +

    (string)
    y-axis label.

    -
    ylim
    +
    ylim +

    (numeric(2))
    vector containing lower and upper limits for the y-axis, respectively. If NULL (default), the default scale range is used.

    -
    title
    +
    title +

    (string)
    plot title.

    -
    footnotes
    +
    footnotes +

    (string)
    plot footnotes.

    -
    max_time
    +
    max_time +

    (numeric(1))
    maximum value to show on x-axis. Only data values less than or up to this threshold value will be plotted (defaults to NULL).

    -
    lwd
    +
    lwd +

    (numeric)
    line width. If a vector is given, its length should be equal to the number of strata from survival::survfit().

    -
    lty
    +
    lty +

    (numeric)
    line type. If a vector is given, its length should be equal to the number of strata from survival::survfit().

    -
    pch
    +
    pch +

    (string)
    name of symbol or character to use as point symbol to indicate censored cases.

    -
    size
    +
    size +

    (numeric(1))
    size of censored point symbols.

    -
    col
    +
    col +

    (character)
    lines colors. Length of a vector should be equal to number of strata from survival::survfit().

    -
    ci_ribbon
    +
    ci_ribbon +

    (flag)
    whether the confidence interval should be drawn around the Kaplan-Meier curve.

    -
    ggtheme
    +
    ggtheme +

    (theme)
    a graphical theme as provided by ggplot2 to format the Kaplan-Meier plot.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot object.

    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -188,17 +274,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_glm_count.html b/main/reference/h_glm_count.html index bd7ac31cac..54195a0e53 100644 --- a/main/reference/h_glm_count.html +++ b/main/reference/h_glm_count.html @@ -1,11 +1,34 @@ - -Helper functions for Poisson models — h_glm_count • tern + + + + + +Helper functions for Poisson models — h_glm_count • tern + + + + + + + + + + + + + +distributions. Link function for the GLM is log."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,7 +123,8 @@
    -

    Usage

    +

    Usage +

    h_glm_count(.var, .df_row, variables, distribution, weights)
     
     h_glm_poisson(.var, .df_row, variables, weights)
    @@ -71,75 +135,102 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    .var
    +
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    dataset that includes all the variables that are called in .var and variables.

    -
    variables
    -

    (named list of string)
    list of additional analysis variables, with -expected elements:

    • arm (string)
      group variable, for which the covariate adjusted means of multiple +

      variables +
      +
      +

      (named list of string)
      list of additional analysis variables, with +expected elements:

      +
        +
      • arm (string)
        group variable, for which the covariate adjusted means of multiple groups will be summarized. Specifically, the first level of arm variable is taken as the reference group.

      • covariates (character)
        a vector that can contain single variable names (such as "X1"), and/or interaction terms indicated by "X1 * X2".

      • offset (numeric)
        a numeric vector or scalar adding an offset.

      • -
      +
    +
    -
    distribution
    +
    distribution +

    (character)
    a character value specifying the distribution used in the regression (Poisson, Quasi-Poisson, negative binomial).

    -
    weights
    +
    weights +

    (character)
    a character vector specifying weights used in averaging predictions. Number of weights must equal the number of levels included in the covariates. Weights option passed to emmeans::emmeans().

    -
    + +
    -

    Value

    - -
    • h_glm_count() returns the results of the selected model.

    • -
    • h_glm_poisson() returns the results of a Poisson model.

    • -
    • h_glm_quasipoisson() returns the results of a Quasi-Poisson model.

    • -
    • h_glm_negbin() returns the results of a negative binomial model.

    • -
    +

    Value +

    + +
      +
    • h_glm_count() returns the results of the selected model.

    • +
    +
      +
    • h_glm_poisson() returns the results of a Poisson model.

    • +
    +
      +
    • h_glm_quasipoisson() returns the results of a Quasi-Poisson model.

    • +
    +
      +
    • h_glm_negbin() returns the results of a negative binomial model.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • h_glm_count(): Helper function to return the results of the +

        +
      • h_glm_count(): Helper function to return the results of the selected model (Poisson, Quasi-Poisson, negative binomial).

      • h_glm_poisson(): Helper function to return results of a Poisson model.

      • h_glm_quasipoisson(): Helper function to return results of a Quasi-Poisson model.

      • h_glm_negbin(): Helper function to return results of a negative binomial model.

      • -
    + +
    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/h_grob_coxph.html b/main/reference/h_grob_coxph.html index 304a345f30..b6ae57e8fb 100644 --- a/main/reference/h_grob_coxph.html +++ b/main/reference/h_grob_coxph.html @@ -1,7 +1,30 @@ - -Helper function to create Cox-PH grobs — h_grob_coxph • tern + + + + + + +Helper function to create Cox-PH grobs — h_grob_coxph • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_grob_coxph(
       ...,
       x = 0,
    @@ -66,37 +130,47 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    ...
    +
    +
    ... +

    arguments to pass to h_tbl_coxph_pairwise().

    -
    x
    +
    x +

    (proportion)
    a value between 0 and 1 specifying x-location.

    -
    y
    +
    y +

    (proportion)
    a value between 0 and 1 specifying y-location.

    -
    width
    +
    width +

    (grid::unit)
    width (as a unit) to use when printing the grob.

    -
    ttheme
    +
    ttheme +

    (list)
    see gridExtra::ttheme_default().

    -
    + +
    -

    Value

    +

    Value +

    A grob of a table containing statistics HR, XX% CI (XX taken from control_coxph_pw), and p-value (log-rank).

    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -122,17 +196,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_grob_median_surv.html b/main/reference/h_grob_median_surv.html index e5405c94b7..5a93dfc849 100644 --- a/main/reference/h_grob_median_surv.html +++ b/main/reference/h_grob_median_surv.html @@ -1,9 +1,32 @@ - -Helper function to create survival estimation grobs — h_grob_median_surv • tern + + + + + +Helper function to create survival estimation grobs — h_grob_median_surv • tern + + + + + + + + + + + + + +rows characterized by N, median and 95% confidence interval."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    h_grob_median_surv(
       fit_km,
       armval = "All",
    @@ -69,40 +133,51 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    fit_km
    +
    +
    fit_km +

    (survfit)
    result of survival::survfit().

    -
    armval
    +
    armval +

    (string)
    used as strata name when treatment arm variable only has one level. Default is "All".

    -
    x
    +
    x +

    (proportion)
    a value between 0 and 1 specifying x-location.

    -
    y
    +
    y +

    (proportion)
    a value between 0 and 1 specifying y-location.

    -
    width
    +
    width +

    (grid::unit)
    width (as a unit) to use when printing the grob.

    -
    ttheme
    +
    ttheme +

    (list)
    see gridExtra::ttheme_default().

    -
    + +
    -

    Value

    +

    Value +

    A grob of a table containing statistics N, Median, and XX% CI (XX taken from fit_km).

    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -124,17 +199,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_grob_tbl_at_risk.html b/main/reference/h_grob_tbl_at_risk.html index e425fa6708..0676d52dae 100644 --- a/main/reference/h_grob_tbl_at_risk.html +++ b/main/reference/h_grob_tbl_at_risk.html @@ -1,11 +1,34 @@ - -Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk • tern + + + + + +Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk • tern + + + + + + + + + + + + + +also obtained."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,41 +123,51 @@
    -

    Usage

    +

    Usage +

    h_grob_tbl_at_risk(data, annot_tbl, xlim, title = TRUE)
    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    survival data as pre-processed by h_data_plot.

    -
    annot_tbl
    +
    annot_tbl +

    (data.frame)
    annotation as prepared by survival::summary.survfit() which includes the number of patients at risk at given time points.

    -
    xlim
    +
    xlim +

    (numeric(1))
    the maximum value on the x-axis (used to ensure the at risk table aligns with the KM graph).

    -
    title
    +
    title +

    (flag)
    whether the "Patients at Risk" title should be added above the annot_at_risk table. Has no effect if annot_at_risk is FALSE. Defaults to TRUE.

    -
    + +
    -

    Value

    +

    Value +

    A named list of two gTree objects if title = FALSE: at_risk and label, or three gTree objects if title = TRUE: at_risk, label, and title.

    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -160,17 +233,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_grob_y_annot.html b/main/reference/h_grob_y_annot.html index a82eda565e..a32dc37b27 100644 --- a/main/reference/h_grob_y_annot.html +++ b/main/reference/h_grob_y_annot.html @@ -1,7 +1,30 @@ - -Helper function to create grid object with y-axis annotation — h_grob_y_annot • tern + + + + + + +Helper function to create grid object with y-axis annotation — h_grob_y_annot • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,29 +117,37 @@
    -

    Usage

    +

    Usage +

    h_grob_y_annot(ylab, yaxis)
    -

    Arguments

    +

    Arguments +

    -
    ylab
    +
    +
    ylab +

    (gtable)
    the y-lab as a graphical object derived from a ggplot.

    -
    yaxis
    +
    yaxis +

    (gtable)
    the y-axis as a graphical object derived from a ggplot.

    -
    + +
    -

    Value

    +

    Value +

    A gTree object containing the y-axis annotation from a ggplot.

    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -110,17 +181,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_incidence_rate.html b/main/reference/h_incidence_rate.html index 5753724f5c..8eda8f4dd2 100644 --- a/main/reference/h_incidence_rate.html +++ b/main/reference/h_incidence_rate.html @@ -1,5 +1,28 @@ - -Helper functions for incidence rate — h_incidence_rate • tern + + + + + + +Helper functions for incidence rate — h_incidence_rate • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    h_incidence_rate(person_years, n_events, control = control_incidence_rate())
     
     h_incidence_rate_normal(person_years, n_events, alpha = 0.05)
    @@ -64,40 +128,54 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    person_years
    +
    +
    person_years +

    (numeric(1))
    total person-years at risk.

    -
    n_events
    +
    n_events +

    (integer(1))
    number of events observed.

    -
    control
    -

    (list)
    parameters for estimation details, specified by using -the helper function control_incidence_rate(). Possible parameter options are:

    • conf_level: (proportion)
      confidence level for the estimated incidence rate.

    • +
      control +
      +
      +

      (list)
      parameters for estimation details, specified by using +the helper function control_incidence_rate(). Possible parameter options are:

      +
        +
      • conf_level: (proportion)
        confidence level for the estimated incidence rate.

      • conf_type: (string)
        normal (default), normal_log, exact, or byar for confidence interval type.

      • input_time_unit: (string)
        day, week, month, or year (default) indicating time unit for data input.

      • num_pt_year: (numeric)
        time unit for desired output (in person-years).

      • -
      +
    +
    -
    alpha
    +
    alpha +

    (numeric(1))
    two-sided alpha-level for confidence interval.

    -
    + +
    -

    Value

    +

    Value +

    Estimated incidence rate, rate, and associated confidence interval, rate_ci.

    -

    Functions

    +

    Functions +

    -
    • h_incidence_rate(): Helper function to estimate the incidence rate and +

        +
      • h_incidence_rate(): Helper function to estimate the incidence rate and associated confidence interval.

      • h_incidence_rate_normal(): Helper function to estimate the incidence rate and associated confidence interval based on the normal approximation for the @@ -109,14 +187,17 @@

        Functions -

        See also

        +

        See also +

    -

    Examples

    +

    Examples +

    h_incidence_rate_normal(200, 2)
     #> $rate
     #> [1] 0.01
    @@ -152,17 +233,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_km_layout.html b/main/reference/h_km_layout.html index fa66651084..e53555d23e 100644 --- a/main/reference/h_km_layout.html +++ b/main/reference/h_km_layout.html @@ -1,7 +1,30 @@ - -Helper function to prepare a KM layout — h_km_layout • tern + + + + + + +Helper function to prepare a KM layout — h_km_layout • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_km_layout(
       data,
       g_el,
    @@ -66,50 +130,65 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    survival data as pre-processed by h_data_plot.

    -
    g_el
    +
    g_el +

    (list of gtable)
    list as obtained by h_decompose_gg().

    -
    title
    +
    title +

    (string)
    plot title.

    -
    footnotes
    +
    footnotes +

    (string)
    plot footnotes.

    -
    annot_at_risk
    +
    annot_at_risk +

    (flag)
    compute and add the annotation table reporting the number of patient at risk matching the main grid of the Kaplan-Meier curve.

    -
    annot_at_risk_title
    +
    annot_at_risk_title +

    (flag)
    whether the "Patients at Risk" title should be added above the annot_at_risk table. Has no effect if annot_at_risk is FALSE. Defaults to TRUE.

    -
    + +
    -

    Value

    +

    Value +

    A grid layout.

    -

    Details

    +

    Details +

    The layout corresponds to a grid of two columns and five rows of unequal dimensions. Most of the -dimension are fixed, only the curve is flexible and will accommodate with the remaining free space.

    • The left column gets the annotation of the ggplot (y-axis) and the names of the strata for the patient +dimension are fixed, only the curve is flexible and will accommodate with the remaining free space.

      +
        +
      • The left column gets the annotation of the ggplot (y-axis) and the names of the strata for the patient at risk tabulation. The main constraint is about the width of the columns which must allow the writing of the strata name.

      • The right column receive the ggplot, the legend, the x-axis and the patient at risk table.

      • -
    + +
    -

    Examples

    +

    Examples +

    # \donttest{
     library(dplyr)
     library(survival)
    @@ -135,17 +214,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_logistic_regression.html b/main/reference/h_logistic_regression.html index a5d1503cde..a5546c6692 100644 --- a/main/reference/h_logistic_regression.html +++ b/main/reference/h_logistic_regression.html @@ -1,7 +1,30 @@ - -Helper functions for multivariate logistic regression — h_logistic_regression • tern + + + + + + +Helper functions for multivariate logistic regression — h_logistic_regression • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_get_interaction_vars(fit_glm)
     
     h_interaction_coef_name(
    @@ -102,75 +166,94 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    fit_glm
    +
    +
    fit_glm +

    (glm)
    logistic regression model fitted by stats::glm() with "binomial" family. Limited functionality is also available for conditional logistic regression models fitted by survival::clogit(), currently this is used only by extract_rsp_biomarkers().

    -
    interaction_vars
    +
    interaction_vars +

    (character(2))
    interaction variable names.

    -
    first_var_with_level
    +
    first_var_with_level +

    (character(2))
    the first variable name with the interaction level.

    -
    second_var_with_level
    +
    second_var_with_level +

    (character(2))
    the second variable name with the interaction level.

    -
    odds_ratio_var
    +
    odds_ratio_var +

    (string)
    the odds ratio variable.

    -
    interaction_var
    +
    interaction_var +

    (string)
    the interaction variable.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    at
    +
    at +

    (numeric or NULL)
    optional values for the interaction variable. Otherwise the median is used.

    -
    terms
    +
    terms +

    (character)
    simple terms.

    -
    table
    +
    table +

    (table)
    table containing numbers for terms.

    -
    terms1
    +
    terms1 +

    (character)
    terms for first dimension (rows).

    -
    terms2
    +
    terms2 +

    (character)
    terms for second dimension (rows).

    -
    any
    +
    any +

    (flag)
    whether any of term1 and term2 can be fulfilled to count the number of patients. In that case they can only be scalar (strings).

    -
    x
    +
    x +

    (character)
    a variable or interaction term in fit_glm (depending on the helper function used).

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    + +
    -

    Value

    +

    Value +

    Vector of names of interaction variables.

    Name of coefficient.

    Odds ratio.

    @@ -185,9 +268,11 @@

    Value

    Tabulated statistics for the given variable(s) from the logistic regression model.

    -

    Functions

    +

    Functions +

    -
    • h_get_interaction_vars(): Helper function to extract interaction variable names from a fitted +

        +
      • h_get_interaction_vars(): Helper function to extract interaction variable names from a fitted model assuming only one interaction term.

      • h_interaction_coef_name(): Helper function to get the right coefficient name from the interaction variable names and the given levels. The main value here is that the order @@ -215,16 +300,19 @@

        Functions -

        Note

        +

        Note +

        We don't provide a function for the case when both variables are continuous because this does not arise in this table, as the treatment arm variable will always be involved and categorical.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(broom)
     
    @@ -404,17 +492,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_map_for_count_abnormal.html b/main/reference/h_map_for_count_abnormal.html index d527e11578..c6766999a1 100644 --- a/main/reference/h_map_for_count_abnormal.html +++ b/main/reference/h_map_for_count_abnormal.html @@ -1,9 +1,32 @@ - -Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal • tern + + + + + +Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal • tern + + + + + + + + + + + + + +trim_levels_to_map split function. Based on different method, the map is constructed differently."> + + + + + Skip to contents @@ -19,33 +42,74 @@ + +
    @@ -57,7 +121,8 @@
    -

    Usage

    +

    Usage +

    h_map_for_count_abnormal(
       df,
       variables = list(anl = "ANRIND", split_rows = c("PARAM"), range_low = "ANRLO",
    @@ -69,37 +134,47 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    abnormal
    +
    abnormal +

    (named list)
    identifying the abnormal range level(s) in df. Based on the levels of abnormality of the input dataset, it can be something like list(Low = "LOW LOW", High = "HIGH HIGH") or abnormal = list(Low = "LOW", High = "HIGH"))

    -
    method
    +
    method +

    (string)
    indicates how the returned map will be constructed. Can be "default" or "range".

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    + +
    -

    Value

    +

    Value +

    A map data.frame.

    -

    Note

    +

    Note +

    If method is "default", the returned map will only have the abnormal directions that are observed in the df, and records with all normal values will be excluded to avoid error in creating layout. If method is "range", the returned map will be based on the rule that at least one observation with low range > 0 @@ -107,7 +182,8 @@

    Note

    -

    Examples

    +

    Examples +

    adlb <- df_explicit_na(tern_ex_adlb)
     
     h_map_for_count_abnormal(
    @@ -170,17 +246,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_odds_ratio.html b/main/reference/h_odds_ratio.html index f768073a32..1e0b758e21 100644 --- a/main/reference/h_odds_ratio.html +++ b/main/reference/h_odds_ratio.html @@ -1,7 +1,30 @@ - -Helper functions for odds ratio estimation — h_odds_ratio • tern + + + + + + +Helper functions for odds ratio estimation — h_odds_ratio • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,50 +117,63 @@
    -

    Usage

    +

    Usage +

    or_glm(data, conf_level)
     
     or_clogit(data, conf_level, method = "exact")
    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    data frame containing at least the variables rsp and grp, and optionally strata for or_clogit().

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string)
    whether to use the correct ("exact") calculation in the conditional likelihood or one of the approximations. See survival::clogit() for details.

    -
    + +
    -

    Value

    +

    Value +

    A named list of elements or_ci and n_tot.

    -

    Functions

    +

    Functions +

    -
    • or_glm(): Estimates the odds ratio based on stats::glm(). Note that there must be +

        +
      • or_glm(): Estimates the odds ratio based on stats::glm(). Note that there must be exactly 2 groups in data as specified by the grp variable.

      • or_clogit(): Estimates the odds ratio based on survival::clogit(). This is done for the whole data set including all groups, since the results are not the same as when doing pairwise comparisons between the groups.

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    # Data with 2 groups.
     data <- data.frame(
       rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1)),
    @@ -145,17 +221,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_pkparam_sort.html b/main/reference/h_pkparam_sort.html index 78aef263fa..d19d75aec4 100644 --- a/main/reference/h_pkparam_sort.html +++ b/main/reference/h_pkparam_sort.html @@ -1,5 +1,28 @@ - -Sort pharmacokinetic data by PARAM variable — h_pkparam_sort • tern + + + + + + +Sort pharmacokinetic data by PARAM variable — h_pkparam_sort • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,29 +114,37 @@
    -

    Usage

    +

    Usage +

    h_pkparam_sort(pk_data, key_var = "PARAMCD")
    -

    Arguments

    +

    Arguments +

    -
    pk_data
    +
    +
    pk_data +

    (data.frame)
    pharmacokinetic data frame.

    -
    key_var
    +
    key_var +

    (string)
    key variable used to merge pk_data and metadata created by d_pkparam().

    -
    + +
    -

    Value

    +

    Value +

    A pharmacokinetic data.frame sorted by a PARAM variable.

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adpp <- tern_ex_adpp %>% mutate(PKPARAM = factor(paste0(PARAM, " (", AVALU, ")")))
    @@ -82,17 +153,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_ppmeans.html b/main/reference/h_ppmeans.html index a3eaa34a84..fd63721722 100644 --- a/main/reference/h_ppmeans.html +++ b/main/reference/h_ppmeans.html @@ -1,9 +1,32 @@ - -Function to return the estimated means using predicted probabilities — h_ppmeans • tern + + + + + +Function to return the estimated means using predicted probabilities — h_ppmeans • tern + + + + + + + + + + + + + +object formula (coming from the fit). The confidence interval is derived using the conf_level parameter."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,53 +120,67 @@
    -

    Usage

    +

    Usage +

    h_ppmeans(obj, .df_row, arm, conf_level)
    -

    Arguments

    +

    Arguments +

    -
    obj
    +
    +
    obj +

    (glm.fit)
    fitted model object used to derive the mean rate estimates in each treatment arm.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    dataset that includes all the variables that are called in .var and variables.

    -
    arm
    +
    arm +

    (string)
    group variable, for which the covariate adjusted means of multiple groups will be summarized. Specifically, the first level of arm variable is taken as the reference group.

    -
    conf_level
    +
    conf_level +

    (proportion)
    value used to derive the confidence interval for the rate.

    -
    + +
    -

    Value

    +

    Value +

    -
    • h_ppmeans() returns the estimated means.

    • -
    +
      +
    • h_ppmeans() returns the estimated means.

    • +
    +
    -

    See also

    +

    See also +

    + + - + + - + + diff --git a/main/reference/h_prop_diff.html b/main/reference/h_prop_diff.html index f1325782cb..4133b0c3d8 100644 --- a/main/reference/h_prop_diff.html +++ b/main/reference/h_prop_diff.html @@ -1,5 +1,28 @@ - -Helper functions to calculate proportion difference — h_prop_diff • tern + + + + + + +Helper functions to calculate proportion difference — h_prop_diff • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    prop_diff_wald(rsp, grp, conf_level = 0.95, correct = FALSE)
     
     prop_diff_ha(rsp, grp, conf_level)
    @@ -71,45 +135,57 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    rsp
    +
    +
    rsp +

    (logical)
    vector indicating whether each subject is a responder or not.

    -
    grp
    +
    grp +

    (factor)
    vector assigning observations to one out of two groups (e.g. reference and treatment group).

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    correct
    +
    correct +

    (flag)
    whether to include the continuity correction. For further information, see stats::prop.test().

    -
    strata
    +
    strata +

    (factor)
    variable with one level per stratum and same length as rsp.

    -
    weights_method
    +
    weights_method +

    (string)
    weights method. Can be either "cmh" or "heuristic" and directs the way weights are estimated.

    -
    + +
    -

    Value

    +

    Value +

    A named list of elements diff (proportion difference) and diff_ci (proportion difference confidence interval).

    -

    Functions

    +

    Functions +

    -
    • prop_diff_wald(): The Wald interval follows the usual textbook +

        +
      • prop_diff_wald(): The Wald interval follows the usual textbook definition for a single proportion confidence interval using the normal approximation. It is possible to include a continuity correction for Wald's interval.

      • @@ -125,18 +201,22 @@

        Functionsprop_strat_wilson() or from CMH-derived weights (see prop_diff_cmh()).

        -

    + +
    -

    References

    +

    References +

    Yan2010-jttern

    -

    See also

    +

    See also +

    prop_diff() for implementation of these helper functions.

    -

    Examples

    +

    Examples +

    # Wald confidence interval
     set.seed(2)
     rsp <- sample(c(TRUE, FALSE), replace = TRUE, size = 20)
    @@ -284,17 +364,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_prop_diff_test.html b/main/reference/h_prop_diff_test.html index 4e56608410..149f596d00 100644 --- a/main/reference/h_prop_diff_test.html +++ b/main/reference/h_prop_diff_test.html @@ -1,5 +1,28 @@ - -Helper functions to test proportion differences — h_prop_diff_test • tern + + + + + + +Helper functions to test proportion differences — h_prop_diff_test • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    prop_chisq(tbl)
     
     prop_cmh(ary)
    @@ -62,49 +126,63 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    tbl
    +
    +
    tbl +

    (matrix)
    matrix with two groups in rows and the binary response (TRUE/FALSE) in columns.

    -
    ary
    +
    ary +

    (array, 3 dimensions)
    array with two groups in rows, the binary response (TRUE/FALSE) in columns, and the strata in the third dimension.

    -
    + +
    -

    Value

    +

    Value +

    A p-value.

    -

    Functions

    +

    Functions +

    -
    • prop_chisq(): Performs Chi-Squared test. Internally calls stats::prop.test().

    • +
        +
      • prop_chisq(): Performs Chi-Squared test. Internally calls stats::prop.test().

      • prop_cmh(): Performs stratified Cochran-Mantel-Haenszel test. Internally calls stats::mantelhaen.test(). Note that strata with less than two observations are automatically discarded.

      • prop_schouten(): Performs the Chi-Squared test with Schouten correction.

      • prop_fisher(): Performs the Fisher's exact test. Internally calls stats::fisher.test().

      • -
    + +
    -

    See also

    -

    prop_diff_test() for implementation of these helper functions.

    -

    Schouten correction is based upon Schouten1980-kd;textualtern.

    +

    See also +

    +
    +

    prop_diff_test() for implementation of these helper functions.

    +

    Schouten correction is based upon Schouten1980-kd;textualtern.

    +
    + + - + + - + + diff --git a/main/reference/h_proportions.html b/main/reference/h_proportions.html index 285e7e75d3..b03c93816c 100644 --- a/main/reference/h_proportions.html +++ b/main/reference/h_proportions.html @@ -1,7 +1,30 @@ - -Helper functions for calculating proportion confidence intervals — h_proportions • tern + + + + + + +Helper functions for calculating proportion confidence intervals — h_proportions • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    prop_wilson(rsp, conf_level, correct = FALSE)
     
     prop_strat_wilson(
    @@ -76,44 +140,56 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    rsp
    +
    +
    rsp +

    (logical)
    vector indicating whether each subject is a responder or not.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    correct
    +
    correct +

    (flag)
    whether to apply continuity correction.

    -
    strata
    +
    strata +

    (factor)
    variable with one level per stratum and same length as rsp.

    -
    weights
    +
    weights +

    (numeric or NULL)
    weights for each level of the strata. If NULL, they are estimated using the iterative algorithm proposed in Yan2010-jt;textualtern that minimizes the weighted squared length of the confidence interval.

    -
    max_iterations
    +
    max_iterations +

    (count)
    maximum number of iterations for the iterative procedure used to find estimates of optimal weights.

    -
    + +
    -

    Value

    +

    Value +

    Confidence interval of a proportion.

    -

    Functions

    +

    Functions +

    -
    • prop_wilson(): Calculates the Wilson interval by calling stats::prop.test(). +

        +
      • prop_wilson(): Calculates the Wilson interval by calling stats::prop.test(). Also referred to as Wilson score interval.

      • prop_strat_wilson(): Calculates the stratified Wilson confidence interval for unequal proportions as described in Yan2010-jt;textualtern

      • @@ -125,19 +201,23 @@

        Functions -

        References

        +

        References +

        Yan2010-jttern

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    rsp <- c(
       TRUE, TRUE, TRUE, TRUE, TRUE,
       FALSE, FALSE, FALSE, FALSE, FALSE
    @@ -198,17 +278,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_response_biomarkers_subgroups.html b/main/reference/h_response_biomarkers_subgroups.html index 3792c4a2f8..64d745bc20 100644 --- a/main/reference/h_response_biomarkers_subgroups.html +++ b/main/reference/h_response_biomarkers_subgroups.html @@ -1,9 +1,32 @@ - -Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups • tern + + + + + +Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups • tern + + + + + + + + + + + + + +when reading about the user-facing functions."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    h_rsp_to_logistic_variables(variables, biomarker)
     
     h_logistic_mult_cont_df(variables, data, control = control_logistic())
    @@ -66,64 +130,88 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    biomarker
    +
    biomarker +

    (string)
    the name of the biomarker variable.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    control
    +
    control +

    (named list)
    controls for the response definition and the confidence level produced by control_logistic().

    -
    df
    +
    df +

    (data.frame)
    results for a single biomarker, as part of what is returned by extract_rsp_biomarkers() (it needs a couple of columns which are added by that high-level function relative to what is returned by h_logistic_mult_cont_df(), see the example).

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n_tot: Total number of patients per group.

    • +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n_tot: Total number of patients per group.

      • n_rsp: Total number of responses per group.

      • prop: Total response proportion per group.

      • or: Odds ratio.

      • ci: Confidence interval of odds ratio.

      • pval: p-value of the effect. Note, the statistics n_tot, or and ci are required.

      • -
      +
    +
    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    + +
    -

    Value

    - -
    • h_rsp_to_logistic_variables() returns a named list of elements response, arm, covariates, and strata.

    • -
    • h_logistic_mult_cont_df() returns a data.frame containing estimates and statistics for the selected biomarkers.

    • -
    • h_tab_rsp_one_biomarker() returns an rtables table object with the given statistics arranged in columns.

    • -
    +

    Value +

    + +
      +
    • h_rsp_to_logistic_variables() returns a named list of elements response, arm, covariates, and strata.

    • +
    +
      +
    • h_logistic_mult_cont_df() returns a data.frame containing estimates and statistics for the selected biomarkers.

    • +
    +
      +
    • h_tab_rsp_one_biomarker() returns an rtables table object with the given statistics arranged in columns.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • h_rsp_to_logistic_variables(): helps with converting the "response" function variable list +

        +
      • h_rsp_to_logistic_variables(): helps with converting the "response" function variable list to the "logistic regression" variable list. The reason is that currently there is an inconsistency between the variable names accepted by extract_rsp_subgroups() and fit_logistic().

      • h_logistic_mult_cont_df(): prepares estimates for number of responses, patients and @@ -134,10 +222,12 @@

        Functions -

        Examples

        +

        Examples +

        library(dplyr)
         library(forcats)
         
        @@ -224,17 +314,19 @@ 

        Examples

        + +
    - + + - + + diff --git a/main/reference/h_response_subgroups.html b/main/reference/h_response_subgroups.html index 348c1cfd34..4112d9219f 100644 --- a/main/reference/h_response_subgroups.html +++ b/main/reference/h_response_subgroups.html @@ -1,9 +1,32 @@ - -Helper functions for tabulating binary response by subgroup — h_response_subgroups • tern + + + + + +Helper functions for tabulating binary response by subgroup — h_response_subgroups • tern + + + + + + + + + + + + + +and odds ratio for population subgroups."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    h_proportion_df(rsp, arm)
     
     h_proportion_subgroups_df(
    @@ -80,67 +144,91 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    rsp
    +
    +
    rsp +

    (logical)
    vector indicating whether each subject is a responder or not.

    -
    arm
    +
    arm +

    (factor)
    the treatment group variable.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    strata_data
    +
    strata_data +

    (factor, data.frame, or NULL)
    required if stratified analysis is performed.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string or NULL)
    specifies the test used to calculate the p-value for the difference between two proportions. For options, see test_proportion_diff(). Default is NULL so no test is performed.

    -
    + +
    -

    Value

    - -
    • h_proportion_df() returns a data.frame with columns arm, n, n_rsp, and prop.

    • -
    • h_proportion_subgroups_df() returns a data.frame with columns arm, n, n_rsp, prop, subgroup, +

      Value +

      + +
        +
      • h_proportion_df() returns a data.frame with columns arm, n, n_rsp, and prop.

      • +
      +
        +
      • h_proportion_subgroups_df() returns a data.frame with columns arm, n, n_rsp, prop, subgroup, var, var_label, and row_type.

      • -
      • h_odds_ratio_df() returns a data.frame with columns arm, n_tot, or, lcl, ucl, conf_level, and +

      +
        +
      • h_odds_ratio_df() returns a data.frame with columns arm, n_tot, or, lcl, ucl, conf_level, and optionally pval and pval_label.

      • -
      • h_odds_ratio_subgroups_df() returns a data.frame with columns arm, n_tot, or, lcl, ucl, +

      +
        +
      • h_odds_ratio_subgroups_df() returns a data.frame with columns arm, n_tot, or, lcl, ucl, conf_level, subgroup, var, var_label, and row_type.

      • -
    + +
    -

    Details

    +

    Details +

    Main functionality is to prepare data for use in a layout-creating function.

    -

    Functions

    +

    Functions +

    -
    • h_proportion_df(): Helper to prepare a data frame of binary responses by arm.

    • +
        +
      • h_proportion_df(): Helper to prepare a data frame of binary responses by arm.

      • h_proportion_subgroups_df(): Summarizes proportion of binary responses by arm and across subgroups in a data frame. variables corresponds to the names of variables found in data, passed as a named list and requires elements rsp, arm and optionally subgroups. groups_lists optionally specifies @@ -151,10 +239,12 @@

        Functions -

        Examples

        +

        Examples +

        library(dplyr)
         library(forcats)
         
        @@ -356,17 +446,19 @@ 

        Examples

        + +
    - + + - + + diff --git a/main/reference/h_split_by_subgroups.html b/main/reference/h_split_by_subgroups.html index 6ed97cd45d..97828447dc 100644 --- a/main/reference/h_split_by_subgroups.html +++ b/main/reference/h_split_by_subgroups.html @@ -1,7 +1,30 @@ - -Split data frame by subgroups — h_split_by_subgroups • tern + + + + + + +Split data frame by subgroups — h_split_by_subgroups • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,41 +117,51 @@
    -

    Usage

    +

    Usage +

    h_split_by_subgroups(data, subgroups, groups_lists = list())
    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    dataset to split.

    -
    subgroups
    +
    subgroups +

    (character)
    names of factor variables from data used to create subsets. Unused levels not present in data are dropped. Note that the order in this vector determines the order in the downstream table.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    + +
    -

    Value

    +

    Value +

    A list with subset data (df) and metadata about the subset (df_labels).

    -

    Details

    +

    Details +

    Main functionality is to prepare data for use in forest plot layouts.

    -

    Examples

    +

    Examples +

    df <- data.frame(
       x = c(1:5),
       y = factor(c("A", "B", "A", "B", "A"), levels = c("A", "B", "C")),
    @@ -195,17 +268,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_split_param.html b/main/reference/h_split_param.html index 3770778a3c..b37c659528 100644 --- a/main/reference/h_split_param.html +++ b/main/reference/h_split_param.html @@ -1,11 +1,34 @@ - -Split parameters — h_split_param • tern + + + + + +Split parameters — h_split_param • tern + + + + + + + + + + + + + +specific analysis function."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,33 +123,42 @@
    -

    Usage

    +

    Usage +

    h_split_param(param, value, f)
    -

    Arguments

    +

    Arguments +

    -
    param
    +
    +
    param +

    (vector)
    the parameter to be split.

    -
    value
    +
    value +

    (vector)
    the value used to split.

    -
    f
    +
    f +

    (list)
    the reference to make the split.

    -
    + +
    -

    Value

    +

    Value +

    A named list with the same element names as f, each containing the elements specified in .stats.

    -

    Examples

    +

    Examples +

    f <- list(
       surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci"),
       surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval")
    @@ -127,17 +199,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_stack_by_baskets.html b/main/reference/h_stack_by_baskets.html index a9abe5cfb6..e6d666482c 100644 --- a/main/reference/h_stack_by_baskets.html +++ b/main/reference/h_stack_by_baskets.html @@ -1,13 +1,36 @@ - -Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets • tern + + + + + +Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets • tern + + + + + + + + + + + + + +done with df_explicit_na() to have the desired output."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    h_stack_by_baskets(
       df,
       baskets = grep("^(SMQ|CQ).+NAM$", names(df), value = TRUE),
    @@ -75,43 +139,54 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    baskets
    +
    baskets +

    (character)
    variable names of the selected Standardized/Customized queries.

    -
    smq_varlabel
    +
    smq_varlabel +

    (string)
    a label for the new variable created.

    -
    keys
    +
    keys +

    (character)
    names of the key variables to be returned along with the new variable created.

    -
    aag_summary
    +
    aag_summary +

    (data.frame)
    containing the SMQ baskets and the levels of interest for the final SMQ variable. This is useful when there are some levels of interest that are not observed in the df dataset. The two columns of this dataset should be named basket and basket_name.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    + +
    -

    Value

    +

    Value +

    A data.frame with variables in keys taken from df and new variable SMQ containing records belonging to the baskets selected via the baskets argument.

    -

    Examples

    +

    Examples +

    adae <- tern_ex_adae[1:20, ] %>% df_explicit_na()
     h_stack_by_baskets(df = adae)
     #> # A tibble: 8 × 6
    @@ -173,17 +248,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_step.html b/main/reference/h_step.html index d753b40f93..61c0dcc5f0 100644 --- a/main/reference/h_step.html +++ b/main/reference/h_step.html @@ -1,7 +1,30 @@ - -Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step • tern + + + + + + +Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_step_window(x, control = control_step())
     
     h_step_trt_effect(data, model, variables, x)
    @@ -83,57 +147,82 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    biomarker value(s) to use (without NA).

    -
    control
    +
    control +

    (named list)
    output from control_step().

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    model
    +
    model +

    (coxph or glm)
    the regression model object.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    formula
    +
    formula +

    (formula)
    the regression model formula.

    -
    subset
    +
    subset +

    (logical)
    subset vector.

    -
    + +
    -

    Value

    +

    Value +

    -
    • h_step_window() returns a list containing the window-selection matrix sel +

        +
      • h_step_window() returns a list containing the window-selection matrix sel and the interval information matrix interval.

      • -
      • h_step_trt_effect() returns a vector with elements est and se.

      • -
      • h_step_survival_formula() returns a model formula.

      • -
      • h_step_survival_est() returns a matrix of number of observations n, +

      +
        +
      • h_step_trt_effect() returns a vector with elements est and se.

      • +
      +
        +
      • h_step_survival_formula() returns a model formula.

      • +
      +
        +
      • h_step_survival_est() returns a matrix of number of observations n, events, log hazard ratio estimates loghr, standard error se, and Wald confidence interval bounds ci_lower and ci_upper. One row is included for each biomarker value in x.

      • -
      • h_step_rsp_formula() returns a model formula.

      • -
      • h_step_rsp_est() returns a matrix of number of observations n, log odds +

      +
        +
      • h_step_rsp_formula() returns a model formula.

      • +
      +
        +
      • h_step_rsp_est() returns a matrix of number of observations n, log odds ratio estimates logor, standard error se, and Wald confidence interval bounds ci_lower and ci_upper. One row is included for each biomarker value in x.

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • h_step_window(): Creates the windows for STEP, based on the control settings +

        +
      • h_step_window(): Creates the windows for STEP, based on the control settings provided.

      • h_step_trt_effect(): Calculates the estimated treatment effect estimate on the linear predictor scale and corresponding standard error from a STEP model fitted @@ -148,20 +237,23 @@

        Functions

    + + - + + - + + diff --git a/main/reference/h_survival_biomarkers_subgroups.html b/main/reference/h_survival_biomarkers_subgroups.html index b98e6b2c33..f101cd38ca 100644 --- a/main/reference/h_survival_biomarkers_subgroups.html +++ b/main/reference/h_survival_biomarkers_subgroups.html @@ -1,9 +1,32 @@ - -Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups • tern + + + + + +Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups • tern + + + + + + + + + + + + + +when reading about the user-facing functions."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    h_surv_to_coxreg_variables(variables, biomarker)
     
     h_coxreg_mult_cont_df(variables, data, control = control_coxreg())
    @@ -73,72 +137,98 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    variables
    +
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    biomarker
    +
    biomarker +

    (string)
    the name of the biomarker variable.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    control
    +
    control +

    (list)
    a list of parameters as returned by the helper function control_coxreg().

    -
    df
    +
    df +

    (data.frame)
    results for a single biomarker, as part of what is returned by extract_survival_biomarkers() (it needs a couple of columns which are added by that high-level function relative to what is returned by h_coxreg_mult_cont_df(), see the example).

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n_tot_events: Total number of events per group.

    • +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n_tot_events: Total number of events per group.

      • n_tot: Total number of observations per group.

      • median: Median survival time.

      • hr: Hazard ratio.

      • ci: Confidence interval of hazard ratio.

      • pval: p-value of the effect. Note, one of the statistics n_tot and n_tot_events, as well as both hr and ci are required.

      • -
      +
    +
    -
    time_unit
    +
    time_unit +

    (string)
    label with unit of median survival time. Default NULL skips displaying unit.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    + +
    -

    Value

    +

    Value +

    -
    • h_surv_to_coxreg_variables() returns a named list of elements time, event, arm, +

        +
      • h_surv_to_coxreg_variables() returns a named list of elements time, event, arm, covariates, and strata.

      • -
      • h_coxreg_mult_cont_df() returns a data.frame containing estimates and statistics for the selected biomarkers.

      • -
      • h_tab_surv_one_biomarker() returns an rtables table object with the given statistics arranged in columns.

      • -
    + +
      +
    • h_coxreg_mult_cont_df() returns a data.frame containing estimates and statistics for the selected biomarkers.

    • +
    +
      +
    • h_tab_surv_one_biomarker() returns an rtables table object with the given statistics arranged in columns.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • h_surv_to_coxreg_variables(): Helps with converting the "survival" function variable list +

    - + + - + + diff --git a/main/reference/h_survival_duration_subgroups.html b/main/reference/h_survival_duration_subgroups.html index 2dc22a827e..2ebadec337 100644 --- a/main/reference/h_survival_duration_subgroups.html +++ b/main/reference/h_survival_duration_subgroups.html @@ -1,9 +1,32 @@ - -Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups • tern + + + + + +Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups • tern + + + + + + + + + + + + + +time and hazard ratio for population subgroups."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    h_survtime_df(tte, is_event, arm)
     
     h_survtime_subgroups_df(
    @@ -79,73 +143,101 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    tte
    +
    +
    tte +

    (numeric)
    vector of time-to-event duration values.

    -
    is_event
    +
    is_event +

    (flag)
    TRUE if event, FALSE if time to event is censored.

    -
    arm
    +
    arm +

    (factor)
    the treatment group variable.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    data
    +
    data +

    (data.frame)
    the dataset containing the variables to summarize.

    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    label_all
    +
    label_all +

    (string)
    label for the total population analysis.

    -
    strata_data
    +
    strata_data +

    (factor, data.frame, or NULL)
    required if stratified analysis is performed.

    -
    control
    -

    (list)
    parameters for comparison details, specified by using the helper function -control_coxph(). Some possible parameter options are:

    • pval_method (string)
      p-value method for testing the null hypothesis that hazard ratio = 1. Default +

      control +
      +
      +

      (list)
      parameters for comparison details, specified by using the helper function +control_coxph(). Some possible parameter options are:

      +
        +
      • pval_method (string)
        p-value method for testing the null hypothesis that hazard ratio = 1. Default method is "log-rank" which comes from survival::survdiff(), can also be set to "wald" or "likelihood" (from survival::coxph()).

      • ties (string)
        specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in survival::coxph().

      • conf_level (proportion)
        confidence level of the interval for HR.

      • -
      +
    +
    -
    + +
    -

    Value

    - -
    • h_survtime_df() returns a data.frame with columns arm, n, n_events, and median.

    • -
    • h_survtime_subgroups_df() returns a data.frame with columns arm, n, n_events, median, subgroup, +

      Value +

      + +
        +
      • h_survtime_df() returns a data.frame with columns arm, n, n_events, and median.

      • +
      +
        +
      • h_survtime_subgroups_df() returns a data.frame with columns arm, n, n_events, median, subgroup, var, var_label, and row_type.

      • -
      • h_coxph_df() returns a data.frame with columns arm, n_tot, n_tot_events, hr, lcl, ucl, +

      +
        +
      • h_coxph_df() returns a data.frame with columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval and pval_label.

      • -
      • h_coxph_subgroups_df() returns a data.frame with columns arm, n_tot, n_tot_events, hr, +

      +
        +
      • h_coxph_subgroups_df() returns a data.frame with columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, and row_type.

      • -
    + +
    -

    Details

    +

    Details +

    Main functionality is to prepare data for use in a layout-creating function.

    -

    Functions

    +

    Functions +

    -
    • h_survtime_df(): Helper to prepare a data frame of median survival times by arm.

    • +
        +
      • h_survtime_df(): Helper to prepare a data frame of median survival times by arm.

      • h_survtime_subgroups_df(): Summarizes median survival times by arm and across subgroups in a data frame. variables corresponds to the names of variables found in data, passed as a named list and requires elements tte, is_event, arm and optionally subgroups. groups_lists optionally specifies @@ -157,10 +249,12 @@

        Functions -

        Examples

        +

        Examples +

        library(dplyr)
         library(forcats)
         
        @@ -382,17 +476,19 @@ 

        Examples

        + +
    - + + - + + diff --git a/main/reference/h_tab_one_biomarker.html b/main/reference/h_tab_one_biomarker.html index 1ad006123c..44b6e19f3c 100644 --- a/main/reference/h_tab_one_biomarker.html +++ b/main/reference/h_tab_one_biomarker.html @@ -1,9 +1,32 @@ - -Helper function for tabulation of a single biomarker result — h_tab_one_biomarker • tern + + + + + +Helper function for tabulation of a single biomarker result — h_tab_one_biomarker • tern + + + + + + + + + + + + + +This function is a wrapper for rtables::summarize_row_groups()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    h_tab_one_biomarker(
       df,
       afuns,
    @@ -69,51 +133,63 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    results for a single biomarker.

    -
    afuns
    +
    afuns +

    (named list of function)
    analysis functions.

    -
    colvars
    +
    colvars +

    (named list)
    named list with elements vars (variables to tabulate) and labels (their labels).

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    + +
    -

    Value

    +

    Value +

    An rtables table object with statistics in columns.

    + + - + + - + + diff --git a/main/reference/h_tbl_coxph_pairwise.html b/main/reference/h_tbl_coxph_pairwise.html index 7a3bde900f..450111f0e3 100644 --- a/main/reference/h_tbl_coxph_pairwise.html +++ b/main/reference/h_tbl_coxph_pairwise.html @@ -1,7 +1,30 @@ - -Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise • tern + + + + + + +Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    h_tbl_coxph_pairwise(
       df,
       variables,
    @@ -65,49 +129,67 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    variables
    -

    (named list)
    variable names. Details are:

    • tte (numeric)
      variable indicating time-to-event duration values.

    • +
      variables +
      +
      +

      (named list)
      variable names. Details are:

      +
        +
      • tte (numeric)
        variable indicating time-to-event duration values.

      • is_event (logical)
        event variable. TRUE if event, FALSE if time to event is censored.

      • arm (factor)
        the treatment group variable.

      • strata (character or NULL)
        variable names indicating stratification factors.

      • -
      +
    +
    -
    ref_group_coxph
    +
    ref_group_coxph +

    (string or NULL)
    level of arm variable to use as reference group in calculations for annot_coxph table. If NULL (default), uses the first level of the arm variable.

    -
    control_coxph_pw
    -

    (list)
    parameters for comparison details, specified using the helper function -control_coxph(). Some possible parameter options are:

    • pval_method (string)
      p-value method for testing hazard ratio = 1. +

      control_coxph_pw +
      +
      +

      (list)
      parameters for comparison details, specified using the helper function +control_coxph(). Some possible parameter options are:

      +
        +
      • pval_method (string)
        p-value method for testing hazard ratio = 1. Default method is "log-rank", can also be set to "wald" or "likelihood".

      • ties (string)
        method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in survival::coxph()

      • conf_level (proportion)
        confidence level of the interval for HR.

      • -
      +
    +
    -
    annot_coxph_ref_lbls
    +
    annot_coxph_ref_lbls +

    (flag)
    whether the reference group should be explicitly printed in labels for the annot_coxph table. If FALSE (default), only comparison groups will be printed in annot_coxph table labels.

    -
    + +
    -

    Value

    +

    Value +

    A data.frame containing statistics HR, XX% CI (XX taken from control_coxph_pw), and p-value (log-rank).

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte <- tern_ex_adtte %>%
    @@ -126,17 +208,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_tbl_median_surv.html b/main/reference/h_tbl_median_surv.html index 4ca7ee3347..caff32adea 100644 --- a/main/reference/h_tbl_median_surv.html +++ b/main/reference/h_tbl_median_surv.html @@ -1,7 +1,30 @@ - -Helper function for survival estimations — h_tbl_median_surv • tern + + + + + + +Helper function for survival estimations — h_tbl_median_surv • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,29 +117,37 @@
    -

    Usage

    +

    Usage +

    h_tbl_median_surv(fit_km, armval = "All")
    -

    Arguments

    +

    Arguments +

    -
    fit_km
    +
    +
    fit_km +

    (survfit)
    result of survival::survfit().

    -
    armval
    +
    armval +

    (string)
    used as strata name when treatment arm variable only has one level. Default is "All".

    -
    + +
    -

    Value

    +

    Value +

    A summary table with statistics N, Median, and XX% CI (XX taken from fit_km).

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(survival)
     
    @@ -94,17 +165,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_worsen_counter.html b/main/reference/h_worsen_counter.html index fe3321a80a..1c949f4600 100644 --- a/main/reference/h_worsen_counter.html +++ b/main/reference/h_worsen_counter.html @@ -1,11 +1,34 @@ - -Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter • tern + + + + + +Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter • tern + + + + + + + + + + + + + +and the direction of interest specified in direction_var."> + + + + + Skip to contents @@ -21,33 +44,74 @@ + +
    @@ -60,52 +124,68 @@
    -

    Usage

    +

    Usage +

    h_worsen_counter(df, id, .var, baseline_var, direction_var)
    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    id
    +
    id +

    (string)
    subject variable name.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    baseline_var
    +
    baseline_var +

    (string)
    name of the baseline lab grade variable.

    -
    direction_var
    -

    (string)
    name of the direction variable specifying the direction of the shift table of -interest. Only lab records flagged by L, H or B are included in the shift table.

    • L: low direction only

    • +
      direction_var +
      +
      +

      (string)
      name of the direction variable specifying the direction of the shift table of +interest. Only lab records flagged by L, H or B are included in the shift table.

      +
        +
      • L: low direction only

      • H: high direction only

      • B: both low and high directions

      • -
      +
    +
    -
    + +
    -

    Value

    +

    Value +

    The counts and fraction of patients whose worst post-baseline lab grades are worse than their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # The direction variable, GRADDR, is based on metadata
    @@ -160,17 +240,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/h_xticks.html b/main/reference/h_xticks.html index 300cebead6..9fbc3350bb 100644 --- a/main/reference/h_xticks.html +++ b/main/reference/h_xticks.html @@ -1,11 +1,34 @@ - -Helper function to calculate x-tick positions — h_xticks • tern + + + + + +Helper function to calculate x-tick positions — h_xticks • tern + + + + + + + + + + + + + +and is required in the graphic and the patient-at-risk annotation table."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,36 +123,45 @@
    -

    Usage

    +

    Usage +

    h_xticks(data, xticks = NULL, max_time = NULL)
    -

    Arguments

    +

    Arguments +

    -
    data
    +
    +
    data +

    (data.frame)
    survival data as pre-processed by h_data_plot.

    -
    xticks
    +
    xticks +

    (numeric or NULL)
    numeric vector of tick positions or a single number with spacing between ticks on the x-axis. If NULL (default), labeling::extended() is used to determine optimal tick positions on the x-axis.

    -
    max_time
    +
    max_time +

    (numeric(1))
    maximum value to show on x-axis. Only data values less than or up to this threshold value will be plotted (defaults to NULL).

    -
    + +
    -

    Value

    +

    Value +

    A vector of positions to use for x-axis ticks on a ggplot object.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(survival)
     
    @@ -114,17 +186,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/imputation_rule.html b/main/reference/imputation_rule.html index c4f12ad5e9..9a1a0ea517 100644 --- a/main/reference/imputation_rule.html +++ b/main/reference/imputation_rule.html @@ -1,5 +1,28 @@ - -Apply 1/3 or 1/2 imputation rule to data — imputation_rule • tern + + + + + + +Apply 1/3 or 1/2 imputation rule to data — imputation_rule • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    imputation_rule(
       df,
       x_stats,
    @@ -63,51 +127,63 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    x_stats
    +
    x_stats +

    (named list)
    a named list of statistics, typically the results of s_summary().

    -
    stat
    +
    stat +

    (string)
    statistic to return the value/NA level of according to the imputation rule applied.

    -
    imp_rule
    +
    imp_rule +

    (string)
    imputation rule setting. Set to "1/3" to implement 1/3 imputation rule or "1/2" to implement 1/2 imputation rule.

    -
    post
    +
    post +

    (flag)
    whether the data corresponds to a post-dose time-point (defaults to FALSE). This parameter is only used when imp_rule is set to "1/3".

    -
    avalcat_var
    +
    avalcat_var +

    (string)
    name of variable that indicates whether a row in df corresponds to an analysis value in category "BLQ", "LTR", "<PCLLOQ", or none of the above (defaults to "AVALCAT1"). Variable avalcat_var must be present in df.

    -
    + +
    -

    Value

    +

    Value +

    A list containing statistic value (val) and NA level (na_str) that should be displayed according to the specified imputation rule.

    -

    See also

    +

    See also +

    analyze_vars_in_cols() where this function can be implemented by setting the imp_rule argument.

    -

    Examples

    +

    Examples +

    set.seed(1)
     df <- data.frame(
       AVAL = runif(50, 0, 1),
    @@ -140,17 +216,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/incidence_rate.html b/main/reference/incidence_rate.html index 03e948eb04..655fd73f63 100644 --- a/main/reference/incidence_rate.html +++ b/main/reference/incidence_rate.html @@ -1,13 +1,36 @@ - -Incidence rate estimation — incidence_rate • tern + + + + + +Incidence rate estimation — incidence_rate • tern + + + + + + + + + + + + + +a value of 1 means an event was observed and 0 means that no event was observed) must also be specified."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    estimate_incidence_rate(
       lyt,
       vars,
    @@ -111,144 +175,190 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    n_events
    +
    n_events +

    (string)
    name of integer variable indicating whether an event has been observed (1) or not (0).

    -
    id_var
    +
    id_var +

    (string)
    name of variable used as patient identifier if "n_unique" is included in .stats. Defaults to "USUBJID".

    -
    control
    -

    (list)
    parameters for estimation details, specified by using -the helper function control_incidence_rate(). Possible parameter options are:

    • conf_level (proportion)
      confidence level for the estimated incidence rate.

    • +
      control +
      +
      +

      (list)
      parameters for estimation details, specified by using +the helper function control_incidence_rate(). Possible parameter options are:

      +
        +
      • conf_level (proportion)
        confidence level for the estimated incidence rate.

      • conf_type (string)
        normal (default), normal_log, exact, or byar for confidence interval type.

      • input_time_unit (string)
        day, week, month, or year (default) indicating time unit for data input.

      • num_pt_year (numeric)
        time unit for desired output (in person-years).

      • -
      +
    +
    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    summarize
    +
    summarize +

    (flag)
    whether the function should act as an analyze function (summarize = FALSE), or a summarize function (summarize = TRUE). Defaults to FALSE.

    -
    label_fmt
    +
    label_fmt +

    (string)
    how labels should be formatted after a row split occurs if summarize = TRUE. The string should use "%s" to represent row split levels, and "%.labels" to represent labels supplied to the .labels argument. Defaults to "%s - %.labels".

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'person_years', 'n_events', 'rate', 'rate_ci', 'n_unique', 'n_rate'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'person_years', 'n_events', 'rate', 'rate_ci', 'n_unique', 'n_rate'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    is_event
    +
    is_event +

    (flag)
    TRUE if event, FALSE if time to event is censored.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    + +
    -

    Value

    +

    Value +

    -
    • estimate_incidence_rate() returns a layout object suitable for passing to further layouting functions, +

        +
      • estimate_incidence_rate() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_incidence_rate() to the table layout.

      • -
      • s_incidence_rate() returns the following statistics:

        • person_years: Total person-years at risk.

        • +
        +
          +
        • +

          s_incidence_rate() returns the following statistics:

          +
            +
          • person_years: Total person-years at risk.

          • n_events: Total number of events observed.

          • rate: Estimated incidence rate.

          • rate_ci: Confidence interval for the incidence rate.

          • n_unique: Total number of patients with at least one event observed.

          • n_rate: Total number of events observed & estimated incidence rate.

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • estimate_incidence_rate(): Layout-creating function which can take statistics function arguments +

        +
      • estimate_incidence_rate(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_incidence_rate(): Statistics function which estimates the incidence rate and the associated confidence interval.

      • a_incidence_rate(): Formatted analysis function which is used as afun in estimate_incidence_rate().

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    df <- data.frame(
       USUBJID = as.character(seq(6)),
       CNSR = c(0, 1, 1, 0, 0, 0),
    @@ -325,17 +435,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/index.html b/main/reference/index.html index 88fff3cd0b..0e15867a93 100644 --- a/main/reference/index.html +++ b/main/reference/index.html @@ -1,5 +1,26 @@ - -Package index • tern + + + + + + +Package index • tern + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +36,66 @@ + + @@ -45,1350 +106,1806 @@
    -

    Overview Pages

    +

    Overview Pages +

    -
    +
    +
    -
    +
    +
    tern tern-package
    tern Package
    -
    +
    +
    +
    analyze_functions
    Analyze functions
    -
    +
    +
    +
    analyze_colvars_functions
    Analyze functions in columns
    -
    +
    +
    +
    summarize_functions
    Summarize functions
    -
    +
    +
    +
    formatting_functions
    Formatting functions
    -
    -

    Analysis Functions

    - -

    Analyze functions with their corresponding statistics functions and formatted analysis functions.

    • Analyze functions are used in combination with rtables layout functions in the pipeline which creates the table.

    • + +
    +
    +

    Analysis Functions +

    + +
    +

    Analyze functions with their corresponding statistics functions and formatted analysis functions.

    +
      +
    • Analyze functions are used in combination with rtables layout functions in the pipeline which creates the table.

    • Statistics functions (denoted by s_ prefix) compute the numbers that are tabulated later. In order to separate computation from formatting, they do not take care of rcell type formatting themselves.

    • Formatted analysis functions (denoted by a_ prefix) have the same arguments as the corresponding statistics functions, and can be further customized by calling rtables::make_afun() on them. They are used as afun in rtables::analyze().

    • -
    + +
    -
    +
    +
    -
    +
    +
    analyze_vars() s_summary() a_summary() stable
    Analyze variables
    -
    +
    +
    +
    analyze_vars_in_cols() experimental
    Analyze numeric variables in columns
    -
    +
    +
    +
    analyze_num_patients() summarize_num_patients() s_num_patients() s_num_patients_content() stable
    Count number of patients
    -
    +
    +
    +
    analyze_patients_exposure_in_cols() summarize_patients_exposure_in_cols() s_count_patients_sum_exposure() a_count_patients_sum_exposure() stable
    Count number of patients and sum exposure across all patients in columns
    -
    +
    +
    +
    compare_vars() s_compare() stable
    Compare variables between groups
    -
    +
    +
    +
    count_abnormal() s_count_abnormal() a_count_abnormal() stable
    Count patients with abnormal range values
    -
    +
    +
    +
    count_abnormal_by_baseline() s_count_abnormal_by_baseline() a_count_abnormal_by_baseline() stable
    Count patients with abnormal analysis range values by baseline status
    -
    +
    +
    +
    count_abnormal_by_marked() s_count_abnormal_by_marked() a_count_abnormal_by_marked() stable
    Count patients with marked laboratory abnormalities
    -
    +
    +
    +
    count_abnormal_by_worst_grade() s_count_abnormal_by_worst_grade() a_count_abnormal_by_worst_grade() stable
    Count patients by most extreme post-baseline toxicity grade per direction of abnormality
    -
    +
    +
    +
    count_abnormal_lab_worsen_by_baseline() s_count_abnormal_lab_worsen_by_baseline() a_count_abnormal_lab_worsen_by_baseline() stable
    Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline
    -
    +
    +
    +
    count_cumulative() s_count_cumulative() a_count_cumulative() stable
    Cumulative counts of numeric variable by thresholds
    -
    +
    +
    +
    count_missed_doses() s_count_nonmissing() s_count_missed_doses() a_count_missed_doses() stable
    Count number of patients with missed doses by thresholds
    -
    +
    +
    +
    count_occurrences() summarize_occurrences() s_count_occurrences() a_count_occurrences() stable
    Count occurrences
    -
    +
    +
    +
    count_occurrences_by_grade() summarize_occurrences_by_grade() s_count_occurrences_by_grade() a_count_occurrences_by_grade() stable
    Count occurrences by grade
    -
    +
    +
    +
    summarize_patients_events_in_cols() s_count_patients_and_multiple_events() stable
    Count patient events in columns
    -
    +
    +
    +
    count_patients_with_event() s_count_patients_with_event() a_count_patients_with_event() stable
    Count the number of patients with a particular event
    -
    +
    +
    +
    count_patients_with_flags() s_count_patients_with_flags() a_count_patients_with_flags() stable
    Count the number of patients with particular flags
    -
    +
    +
    +
    count_values() s_count_values() a_count_values() stable
    Count specific values
    -
    +
    +
    +
    estimate_multinomial_response() s_length_proportion() a_length_proportion() stable
    Estimate proportions of each level of a variable
    -
    +
    +
    +
    estimate_proportion() s_proportion() a_proportion() stable
    Proportion estimation
    -
    +
    +
    +
    estimate_incidence_rate() s_incidence_rate() a_incidence_rate() stable
    Incidence rate estimation
    -
    +
    +
    +
    estimate_odds_ratio() s_odds_ratio() a_odds_ratio() stable
    Odds ratio estimation
    -
    +
    +
    +
    estimate_proportion_diff() s_proportion_diff() a_proportion_diff() stable
    Proportion difference estimation
    -
    +
    +
    +
    s_bland_altman() experimental
    Bland-Altman analysis
    -
    +
    +
    +
    summarize_coxreg() s_coxreg() a_coxreg() stable
    Cox proportional hazards regression
    -
    +
    +
    +
    summarize_ancova() s_ancova() a_ancova() stable
    Summarize analysis of covariance (ANCOVA) results
    -
    +
    +
    +
    summarize_change() s_change_from_baseline() a_change_from_baseline() stable
    Summarize change from baseline values or absolute baseline values
    -
    +
    +
    +
    summarize_colvars() stable
    Summarize variables in columns
    -
    +
    +
    +
    summarize_glm_count() s_glm_count() experimental
    Summarize Poisson negative binomial regression
    -
    +
    +
    +
    summarize_logistic() stable
    Multivariate logistic regression table
    -
    +
    +
    +
    surv_time() s_surv_time() a_surv_time() stable
    Survival time analysis
    -
    +
    +
    +
    surv_timepoint() s_surv_timepoint() a_surv_timepoint() s_surv_timepoint_diff() a_surv_timepoint_diff() stable
    Survival time point analysis
    -
    +
    +
    +
    tabulate_rsp_biomarkers() stable
    Tabulate biomarker effects on binary response by subgroup
    -
    +
    +
    +
    tabulate_rsp_subgroups() a_response_subgroups() stable
    Tabulate binary response by subgroup
    -
    +
    +
    +
    tabulate_survival_biomarkers() stable
    Tabulate biomarker effects on survival by subgroup
    -
    +
    +
    +
    tabulate_survival_subgroups() a_survival_subgroups() stable
    Tabulate survival duration by subgroup
    -
    +
    +
    +
    test_proportion_diff() s_test_proportion_diff() a_test_proportion_diff() stable
    Difference test for two proportions
    -
    -

    Model-Specific Functions

    + +
    +
    +

    Model-Specific Functions +

    These functions help with fitting or extracting results from specific models.

    -
    +
    +
    -
    +
    +
    estimate_coef()
    Hazard ratio estimation in interactions
    -
    +
    +
    +
    extract_rsp_biomarkers() stable
    Prepare response data estimates for multiple biomarkers in a single data frame
    -
    +
    +
    +
    extract_rsp_subgroups() stable
    Prepare response data for population subgroups in data frames
    -
    +
    +
    +
    extract_survival_biomarkers() stable
    Prepare survival data estimates for multiple biomarkers in a single data frame
    -
    +
    +
    +
    extract_survival_subgroups() stable
    Prepare survival data for population subgroups in data frames
    -
    +
    +
    +
    fit_coxreg_univar() fit_coxreg_multivar() stable
    Fitting functions for Cox proportional hazards regression
    -
    +
    +
    +
    fit_logistic() stable
    Fit for logistic regression
    -
    +
    +
    +
    fit_rsp_step() stable
    Subgroup treatment effect pattern (STEP) fit for binary (response) outcome
    -
    +
    +
    +
    fit_survival_step() stable
    Subgroup treatment effect pattern (STEP) fit for survival outcome
    -
    +
    +
    +
    get_smooths() stable
    Smooth function with optional grouping
    -
    +
    +
    +
    logistic_regression_cols() stable
    Logistic regression multivariate column layout function
    -
    +
    +
    +
    logistic_summary_by_flag() stable
    Logistic regression summary table
    -
    +
    +
    +
    tidy(<glm>) stable
    Custom tidy method for binomial GLM results
    -
    +
    +
    +
    tidy(<step>) stable
    Custom tidy method for STEP results
    -
    +
    +
    +
    tidy(<summary.coxph>) tidy(<coxreg.univar>) tidy(<coxreg.multivar>) stable
    Custom tidy methods for Cox regression
    -
    +
    +
    +
    univariate() stable
    Univariate formula special term
    -
    -

    Graphs

    + +
    +
    +

    Graphs +

    These function create graphical type output.

    -
    +
    +
    -
    +
    +
    g_bland_altman() experimental
    Bland-Altman plot
    -
    +
    +
    +
    g_forest() stable
    -
    Create a forest plot from an rtable
    -
    +
    Create a forest plot from an rtable +
    +
    +
    +
    g_ipp() stable
    Individual patient plots
    -
    +
    +
    +
    g_km() stable
    Kaplan-Meier plot
    -
    +
    +
    +
    g_lineplot() stable
    Line plot with optional table
    -
    +
    +
    +
    g_step() stable
    Create a STEP graph
    -
    +
    +
    +
    g_waterfall() stable
    Horizontal waterfall plot
    -
    -

    Control Functions

    + +
    +
    +

    Control Functions +

    These functions capture options in lists and take care of defaults (and checks where applicable). They avoid cluttering of function signatures with long lists of single arguments.

    -
    +
    +
    -
    +
    +
    control_analyze_vars() stable
    Control function for descriptive statistics
    -
    +
    +
    +
    control_surv_med_annot() control_coxph_annot() stable
    Control functions for Kaplan-Meier plot annotation tables
    -
    +
    +
    +
    control_coxph() stable
    Control function for Cox-PH model
    -
    +
    +
    +
    control_coxreg() stable
    Control function for Cox regression
    -
    +
    +
    +
    control_incidence_rate() stable
    Control function for incidence rate
    -
    +
    +
    +
    control_lineplot_vars() stable
    -
    Control function for g_lineplot()
    -
    +
    Control function for g_lineplot() +
    +
    +
    +
    control_logistic() stable
    Control function for logistic regression model fitting
    -
    +
    +
    +
    control_riskdiff() stable
    Control function for risk difference column
    -
    +
    +
    +
    control_step() stable
    Control function for subgroup treatment effect pattern (STEP) calculations
    -
    +
    +
    +
    control_surv_time() stable
    Control function for survfit models for survival time
    -
    +
    +
    +
    control_surv_timepoint() stable
    Control function for survfit models for patients' survival rate at time points
    -
    -

    Analysis Helper Functions

    + +
    +
    +

    Analysis Helper Functions +

    These functions are useful in defining an analysis.

    -
    +
    +
    -
    +
    +
    get_stats() get_formats_from_stats() get_labels_from_stats() get_indents_from_stats() tern_default_stats tern_default_formats tern_default_labels summary_formats() summary_labels() stable
    Get default statistical methods and their associated formats, labels, and indent modifiers
    -
    +
    +
    +
    h_coxreg_inter_effect() h_coxreg_extract_interaction() h_coxreg_inter_estimations() stable
    Cox regression helper function for interactions
    -
    +
    +
    +
    h_get_format_threshold() h_format_threshold() stable
    Format extreme values
    -
    +
    +
    +
    h_adlb_abnormal_by_worst_grade() stable
    -
    Helper function to prepare ADLB for count_abnormal_by_worst_grade()
    -
    +
    Helper function to prepare ADLB for count_abnormal_by_worst_grade() +
    +
    +
    +
    h_adlb_worsen() stable
    Helper function to prepare ADLB with worst labs
    -
    +
    +
    +
    h_adsl_adlb_merge_using_worst_flag() stable
    Helper function for deriving analysis datasets for select laboratory tables
    -
    +
    +
    +
    h_ancova() stable
    Helper function to return results of a linear model
    -
    +
    +
    +
    h_append_grade_groups() stable
    -
    Helper function for s_count_occurrences_by_grade()
    -
    +
    Helper function for s_count_occurrences_by_grade() +
    +
    +
    +
    h_count_cumulative() stable
    -
    Helper function for s_count_cumulative()
    -
    +
    Helper function for s_count_cumulative() +
    +
    +
    +
    h_coxreg_univar_formulas() h_coxreg_multivar_formula() h_coxreg_univar_extract() h_coxreg_multivar_extract() stable
    Helper functions for Cox proportional hazards regression
    -
    +
    +
    +
    h_decompose_gg() deprecated
    -
    ggplot decomposition
    -
    +
    +ggplot decomposition
    +
    +
    +
    h_format_row() stable
    Helper function to format the optional g_lineplot table
    -
    +
    +
    +
    h_ggkm() deprecated
    Helper function to create a KM plot
    -
    +
    +
    +
    h_km_layout() deprecated
    Helper function to prepare a KM layout
    -
    +
    +
    +
    h_get_interaction_vars() h_interaction_coef_name() h_or_cat_interaction() h_or_cont_interaction() h_or_interaction() h_simple_term_labels() h_interaction_term_labels() h_glm_simple_term_extract() h_glm_interaction_extract() h_glm_inter_term_extract() h_logistic_simple_terms() h_logistic_inter_terms() stable
    Helper functions for multivariate logistic regression
    -
    +
    +
    +
    h_map_for_count_abnormal() stable
    -
    Helper function to create a map data frame for trim_levels_to_map()
    -
    +
    Helper function to create a map data frame for trim_levels_to_map() +
    +
    +
    +
    or_glm() or_clogit() stable
    Helper functions for odds ratio estimation
    -
    +
    +
    +
    h_pkparam_sort() stable
    Sort pharmacokinetic data by PARAM variable
    -
    +
    +
    +
    h_ppmeans()
    Function to return the estimated means using predicted probabilities
    -
    +
    +
    +
    prop_diff_wald() prop_diff_ha() prop_diff_nc() prop_diff_cmh() prop_diff_strat_nc() stable
    Helper functions to calculate proportion difference
    -
    +
    +
    +
    prop_wilson() prop_strat_wilson() prop_clopper_pearson() prop_wald() prop_agresti_coull() prop_jeffreys() stable
    Helper functions for calculating proportion confidence intervals
    -
    +
    +
    +
    h_rsp_to_logistic_variables() h_logistic_mult_cont_df() h_tab_rsp_one_biomarker() stable
    Helper functions for tabulating biomarker effects on binary response by subgroup
    -
    +
    +
    +
    h_proportion_df() h_proportion_subgroups_df() h_odds_ratio_df() h_odds_ratio_subgroups_df() stable
    Helper functions for tabulating binary response by subgroup
    -
    +
    +
    +
    h_split_by_subgroups() stable
    Split data frame by subgroups
    -
    +
    +
    +
    h_split_param() stable
    Split parameters
    -
    +
    +
    +
    h_stack_by_baskets() stable
    Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records.
    -
    +
    +
    +
    h_step_window() h_step_trt_effect() h_step_survival_formula() h_step_survival_est() h_step_rsp_formula() h_step_rsp_est() stable
    Helper functions for subgroup treatment effect pattern (STEP) calculations
    -
    +
    +
    +
    h_surv_to_coxreg_variables() h_coxreg_mult_cont_df() h_tab_surv_one_biomarker() stable
    Helper functions for tabulating biomarker effects on survival by subgroup
    -
    +
    +
    +
    h_survtime_df() h_survtime_subgroups_df() h_coxph_df() h_coxph_subgroups_df() stable
    Helper functions for tabulating survival duration by subgroup
    -
    +
    +
    +
    h_tab_one_biomarker() stable
    Helper function for tabulation of a single biomarker result
    -
    +
    +
    +
    h_tbl_coxph_pairwise() stable
    Helper function for generating a pairwise Cox-PH table
    -
    +
    +
    +
    h_tbl_median_surv() stable
    Helper function for survival estimations
    -
    +
    +
    +
    h_worsen_counter() stable
    -
    Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline()
    -
    +
    Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() +
    +
    +
    +
    imputation_rule() stable
    Apply 1/3 or 1/2 imputation rule to data
    -
    +
    +
    +
    labels_use_control() stable
    Update labels according to control specifications
    -
    -

    rtables Helper Functions

    + +
    +
    +

    rtables Helper Functions +

    These functions help to work with the rtables package and may be moved there later.

    -
    +
    +
    -
    +
    +
    add_riskdiff() stable
    Split function to configure risk difference column
    -
    +
    +
    +
    add_rowcounts() stable
    Layout-creating function to add row total counts
    -
    +
    +
    +
    append_varlabels() stable
    Add variable labels to top left corner in table
    -
    +
    +
    +
    default_na_str() set_default_na_str() stable
    Default string replacement for NA values
    -
    +
    +
    +
    as.rtable() stable
    -
    Convert to rtable
    -
    +
    Convert to rtable +
    +
    +
    +
    combine_counts()
    Combine counts
    -
    +
    +
    +
    combine_groups() stable
    Reference and treatment group combination
    -
    +
    +
    +
    combine_levels() stable
    Combine factor levels
    -
    +
    +
    +
    combine_vectors()
    Element-wise combination of two vectors
    -
    +
    +
    +
    h_col_indices() stable
    Obtain column indices
    -
    +
    +
    +
    h_row_first_values() h_row_counts() h_row_fractions() h_col_counts() h_content_first_row() is_leaf_table() check_names_indices() stable
    -
    Helper functions for accessing information from rtables
    -
    +
    Helper functions for accessing information from rtables +
    +
    +
    +
    rtable2gg() experimental
    Convert rtable objects to ggplot objects
    -
    +
    +
    +
    split_cols_by_groups() stable
    Split columns by groups of levels
    -
    +
    +
    +
    to_string_matrix() stable
    Convert table into matrix of strings
    -
    +
    +
    +
    groups_list_to_df()
    Convert list of groups to a data frame
    -
    +
    +
    +
    ref_group_position() level_order() stable
    Custom split functions
    -
    -

    rtables Formatting Functions

    + +
    +
    +

    rtables Formatting Functions +

    These functions provide customized formatting rules to work with the rtables package.

    -
    +
    +
    -
    +
    +
    format_auto() stable
    Format automatically using data significant digits
    -
    +
    +
    +
    format_count_fraction() stable
    Format count and fraction
    -
    +
    +
    +
    format_count_fraction_fixed_dp() experimental
    Format count and percentage with fixed single decimal place
    -
    +
    +
    +
    format_count_fraction_lt10() stable
    Format count and fraction with special case for count < 10
    -
    +
    +
    +
    format_extreme_values() stable
    Format a single extreme value
    -
    +
    +
    +
    format_extreme_values_ci() stable
    Format extreme values part of a confidence interval
    -
    +
    +
    +
    format_fraction() stable
    Format fraction and percentage
    -
    +
    +
    +
    format_fraction_fixed_dp() stable
    Format fraction and percentage with fixed single decimal place
    -
    +
    +
    +
    format_fraction_threshold() stable
    Format fraction with lower threshold
    -
    +
    +
    +
    format_sigfig()
    Format numeric values by significant figures
    -
    +
    +
    +
    format_xx()
    Format XX as a formatting function
    -
    -

    rtables Scoring Functions

    + +
    +
    +

    rtables Scoring Functions +

    These functions can help with table sorting.

    -
    +
    +
    -

    rtables Pruning Functions

    + +
    +
    +

    rtables Pruning Functions +

    These functions and classes help with flexible pruning of tables.

    -
    +
    +
    -

    Graph Helper Functions

    + +
    +
    +

    Graph Helper Functions +

    These functions are useful to modify graphs.

    -
    +
    +
    -
    +
    +
    decorate_grob() stable
    Add titles, footnotes, page Number, and a bounding box to a grid grob
    -
    +
    +
    +
    split_text_grob()
    Split text according to available text width
    -
    +
    +
    +
    decorate_grob_factory()
    Update page number
    -
    +
    +
    +
    decorate_grob_set() stable
    Decorate set of grobs and add page numbering
    -
    +
    +
    +
    h_g_ipp() stable
    Helper function to create simple line plot over time
    -
    +
    +
    +
    h_xticks() stable
    Helper function to calculate x-tick positions
    -
    -

    Data Helper Functions

    + +
    +
    +

    Data Helper Functions +

    These functions are used by other functions to derive data.

    -
    +
    +
    -
    +
    +
    aesi_label() stable
    Labels for adverse event baskets
    -
    +
    +
    +
    as_factor_keep_attributes()
    Conversion of a vector to a factor
    -
    +
    +
    +
    bins_percent_labels()
    Labels for bins in percent
    -
    +
    +
    +
    combine_levels() stable
    Combine factor levels
    -
    +
    +
    +
    cut_quantile_bins() stable
    Cut numeric vector into empirical quantile bins
    -
    +
    +
    +
    day2month()
    Conversion of days to months
    -
    +
    +
    +
    df_explicit_na() stable
    Encode categorical missing values in a data frame
    -
    +
    +
    +
    d_count_abnormal_by_baseline() stable
    -
    Description function for s_count_abnormal_by_baseline()
    -
    +
    Description function for s_count_abnormal_by_baseline() +
    +
    +
    +
    d_count_cumulative() stable
    Description of cumulative count
    -
    +
    +
    +
    d_count_missed_doses() stable
    -
    Description function that calculates labels for s_count_missed_doses()
    -
    +
    Description function that calculates labels for s_count_missed_doses() +
    +
    +
    +
    d_onco_rsp_label() stable
    Description of standard oncology response
    -
    +
    +
    +
    d_pkparam() stable
    Generate PK reference dataset
    -
    +
    +
    +
    d_proportion() stable
    Description of the proportion summary
    -
    +
    +
    +
    d_proportion_diff() stable
    Description of method used for proportion comparison
    -
    +
    +
    +
    d_rsp_subgroups_colvars() stable
    Labels for column variables in binary response by subgroup table
    -
    +
    +
    +
    d_survival_subgroups_colvars() stable
    Labels for column variables in survival duration by subgroup table
    -
    +
    +
    +
    d_test_proportion_diff() stable
    Description of the difference test between two proportions
    -
    +
    +
    +
    explicit_na() stable
    Missing data
    -
    +
    +
    +
    fct_collapse_only() stable
    Collapse factor levels and keep only those new group levels
    -
    +
    +
    +
    fct_discard() stable
    Discard specified levels of a factor
    -
    +
    +
    +
    fct_explicit_na_if() stable
    Insertion of explicit missing values in a factor
    -
    +
    +
    +
    f_conf_level() stable
    Utility function to create label for confidence interval
    -
    +
    +
    +
    f_pval() stable
    Utility function to create label for p-value
    -
    +
    +
    +
    h_data_plot() stable
    Helper function to tidy survival fit data
    -
    +
    +
    +
    month2day() stable
    Conversion of months to days
    -
    +
    +
    +
    reapply_varlabels()
    Reapply variable labels
    -
    +
    +
    +
    sas_na() stable
    -
    Convert strings to NA
    -
    +
    Convert strings to NA +
    +
    +
    +
    stat_mean_ci() stable
    Confidence interval for mean
    -
    +
    +
    +
    stat_mean_pval() stable
    p-Value of the mean
    -
    +
    +
    +
    stat_median_ci() stable
    Confidence interval for median
    -
    +
    +
    +
    stat_propdiff_ci() stable
    Proportion difference and confidence interval
    -
    +
    +
    +
    strata_normal_quantile() stable
    Helper function for the estimation of stratified quantiles
    -
    +
    +
    +
    to_n() stable
    Replicate entries of a vector if required
    -
    +
    +
    +
    update_weights_strat_wilson() stable
    -
    Helper function for the estimation of weights for prop_strat_wilson()
    -
    -

    Assertion Functions

    +
    Helper function for the estimation of weights for prop_strat_wilson() +
    + +
    +
    +

    Assertion Functions +

    These functions supplement those in the checkmate package.

    -
    +
    +
    -

    Data

    +
    Additional assertions to use with checkmate +
    + +
    +
    +

    Data +

    Data included in the package.

    -
    +
    +
    -
    +
    +
    tern_ex_adsl tern_ex_adae tern_ex_adlb tern_ex_adpp tern_ex_adrs tern_ex_adtte
    Simulated CDISC data for examples
    -
    -

    Deprecated Functions

    + +
    +
    +

    Deprecated Functions +

    Functions that are currently deprecated within tern.

    -
    +
    +
    -
    +
    +
    forest_viewport() deprecated
    Create a viewport tree for the forest plot
    -
    +
    +
    +
    h_decompose_gg() deprecated
    -
    ggplot decomposition
    -
    +
    +ggplot decomposition
    +
    +
    +
    h_ggkm() deprecated
    Helper function to create a KM plot
    -
    +
    +
    +
    h_grob_coxph() deprecated
    Helper function to create Cox-PH grobs
    -
    +
    +
    +
    h_grob_median_surv() deprecated
    Helper function to create survival estimation grobs
    -
    +
    +
    +
    h_grob_tbl_at_risk() deprecated
    Helper function to create patient-at-risk grobs
    -
    +
    +
    +
    h_grob_y_annot() deprecated
    Helper function to create grid object with y-axis annotation
    -
    +
    +
    +
    h_km_layout() deprecated
    Helper function to prepare a KM layout
    -
    +
    +
    +
    stack_grobs() deprecated
    Stack multiple grobs
    -
    +
    +
    +
    arrange_grobs() deprecated
    Arrange multiple grobs
    -
    +
    +
    +
    draw_grob() deprecated
    -
    Draw grob
    -
    +
    Draw grob +
    + + + + - + + - + + diff --git a/main/reference/labels_or_names.html b/main/reference/labels_or_names.html index 09b25bf52c..29f68a2feb 100644 --- a/main/reference/labels_or_names.html +++ b/main/reference/labels_or_names.html @@ -1,7 +1,30 @@ - -Labels or names of list elements — labels_or_names • tern + + + + + + +Labels or names of list elements — labels_or_names • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,35 +117,43 @@
    -

    Usage

    +

    Usage +

    labels_or_names(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (list)
    a list.

    -
    + +
    -

    Value

    +

    Value +

    A character vector with the labels or names for the list elements.

    + + - + + - + + diff --git a/main/reference/labels_use_control.html b/main/reference/labels_use_control.html index 965b6a272e..aaf81fd4cf 100644 --- a/main/reference/labels_use_control.html +++ b/main/reference/labels_use_control.html @@ -1,13 +1,36 @@ - -Update labels according to control specifications — labels_use_control • tern + +via labels_custom will not be updated regardless of control.'> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,36 +126,45 @@
    -

    Usage

    +

    Usage +

    labels_use_control(labels_default, control, labels_custom = NULL)
    -

    Arguments

    +

    Arguments +

    -
    labels_default
    +
    +
    labels_default +

    (named character)
    a named vector of statistic labels to modify according to the control specifications. Labels that are explicitly defined in labels_custom will not be affected.

    -
    control
    +
    control +

    (named list)
    list of control parameters to apply to adjust default labels.

    -
    labels_custom
    +
    labels_custom +

    (named character)
    named vector of labels that are customized by the user and should not be affected by control.

    -
    + +
    -

    Value

    +

    Value +

    A named character vector of labels with control specifications applied to relevant labels.

    -

    Examples

    +

    Examples +

    control <- list(conf_level = 0.80, quantiles = c(0.1, 0.83), test_mean = 0.57)
     get_labels_from_stats(c("mean_ci", "quantiles", "mean_pval")) %>%
       labels_use_control(control = control)
    @@ -104,17 +176,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/logistic_regression_cols.html b/main/reference/logistic_regression_cols.html index 2cd060db65..aeee17a5ca 100644 --- a/main/reference/logistic_regression_cols.html +++ b/main/reference/logistic_regression_cols.html @@ -1,9 +1,32 @@ - -Logistic regression multivariate column layout function — logistic_regression_cols • tern + + + + + +Logistic regression multivariate column layout function — logistic_regression_cols • tern + + + + + + + + + + + + + +regression results. This function is a wrapper for rtables::split_cols_by_multivar()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,41 +120,50 @@
    -

    Usage

    +

    Usage +

    logistic_regression_cols(lyt, conf_level = 0.95)
    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    +

    Value +

    A layout object suitable for passing to further layouting functions. Adding this function to an rtable layout will split the table into columns corresponding to statistics df, estimate, std_error, odds_ratio, ci, and pvalue.

    + + - + + - + + diff --git a/main/reference/logistic_summary_by_flag.html b/main/reference/logistic_summary_by_flag.html index 9c742767da..9140cfe81d 100644 --- a/main/reference/logistic_summary_by_flag.html +++ b/main/reference/logistic_summary_by_flag.html @@ -1,9 +1,32 @@ - -Logistic regression summary table — logistic_summary_by_flag • tern + + + + + +Logistic regression summary table — logistic_summary_by_flag • tern + + + + + + + + + + + + + +logistic regression results. This function is a wrapper for rtables::summarize_row_groups()."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    logistic_summary_by_flag(
       flag_var,
       na_str = default_na_str(),
    @@ -66,40 +130,49 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    flag_var
    +
    +
    flag_var +

    (string)
    variable name identifying which row should be used in this content function.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    + +
    -

    Value

    +

    Value +

    A content function.

    + + - + + - + + diff --git a/main/reference/make_names.html b/main/reference/make_names.html index 8316e71655..ffffdcb618 100644 --- a/main/reference/make_names.html +++ b/main/reference/make_names.html @@ -1,5 +1,28 @@ - -Make names without dots — make_names • tern + + + + + + +Make names without dots — make_names • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,35 +114,43 @@
    -

    Usage

    +

    Usage +

    make_names(nams)
    -

    Arguments

    +

    Arguments +

    -
    nams
    +
    +
    nams +

    (character)
    vector of original names.

    -
    + +
    -

    Value

    +

    Value +

    A character vector of proper names, which does not use dots in contrast to make.names().

    + + - + + - + + diff --git a/main/reference/month2day.html b/main/reference/month2day.html index d92190d542..55372b1a6e 100644 --- a/main/reference/month2day.html +++ b/main/reference/month2day.html @@ -1,9 +1,32 @@ - -Conversion of months to days — month2day • tern + + + + + +Conversion of months to days — month2day • tern + + + + + + + + + + + + + +considers each month as having an average of 30.4375 days."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,25 +120,32 @@
    -

    Usage

    +

    Usage +

    month2day(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric(1))
    time in months.

    -
    + +
    -

    Value

    +

    Value +

    A numeric vector with the time in days.

    -

    Examples

    +

    Examples +

    x <- c(13.25, 8.15, 1, 2.834)
     month2day(x)
     #> [1] 403.29688 248.06563  30.43750  86.25988
    @@ -83,17 +153,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/muffled_car_anova.html b/main/reference/muffled_car_anova.html index 37fc9a3031..4a17673864 100644 --- a/main/reference/muffled_car_anova.html +++ b/main/reference/muffled_car_anova.html @@ -1,7 +1,30 @@ - -Muffled car::Anova — muffled_car_anova • tern + + + + + + +Muffled car::Anova — muffled_car_anova • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,33 +40,74 @@ + +
    @@ -54,39 +118,48 @@
    -

    Usage

    +

    Usage +

    muffled_car_anova(mod, test_statistic)
    -

    Arguments

    +

    Arguments +

    -
    mod
    +
    +
    mod +

    (coxph)
    Cox regression model fitted by survival::coxph().

    -
    test_statistic
    +
    test_statistic +

    (string)
    the method used for estimation of p.values; wald (default) or likelihood.

    -
    + +
    -

    Value

    +

    Value +

    The output of car::Anova(), with convergence message muffled.

    + + - + + - + + diff --git a/main/reference/n_available.html b/main/reference/n_available.html index cdd112bc8d..f805d73212 100644 --- a/main/reference/n_available.html +++ b/main/reference/n_available.html @@ -1,5 +1,28 @@ - -Number of available (non-missing entries) in a vector — n_available • tern + + + + + + +Number of available (non-missing entries) in a vector — n_available • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,35 +114,43 @@
    -

    Usage

    +

    Usage +

    n_available(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (vector)
    vector in which to count non-missing values.

    -
    + +
    -

    Value

    +

    Value +

    Number of non-missing values.

    + + - + + - + + diff --git a/main/reference/odds_ratio.html b/main/reference/odds_ratio.html index 39693a7ab5..cf96e501b2 100644 --- a/main/reference/odds_ratio.html +++ b/main/reference/odds_ratio.html @@ -1,15 +1,38 @@ - -Odds ratio estimation — odds_ratio • tern + + + + + +Odds ratio estimation — odds_ratio • tern + + + + + + + + + + + + + +If more than two arm levels are present, they can be combined into two groups using the groups_list argument."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    estimate_odds_ratio(
       lyt,
       vars,
    @@ -111,135 +175,175 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    groups_list
    +
    groups_list +

    (named list of character)
    specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    method
    +
    method +

    (string)
    whether to use the correct ("exact") calculation in the conditional likelihood or one of the approximations. See survival::clogit() for details.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'or_ci', 'n_tot'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'or_ci', 'n_tot'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    + +
    -

    Value

    +

    Value +

    -
    • estimate_odds_ratio() returns a layout object suitable for passing to further layouting functions, +

        +
      • estimate_odds_ratio() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_odds_ratio() to the table layout.

      • -
      • s_odds_ratio() returns a named list with the statistics or_ci +

      +
        +
      • s_odds_ratio() returns a named list with the statistics or_ci (containing est, lcl, and ucl) and n_tot.

      • -
    + + +
    -

    Functions

    +

    Functions +

    -
    • estimate_odds_ratio(): Layout-creating function which can take statistics function arguments +

        +
      • estimate_odds_ratio(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_odds_ratio(): Statistics function which estimates the odds ratio between a treatment and a control. A variables list with arm and strata variable names must be passed if a stratified analysis is required.

      • a_odds_ratio(): Formatted analysis function which is used as afun in estimate_odds_ratio().

      • -
    + +
    -

    Note

    +

    Note +

    -
    • This function uses logistic regression for unstratified analyses, and conditional logistic regression for +

        +
      • This function uses logistic regression for unstratified analyses, and conditional logistic regression for stratified analyses. The Wald confidence interval is calculated with the specified confidence level.

      • For stratified analyses, there is currently no implementation for conditional likelihood confidence intervals, therefore the likelihood confidence interval is not available as an option.

      • When vars contains only responders or non-responders no odds ratio estimation is possible so the returned values will be NA.

      • -
    + +
    -

    See also

    +

    See also +

    Relevant helper function h_odds_ratio().

    -

    Examples

    +

    Examples +

    set.seed(12)
     dta <- data.frame(
       rsp = sample(c(TRUE, FALSE), 100, TRUE),
    @@ -315,17 +419,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/prop_diff.html b/main/reference/prop_diff.html index 2a8a7122cf..df5236ec3f 100644 --- a/main/reference/prop_diff.html +++ b/main/reference/prop_diff.html @@ -1,15 +1,38 @@ - -Proportion difference estimation — prop_diff • tern + + + + + +Proportion difference estimation — prop_diff • tern + + + + + + + + + + + + + +strata element of the variables argument."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    estimate_proportion_diff(
       lyt,
       vars,
    @@ -113,127 +177,165 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    method
    +
    method +

    (string)
    the method used for the confidence interval estimation.

    -
    weights_method
    +
    weights_method +

    (string)
    weights method. Can be either "cmh" or "heuristic" and directs the way weights are estimated.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'diff', 'diff_ci'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'diff', 'diff_ci'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    + +
    -

    Value

    +

    Value +

    -
    • estimate_proportion_diff() returns a layout object suitable for passing to further layouting functions, +

        +
      • estimate_proportion_diff() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_proportion_diff() to the table layout.

      • -
      • s_proportion_diff() returns a named list of elements diff and diff_ci.

      • -
    + +
      +
    • s_proportion_diff() returns a named list of elements diff and diff_ci.

    • +
    + +
    -

    Functions

    +

    Functions +

    -
    • estimate_proportion_diff(): Layout-creating function which can take statistics function arguments +

        +
      • estimate_proportion_diff(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_proportion_diff(): Statistics function estimating the difference in terms of responder proportion.

      • a_proportion_diff(): Formatted analysis function which is used as afun in estimate_proportion_diff().

      • -
    + +
    -

    Note

    +

    Note +

    When performing an unstratified analysis, methods "cmh", "strat_newcombe", and "strat_newcombecc" are not permitted.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    ## "Mid" case: 4/4 respond in group A, 1/2 respond in group B.
     nex <- 100 # Number of example rows
     dta <- data.frame(
    @@ -315,17 +417,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/prop_diff_test.html b/main/reference/prop_diff_test.html index d6bf628088..66112f748b 100644 --- a/main/reference/prop_diff_test.html +++ b/main/reference/prop_diff_test.html @@ -1,13 +1,36 @@ - -Difference test for two proportions — prop_diff_test • tern + + + + + +Difference test for two proportions — prop_diff_test • tern + + + + + + + + + + + + + +variable can be supplied via the strata element of the variables argument."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    test_proportion_diff(
       lyt,
       vars,
    @@ -101,114 +165,149 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    method
    +
    method +

    (string)
    one of chisq, cmh, fisher, or schouten; specifies the test used to calculate the p-value.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'pval'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'pval'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    + +
    -

    Value

    +

    Value +

    -
    • test_proportion_diff() returns a layout object suitable for passing to further layouting functions, +

        +
      • test_proportion_diff() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_test_proportion_diff() to the table layout.

      • -
      • s_test_proportion_diff() returns a named list with a single item pval with an attribute label +

      +
        +
      • s_test_proportion_diff() returns a named list with a single item pval with an attribute label describing the method used. The p-value tests the null hypothesis that proportions in two groups are the same.

      • -
    + + +
    -

    Functions

    +

    Functions +

    -
    • test_proportion_diff(): Layout-creating function which can take statistics function arguments +

        +
      • test_proportion_diff(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_test_proportion_diff(): Statistics function which tests the difference between two proportions.

      • a_test_proportion_diff(): Formatted analysis function which is used as afun in test_proportion_diff().

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    dta <- data.frame(
       rsp = sample(c(TRUE, FALSE), 100, TRUE),
       grp = factor(rep(c("A", "B"), each = 50)),
    @@ -231,17 +330,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/prune_occurrences.html b/main/reference/prune_occurrences.html index 9b091568dd..5665913257 100644 --- a/main/reference/prune_occurrences.html +++ b/main/reference/prune_occurrences.html @@ -1,13 +1,36 @@ - -Occurrence table pruning — prune_occurrences • tern + + + + + +Occurrence table pruning — prune_occurrences • tern + + + + + + + + + + + + + +functions."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    keep_rows(row_condition)
     
     keep_content_rows(content_row_condition)
    @@ -82,52 +146,78 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    row_condition
    +
    +
    row_condition +

    (CombinationFunction)
    condition function which works on individual analysis rows and flags whether these should be kept in the pruned table.

    -
    content_row_condition
    +
    content_row_condition +

    (CombinationFunction)
    condition function which works on individual first content rows of leaf tables and flags whether these leaf tables should be kept in the pruned table.

    -
    atleast
    +
    atleast +

    (numeric(1))
    threshold which should be met in order to keep the row.

    -
    ...
    +
    ... +

    arguments for row or column access, see rtables_access: either col_names (character) including the names of the columns which should be used, or alternatively col_indices (integer) giving the indices directly instead.

    -
    + +
    -

    Value

    +

    Value +

    -
    • keep_rows() returns a pruning function that can be used with rtables::prune_table() +

        +
      • keep_rows() returns a pruning function that can be used with rtables::prune_table() to prune an rtables table.

      • -
      • keep_content_rows() returns a pruning function that checks the condition on the first content +

      +
        +
      • keep_content_rows() returns a pruning function that checks the condition on the first content row of leaf tables in the table.

      • -
      • has_count_in_cols() returns a condition function that sums the counts in the specified column.

      • -
      • has_count_in_any_col() returns a condition function that compares the counts in the +

      +
        +
      • has_count_in_cols() returns a condition function that sums the counts in the specified column.

      • +
      +
        +
      • has_count_in_any_col() returns a condition function that compares the counts in the specified columns with the threshold.

      • -
      • has_fraction_in_cols() returns a condition function that sums the counts in the +

      +
        +
      • has_fraction_in_cols() returns a condition function that sums the counts in the specified column, and computes the fraction by dividing by the total column counts.

      • -
      • has_fraction_in_any_col() returns a condition function that looks at the fractions +

      +
        +
      • has_fraction_in_any_col() returns a condition function that looks at the fractions in the specified columns and checks whether any of them fulfill the threshold.

      • -
      • has_fractions_difference() returns a condition function that extracts the fractions of each +

      +
        +
      • has_fractions_difference() returns a condition function that extracts the fractions of each specified column, and computes the difference of the minimum and maximum.

      • -
      • has_counts_difference() returns a condition function that extracts the counts of each +

      +
        +
      • has_counts_difference() returns a condition function that extracts the counts of each specified column, and computes the difference of the minimum and maximum.

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • keep_rows(): Constructor for creating pruning functions based on +

        +
      • keep_rows(): Constructor for creating pruning functions based on a row condition function. This removes all analysis rows (TableRow) that should be pruned, i.e., don't fulfill the row condition. It removes the sub-tree if there are no children left.

      • @@ -146,16 +236,19 @@

        Functions -

        Note

        +

        Note +

        Since most table specifications are worded positively, we name our constructor and condition functions positively, too. However, note that the result of keep_rows() says what should be pruned, to conform with the rtables::prune_table() interface.

    -

    Examples

    +

    Examples +

    # \donttest{
     tab <- basic_table() %>%
       split_cols_by("ARM") %>%
    @@ -753,17 +846,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/range_noinf.html b/main/reference/range_noinf.html index fa230183d9..ea1969f89b 100644 --- a/main/reference/range_noinf.html +++ b/main/reference/range_noinf.html @@ -1,7 +1,30 @@ - -Re-implemented range() default S3 method for numerical objects — range_noinf • tern + + + + + + +Re-implemented range() default S3 method for numerical objects — range_noinf • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,43 +117,53 @@
    -

    Usage

    +

    Usage +

    range_noinf(x, na.rm = FALSE, finite = FALSE)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    a sequence of numbers for which the range is computed.

    -
    na.rm
    +
    na.rm +

    (flag)
    flag indicating if NA should be omitted.

    -
    finite
    +
    finite +

    (flag)
    flag indicating if non-finite elements should be removed.

    -
    + +
    -

    Value

    +

    Value +

    A 2-element vector of class numeric.

    + + - + + - + + diff --git a/main/reference/reapply_varlabels.html b/main/reference/reapply_varlabels.html index 5582c0791f..004b5bde7c 100644 --- a/main/reference/reapply_varlabels.html +++ b/main/reference/reapply_varlabels.html @@ -1,5 +1,28 @@ - -Reapply variable labels — reapply_varlabels • tern + + + + + + +Reapply variable labels — reapply_varlabels • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,43 +114,53 @@
    -

    Usage

    +

    Usage +

    reapply_varlabels(x, varlabels, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (vector)
    vector of elements that needs new labels.

    -
    varlabels
    +
    varlabels +

    (character)
    vector of labels for x.

    -
    ...
    +
    ... +

    further parameters to be added to the list.

    -
    + +
    -

    Value

    +

    Value +

    x with variable labels reapplied.

    + + - + + - + + diff --git a/main/reference/response_biomarkers_subgroups.html b/main/reference/response_biomarkers_subgroups.html index cb6059067c..f18a0754f0 100644 --- a/main/reference/response_biomarkers_subgroups.html +++ b/main/reference/response_biomarkers_subgroups.html @@ -1,15 +1,38 @@ - -Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups • tern + + + + + +Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups • tern + + + + + + + + + + + + + +A forest plot can be created from the resulting table using the g_forest() function."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    tabulate_rsp_biomarkers(
       df,
       vars = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"),
    @@ -76,56 +140,72 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    containing all analysis variables, as returned by extract_rsp_biomarkers().

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n_tot: Total number of patients per group.

    • +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n_tot: Total number of patients per group.

      • n_rsp: Total number of responses per group.

      • prop: Total response proportion per group.

      • or: Odds ratio.

      • ci: Confidence interval of odds ratio.

      • pval: p-value of the effect. Note, the statistics n_tot, or and ci are required.

      • -
      +
    +
    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    + +
    -

    Value

    +

    Value +

    An rtables table summarizing biomarker effects on binary response by subgroup.

    -

    Details

    +

    Details +

    These functions create a layout starting from a data frame which contains the required statistics. The tables are then typically used as input for forest plots.

    -

    Note

    +

    Note +

    In contrast to tabulate_rsp_subgroups() this tabulation function does not start from an input layout lyt. This is because internally the table is created by combining multiple subtables.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(forcats)
     
    @@ -179,17 +259,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/response_subgroups.html b/main/reference/response_subgroups.html index 43e8b0bb02..3c1b3432f7 100644 --- a/main/reference/response_subgroups.html +++ b/main/reference/response_subgroups.html @@ -1,15 +1,38 @@ - -Tabulate binary response by subgroup — response_subgroups • tern + + + + + +Tabulate binary response by subgroup — response_subgroups • tern + + + + + + + + + + + + + +A forest plot can be created from the resulting table using the g_forest() function."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    tabulate_rsp_subgroups(
       lyt,
       df,
    @@ -89,20 +153,28 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    df
    +
    df +

    (list)
    a list of data frames containing all analysis variables. List should be created using extract_rsp_subgroups().

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n: Total number of observations per group.

    • +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n: Total number of observations per group.

      • n_rsp: Number of responders per group.

      • prop: Proportion of responders.

      • n_tot: Total number of observations.

      • @@ -110,60 +182,76 @@

        Argumentsgroups_lists +
        groups_lists +

        (named list of list)
        optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

        -
        label_all
        +
        label_all +

        (string)
        label for the total population analysis.

        -
        riskdiff
        +
        riskdiff +

        (list)
        if a risk (proportion) difference column should be added, a list of settings to apply within the column. See control_riskdiff() for details. If NULL, no risk difference column will be added. If riskdiff$arm_x and riskdiff$arm_y are NULL, the first level of df$prop$arm will be used as arm_x and the second level as arm_y.

        -
        na_str
        +
        na_str +

        (string)
        string used to replace all NA or empty values in the output.

        -
        .formats
        +
        .formats +

        (named character or list)
        formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

        -

    + +
    -

    Value

    +

    Value +

    An rtables table summarizing binary response by subgroup.

    -
    + +
    -

    Details

    +

    Details +

    These functions create a layout starting from a data frame which contains the required statistics. Tables typically used as part of forest plot.

    -

    Functions

    +

    Functions +

    -
    • tabulate_rsp_subgroups(): Table-creating function which creates a table +

        +
      • tabulate_rsp_subgroups(): Table-creating function which creates a table summarizing binary response by subgroup. This function is a wrapper for rtables::analyze_colvars() and rtables::summarize_row_groups().

      • a_response_subgroups(): Formatted analysis function which is used as afun in tabulate_rsp_subgroups().

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(forcats)
     
    @@ -398,17 +486,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/rtable2gg.html b/main/reference/rtable2gg.html index a33acd55d9..26d54d35a0 100644 --- a/main/reference/rtable2gg.html +++ b/main/reference/rtable2gg.html @@ -1,9 +1,32 @@ - -Convert rtable objects to ggplot objects — rtable2gg • tern + + + + + +Convert rtable objects to ggplot objects — rtable2gg • tern + + + + + + + + + + + + + +functions from the ggplot2 package. Any table titles and/or footnotes are ignored."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,41 +120,51 @@
    -

    Usage

    +

    Usage +

    rtable2gg(tbl, fontsize = 12, colwidths = NULL, lbl_col_padding = 0)
    -

    Arguments

    +

    Arguments +

    -
    tbl
    +
    +
    tbl +

    (VTableTree)
    rtables table object.

    -
    fontsize
    +
    fontsize +

    (numeric(1))
    font size.

    -
    colwidths
    +
    colwidths +

    (numeric or NULL)
    a vector of column widths. Each element's position in colwidths corresponds to the column of tbl in the same position. If NULL, column widths are calculated according to maximum number of characters per column.

    -
    lbl_col_padding
    +
    lbl_col_padding +

    (numeric)
    additional padding to use when calculating spacing between the first (label) column and the second column of tbl. If colwidths is specified, the width of the first column becomes colwidths[1] + lbl_col_padding. Defaults to 0.

    -
    + +
    -

    Value

    +

    Value +

    A ggplot object.

    -

    Examples

    +

    Examples +

    dta <- data.frame(
       ARM     = rep(LETTERS[1:3], rep(6, 3)),
       AVISIT  = rep(paste0("V", 1:3), 6),
    @@ -114,17 +187,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/rtables_access.html b/main/reference/rtables_access.html index c684826913..49b74cdf1e 100644 --- a/main/reference/rtables_access.html +++ b/main/reference/rtables_access.html @@ -1,11 +1,34 @@ - -Helper functions for accessing information from rtables — rtables_access • tern + + + + + +Helper functions for accessing information from rtables — rtables_access • tern + + + + + + + + + + + + + +element and a fraction as the second element in each cell."> + + + + + Skip to contents @@ -21,33 +44,74 @@ + +
    @@ -60,7 +124,8 @@
    -

    Usage

    +

    Usage +

    h_row_first_values(table_row, col_names = NULL, col_indices = NULL)
     
     h_row_counts(table_row, col_names = NULL, col_indices = NULL)
    @@ -77,42 +142,66 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    table_row
    +
    +
    table_row +

    (TableRow)
    an analysis row in a occurrence table.

    -
    col_names
    +
    col_names +

    (character)
    the names of the columns to extract from.

    -
    col_indices
    +
    col_indices +

    (integer)
    the indices of the columns to extract from. If col_names are provided, then these are inferred from the names of table_row. Note that this currently only works well with a single column split.

    -
    table
    +
    table +

    (VTableNodeInfo)
    an occurrence table or row.

    -
    + +
    -

    Value

    - -
    • h_row_first_values() returns a vector of numeric values.

    • -
    • h_row_counts() returns a vector of numeric values.

    • -
    • h_row_fractions() returns a vector of proportions.

    • -
    • h_col_counts() returns a vector of column counts.

    • -
    • h_content_first_row() returns a row from an rtables table.

    • -
    • is_leaf_table() returns a logical value indicating whether current table is a leaf.

    • -
    • check_names_indices returns column indices.

    • -
    +

    Value +

    + +
      +
    • h_row_first_values() returns a vector of numeric values.

    • +
    +
      +
    • h_row_counts() returns a vector of numeric values.

    • +
    +
      +
    • h_row_fractions() returns a vector of proportions.

    • +
    +
      +
    • h_col_counts() returns a vector of column counts.

    • +
    +
      +
    • h_content_first_row() returns a row from an rtables table.

    • +
    +
      +
    • is_leaf_table() returns a logical value indicating whether current table is a leaf.

    • +
    +
      +
    • check_names_indices returns column indices.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • h_row_first_values(): Helper function to extract the first values from each content +

        +
      • h_row_first_values(): Helper function to extract the first values from each content cell and from specified columns in a TableRow. Defaults to all columns.

      • h_row_counts(): Helper function that extracts row values and checks if they are convertible to integers (integerish values).

      • @@ -122,14 +211,17 @@

        Functions -

        See also

        +

        See also +

        prune_occurrences for usage of these functions.

    -

    Examples

    +

    Examples +

    tbl <- basic_table() %>%
       split_cols_by("ARM") %>%
       split_rows_by("RACE") %>%
    @@ -163,17 +255,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/s_bland_altman.html b/main/reference/s_bland_altman.html index 84b6e44ca1..e89743d1f5 100644 --- a/main/reference/s_bland_altman.html +++ b/main/reference/s_bland_altman.html @@ -1,9 +1,32 @@ - -Bland-Altman analysis — s_bland_altman • tern + + + + + +Bland-Altman analysis — s_bland_altman • tern + + + + + + + + + + + + + +and calculates a variety of statistics."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,29 +120,39 @@
    -

    Usage

    +

    Usage +

    s_bland_altman(x, y, conf_level = 0.95)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    y
    +
    y +

    (numeric)
    vector of numbers we want to analyze, to be compared with x.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    -

    A named list of the following elements:

    • df

    • +

      Value +

      +

      A named list of the following elements:

      +
        +
      • df

      • difference_mean

      • ci_mean

      • difference_sd

      • @@ -91,10 +164,12 @@

        Value

        lower_agreement_limit_ci

      • t_value

      • n

      • -
    + +
    -

    Examples

    +

    Examples +

    x <- seq(1, 60, 5)
     y <- seq(5, 50, 4)
     
    @@ -151,17 +226,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/s_cox_multivariate.html b/main/reference/s_cox_multivariate.html index e6267c12cc..078cd53cde 100644 --- a/main/reference/s_cox_multivariate.html +++ b/main/reference/s_cox_multivariate.html @@ -1,19 +1,42 @@ - -Multivariate Cox model - summarized results — s_cox_multivariate • tern + + + + + +Multivariate Cox model - summarized results — s_cox_multivariate • tern + + + + + + + + + + + + + +NEST's bookdown)"> + + + + + Skip to contents @@ -29,26 +52,66 @@ + + @@ -72,7 +135,8 @@
    -

    Usage

    +

    Usage +

    s_cox_multivariate(
       formula,
       data,
    @@ -83,49 +147,61 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    formula
    +
    +
    formula +

    (formula)
    a formula corresponding to the investigated survival::Surv() survival model including covariates.

    -
    data
    +
    data +

    (data.frame)
    a data frame which includes the variable in formula and covariates.

    -
    conf_level
    +
    conf_level +

    (proportion)
    the confidence level for the hazard ratio interval estimations. Default is 0.95.

    -
    pval_method
    +
    pval_method +

    (string)
    the method used for the estimation of p-values, should be one of "wald" (default) or "likelihood".

    -
    ...
    +
    ... +

    optional parameters passed to survival::coxph(). Can include ties, a character string specifying the method for tie handling, one of exact (default), efron, breslow.

    -
    + +
    -

    Value

    +

    Value +

    A list with elements mod, msum, aov, and coef_inter.

    -

    Details

    +

    Details +

    The output is limited to single effect terms. Work in ongoing for estimation of interaction terms but is out of scope as defined by the Global Data Standards Repository (GDS_Standard_TLG_Specs_Tables_2.doc).

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte <- tern_ex_adtte
    @@ -142,17 +218,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/sas_na.html b/main/reference/sas_na.html index 091ae70375..f15b6c3a09 100644 --- a/main/reference/sas_na.html +++ b/main/reference/sas_na.html @@ -1,9 +1,32 @@ - -Convert strings to NA — sas_na • tern + + + + + +Convert strings to NA — sas_na • tern + + + + + + + + + + + + + +convert these values to NAs."> + + + + + Skip to contents @@ -19,33 +42,74 @@ + +
    @@ -57,34 +121,43 @@
    -

    Usage

    +

    Usage +

    sas_na(x, empty = TRUE, whitespaces = TRUE)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (factor or character)
    values for which any missing values should be substituted.

    -
    empty
    +
    empty +

    (flag)
    if TRUE, empty strings get replaced by NA.

    -
    whitespaces
    +
    whitespaces +

    (flag)
    if TRUE, strings made from only whitespaces get replaced with NA.

    -
    + +
    -

    Value

    +

    Value +

    x with "" and/or whitespace-only values substituted by NA, depending on the values of empty and whitespaces.

    -

    Examples

    +

    Examples +

    sas_na(c("1", "", " ", "   ", "b"))
     #> [1] "1" NA  NA  NA  "b"
     sas_na(factor(c("", " ", "b")))
    @@ -97,17 +170,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/score_occurrences.html b/main/reference/score_occurrences.html index d1e9c60d7c..4f7b2c2ae8 100644 --- a/main/reference/score_occurrences.html +++ b/main/reference/score_occurrences.html @@ -1,9 +1,32 @@ - -Occurrence table sorting — score_occurrences • tern + + + + + +Occurrence table sorting — score_occurrences • tern + + + + + + + + + + + + + +sorting of occurrence tables."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    score_occurrences(table_row)
     
     score_occurrences_cols(...)
    @@ -68,34 +132,50 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    table_row
    +
    +
    table_row +

    (TableRow)
    an analysis row in a occurrence table.

    -
    ...
    +
    ... +

    arguments for row or column access, see rtables_access: either col_names (character) including the names of the columns which should be used, or alternatively col_indices (integer) giving the indices directly instead.

    -
    + +
    -

    Value

    +

    Value +

    -
    • score_occurrences() returns the sum of counts across all columns of a table row.

    • -
    • score_occurrences_cols() returns a function that sums counts across all specified columns +

        +
      • score_occurrences() returns the sum of counts across all columns of a table row.

      • +
      +
        +
      • score_occurrences_cols() returns a function that sums counts across all specified columns of a table row.

      • -
      • score_occurrences_subtable() returns a function that sums counts in each subtable +

      +
        +
      • score_occurrences_subtable() returns a function that sums counts in each subtable across all specified columns.

      • -
      • score_occurrences_cont_cols() returns a function that sums counts in the first content row in +

      +
        +
      • score_occurrences_cont_cols() returns a function that sums counts in the first content row in specified columns.

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • score_occurrences(): Scoring function which sums the counts across all +

        +
      • score_occurrences(): Scoring function which sums the counts across all columns. It will fail if anything else but counts are used.

      • score_occurrences_cols(): Scoring functions can be produced by this constructor to only include specific columns in the scoring. See h_row_counts() for further information.

      • @@ -104,15 +184,20 @@

        Functionsrtables::cont_n_onecol() and rtables::cont_n_allcols().

        -

    + +
    -

    Examples

    +

    Examples +

    lyt <- basic_table() %>%
       split_cols_by("ARM") %>%
       add_colcounts() %>%
    @@ -266,17 +351,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/split_cols_by_groups.html b/main/reference/split_cols_by_groups.html index 3f8013de15..b987c0f00a 100644 --- a/main/reference/split_cols_by_groups.html +++ b/main/reference/split_cols_by_groups.html @@ -1,5 +1,28 @@ - -Split columns by groups of levels — split_cols_by_groups • tern + + + + + + +Split columns by groups of levels — split_cols_by_groups • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,50 +114,62 @@
    -

    Usage

    +

    Usage +

    split_cols_by_groups(lyt, var, groups_list = NULL, ref_group = NULL, ...)
    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    var
    +
    var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    groups_list
    +
    groups_list +

    (named list of character)
    specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    ref_group
    +
    ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    ...
    +
    ... +

    additional arguments to rtables::split_cols_by() in order. For instance, to control formats (format), add a joint column for all groups (incl_all).

    -
    + +
    -

    Value

    +

    Value +

    A layout object suitable for passing to further layouting functions. Adding this function to an rtable layout will add a column split including the given groups to the table layout.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    # 1 - Basic use
     
     # Without group combination `split_cols_by_groups` is
    @@ -215,17 +290,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/split_text_grob.html b/main/reference/split_text_grob.html index 0ada7c7958..35113b80b2 100644 --- a/main/reference/split_text_grob.html +++ b/main/reference/split_text_grob.html @@ -1,5 +1,28 @@ - -Split text according to available text width — split_text_grob • tern + + + + + + +Split text according to available text width — split_text_grob • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    split_text_grob(
       text,
       x = grid::unit(0.5, "npc"),
    @@ -68,26 +132,33 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    text
    +
    +
    text +

    (string)
    the text to wrap.

    -
    x
    +
    x +

    A numeric vector or unit object specifying x-values.

    -
    y
    +
    y +

    A numeric vector or unit object specifying y-values.

    -
    width
    +
    width +

    (grid::unit)
    a unit object specifying maximum width of text.

    -
    just
    +
    just +

    The justification of the text relative to its (x, y) location. If there are two values, the first value specifies horizontal justification and the second value specifies @@ -97,57 +168,68 @@

    Argumentshjust +
    hjust +

    A numeric vector specifying horizontal justification. If specified, overrides the just setting.

    -
    vjust
    +
    vjust +

    A numeric vector specifying vertical justification. If specified, overrides the just setting.

    -
    default.units
    +
    default.units +

    A string indicating the default units to use if x or y are only given as numeric vectors.

    -
    name
    +
    name +

    A character identifier.

    -
    gp
    +
    gp +

    An object of class "gpar", typically the output from a call to the function gpar. This is basically a list of graphical parameter settings.

    -
    vp
    +
    vp +

    A Grid viewport object (or NULL).

    -

    + +
    -

    Value

    +

    Value +

    A text grob.

    -

    Details

    +

    Details +

    This code is taken from R Graphics by Paul Murell, 2nd edition

    + + - + + - + + diff --git a/main/reference/stack_grobs.html b/main/reference/stack_grobs.html index 8a9a783231..d94dfdeba1 100644 --- a/main/reference/stack_grobs.html +++ b/main/reference/stack_grobs.html @@ -1,7 +1,30 @@ - -Stack multiple grobs — stack_grobs • tern + + + + + + +Stack multiple grobs — stack_grobs • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,7 +117,8 @@
    -

    Usage

    +

    Usage +

    stack_grobs(
       ...,
       grobs = list(...),
    @@ -66,40 +130,51 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    ...
    +
    +
    ... +

    grobs.

    -
    grobs
    +
    grobs +

    (list of grob)
    a list of grobs.

    -
    padding
    +
    padding +

    (grid::unit)
    unit of length 1, space between each grob.

    -
    vp
    +
    vp +

    (viewport or NULL)
    a viewport() object (or NULL).

    -
    gp
    +
    gp +

    (gpar)
    a gpar() object.

    -
    name
    +
    name +

    (string)
    a character identifier for the grob.

    -
    + +
    -

    Value

    +

    Value +

    A grob.

    -

    Examples

    +

    Examples +

    library(grid)
     
     g1 <- circleGrob(gp = gpar(col = "blue"))
    @@ -123,17 +198,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/stat_mean_ci.html b/main/reference/stat_mean_ci.html index 234f3caf56..298ecd0b39 100644 --- a/main/reference/stat_mean_ci.html +++ b/main/reference/stat_mean_ci.html @@ -1,9 +1,32 @@ - -Confidence interval for mean — stat_mean_ci • tern + + + + + +Confidence interval for mean — stat_mean_ci • tern + + + + + + + + + + + + + +geometric mean. It can be used as a ggplot helper function for plotting."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,7 +120,8 @@
    -

    Usage

    +

    Usage +

    stat_mean_ci(
       x,
       conf_level = 0.95,
    @@ -69,40 +133,51 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    n_min
    +
    n_min +

    (numeric(1))
    a minimum number of non-missing x to estimate the confidence interval for mean.

    -
    gg_helper
    +
    gg_helper +

    (flag)
    whether output should be aligned for use with ggplots.

    -
    geom_mean
    +
    geom_mean +

    (flag)
    whether the geometric mean should be calculated.

    -
    + +
    -

    Value

    +

    Value +

    A named vector of values mean_ci_lwr and mean_ci_upr.

    -

    Examples

    +

    Examples +

    stat_mean_ci(sample(10), gg_helper = FALSE)
     #> mean_ci_lwr mean_ci_upr 
     #>    3.334149    7.665851 
    @@ -133,17 +208,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/stat_mean_pval.html b/main/reference/stat_mean_pval.html index 1d2bac4bfe..06d17b6a5e 100644 --- a/main/reference/stat_mean_pval.html +++ b/main/reference/stat_mean_pval.html @@ -1,7 +1,30 @@ - -p-Value of the mean — stat_mean_pval • tern + + + + + + +p-Value of the mean — stat_mean_pval • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,37 +117,47 @@
    -

    Usage

    +

    Usage +

    stat_mean_pval(x, na.rm = TRUE, n_min = 2, test_mean = 0)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    n_min
    +
    n_min +

    (numeric(1))
    a minimum number of non-missing x to estimate the p-value of the mean.

    -
    test_mean
    +
    test_mean +

    (numeric(1))
    mean value to test under the null hypothesis.

    -
    + +
    -

    Value

    +

    Value +

    A p-value.

    -

    Examples

    +

    Examples +

    stat_mean_pval(sample(10))
     #>     p_value 
     #> 0.000278196 
    @@ -96,17 +169,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/stat_median_ci.html b/main/reference/stat_median_ci.html index 9ce09bbdf1..c45584d676 100644 --- a/main/reference/stat_median_ci.html +++ b/main/reference/stat_median_ci.html @@ -1,9 +1,32 @@ - -Confidence interval for median — stat_median_ci • tern + + + + + +Confidence interval for median — stat_median_ci • tern + + + + + + + + + + + + + +function for plotting."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,41 +120,52 @@
    -

    Usage

    +

    Usage +

    stat_median_ci(x, conf_level = 0.95, na.rm = TRUE, gg_helper = TRUE)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    na.rm
    +
    na.rm +

    (flag)
    whether NA values should be removed from x prior to analysis.

    -
    gg_helper
    +
    gg_helper +

    (flag)
    whether output should be aligned for use with ggplots.

    -
    + +
    -

    Value

    +

    Value +

    A named vector of values median_ci_lwr and median_ci_upr.

    -

    Details

    +

    Details +

    This function was adapted from DescTools/versions/0.99.35/source

    -

    Examples

    +

    Examples +

    stat_median_ci(sample(10), gg_helper = FALSE)
     #> median_ci_lwr median_ci_upr 
     #>             2             9 
    @@ -109,17 +183,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/stat_propdiff_ci.html b/main/reference/stat_propdiff_ci.html index 796ca1e1ac..4ec8399c44 100644 --- a/main/reference/stat_propdiff_ci.html +++ b/main/reference/stat_propdiff_ci.html @@ -1,11 +1,34 @@ - -Proportion difference and confidence interval — stat_propdiff_ci • tern + + + + + +Proportion difference and confidence interval — stat_propdiff_ci • tern + + + + + + + + + + + + + +in arm Y from cumulative incidence in arm X."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,7 +123,8 @@
    -

    Usage

    +

    Usage +

    stat_propdiff_ci(
       x,
       y,
    @@ -73,52 +137,65 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (list of integer)
    list of number of occurrences in arm X (reference group).

    -
    y
    +
    y +

    (list of integer)
    list of number of occurrences in arm Y. Must be of equal length to x.

    -
    N_x
    +
    N_x +

    (numeric(1))
    total number of records in arm X.

    -
    N_y
    +
    N_y +

    (numeric(1))
    total number of records in arm Y.

    -
    list_names
    +
    list_names +

    (character)
    names of each variable/level corresponding to pair of proportions in x and y. Must be of equal length to x and y.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    pct
    +
    pct +

    (flag)
    whether output should be returned as percentages. Defaults to TRUE.

    -
    + +
    -

    Value

    +

    Value +

    List of proportion differences and CIs corresponding to each pair of number of occurrences in x and y. Each list element consists of 3 statistics: proportion difference, CI lower bound, and CI upper bound.

    -

    See also

    +

    See also +

    Split function add_riskdiff() which, when used as split_fun within rtables::split_cols_by() with riskdiff argument is set to TRUE in subsequent analyze functions, adds a column containing proportion (risk) difference to an rtables layout.

    -

    Examples

    +

    Examples +

    stat_propdiff_ci(
       x = list(0.375), y = list(0.01), N_x = 5, N_y = 5, list_names = "x", conf_level = 0.9
     )
    @@ -142,17 +219,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/strata_normal_quantile.html b/main/reference/strata_normal_quantile.html index ca2635821a..f15714629b 100644 --- a/main/reference/strata_normal_quantile.html +++ b/main/reference/strata_normal_quantile.html @@ -1,11 +1,34 @@ - -Helper function for the estimation of stratified quantiles — strata_normal_quantile • tern + + + + + +Helper function for the estimation of stratified quantiles — strata_normal_quantile • tern + + + + + + + + + + + + + +proportions for each strata are unequal."> + + + + + Skip to contents @@ -21,26 +44,66 @@ + + @@ -60,39 +123,49 @@
    -

    Usage

    +

    Usage +

    strata_normal_quantile(vars, weights, conf_level)
    -

    Arguments

    +

    Arguments +

    -
    vars
    +
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    weights
    +
    weights +

    (numeric or NULL)
    weights for each level of the strata. If NULL, they are estimated using the iterative algorithm proposed in Yan2010-jt;textualtern that minimizes the weighted squared length of the confidence interval.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    + +
    -

    Value

    +

    Value +

    Stratified quantile.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    strata_data <- table(data.frame(
       "f1" = sample(c(TRUE, FALSE), 100, TRUE),
       "f2" = sample(c("x", "y", "z"), 100, TRUE),
    @@ -109,17 +182,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/study_arm.html b/main/reference/study_arm.html index f08ea6998f..c8aeceb083 100644 --- a/main/reference/study_arm.html +++ b/main/reference/study_arm.html @@ -1,5 +1,28 @@ - -Indicate study arm variable in formula — study_arm • tern + + + + + + +Indicate study arm variable in formula — study_arm • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,35 +114,43 @@
    -

    Usage

    +

    Usage +

    study_arm(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    arm information

    -
    + +
    -

    Value

    +

    Value +

    x

    + + - + + - + + diff --git a/main/reference/summarize_ancova.html b/main/reference/summarize_ancova.html index a6962c704b..4ffea081a6 100644 --- a/main/reference/summarize_ancova.html +++ b/main/reference/summarize_ancova.html @@ -1,5 +1,22 @@ - -Summarize analysis of covariance (ANCOVA) results — summarize_ancova • tern + + + + + +Summarize analysis of covariance (ANCOVA) results — summarize_ancova • tern + + + + + + + + + + + + + +the ANCOVA results via the interaction_y parameter."> + + + + + Skip to contents @@ -31,26 +54,66 @@ + + @@ -75,7 +138,8 @@
    -

    Usage

    +

    Usage +

    summarize_ancova(
       lyt,
       vars,
    @@ -121,134 +185,179 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    variables
    -

    (named list of string)
    list of additional analysis variables, with expected elements:

    • arm (string)
      group variable, for which the covariate adjusted means of multiple groups will be +

      variables +
      +
      +

      (named list of string)
      list of additional analysis variables, with expected elements:

      +
        +
      • arm (string)
        group variable, for which the covariate adjusted means of multiple groups will be summarized. Specifically, the first level of arm variable is taken as the reference group.

      • covariates (character)
        a vector that can contain single variable names (such as "X1"), and/or interaction terms indicated by "X1 * X2".

      • -
      +
    +
    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    interaction_y
    +
    interaction_y +

    (string or flag)
    a selected item inside of the interaction_item variable which will be used to select the specific ANCOVA results. if the interaction is not needed, the default option is FALSE.

    -
    interaction_item
    +
    interaction_item +

    (string or NULL)
    name of the variable that should have interactions with arm. if the interaction is not needed, the default option is NULL.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'lsmean', 'lsmean_diff', 'lsmean_diff_ci', 'pval'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'lsmean', 'lsmean_diff', 'lsmean_diff_ci', 'pval'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data set that includes all the variables that are called in .var and variables.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    + +
    -

    Value

    +

    Value +

    -
    • summarize_ancova() returns a layout object suitable for passing to further layouting functions, +

        +
      • summarize_ancova() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_ancova() to the table layout.

      • -
      • s_ancova() returns a named list of 5 statistics:

        • n: Count of complete sample size for the group.

        • +
        +
          +
        • +

          s_ancova() returns a named list of 5 statistics:

          +
            +
          • n: Count of complete sample size for the group.

          • lsmean: Estimated marginal means in the group.

          • lsmean_diff: Difference in estimated marginal means in comparison to the reference group. If working with the reference group, this will be empty.

          • lsmean_diff_ci: Confidence level for difference in estimated marginal means in comparison to the reference group.

          • pval: p-value (not adjusted for multiple comparisons).

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • summarize_ancova(): Layout-creating function which can take statistics function arguments +

        +
      • summarize_ancova(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_ancova(): Statistics function that produces a named list of results of the investigated linear model.

      • a_ancova(): Formatted analysis function which is used as afun in summarize_ancova().

      • -
    + +
    -

    Examples

    +

    Examples +

    basic_table() %>%
       split_cols_by("Species", ref_group = "setosa") %>%
       add_colcounts() %>%
    @@ -285,17 +394,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/summarize_change.html b/main/reference/summarize_change.html index ad32041a6d..d43631482a 100644 --- a/main/reference/summarize_change.html +++ b/main/reference/summarize_change.html @@ -1,19 +1,42 @@ - -Summarize change from baseline values or absolute baseline values — summarize_change • tern + + + + + +Summarize change from baseline values or absolute baseline values — summarize_change • tern + + + + + + + + + + + + + +or the change from baseline values (post-baseline) are then summarized."> + + + + + Skip to contents @@ -29,26 +52,66 @@ + + @@ -72,7 +135,8 @@
    -

    Usage

    +

    Usage +

    summarize_change(
       lyt,
       vars,
    @@ -107,95 +171,126 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    variables
    +
    variables +

    (named list of string)
    list of additional analysis variables.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    section_div
    +
    section_div +

    (string)
    string which should be repeated as a section divider after each group defined by this split instruction, or NA_character_ (the default) for no section divider.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    + +
    -

    Value

    +

    Value +

    -
    • summarize_change() returns a layout object suitable for passing to further layouting functions, +

        +
      • summarize_change() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_change_from_baseline() to the table layout.

      • -
    + + + +
    -

    Functions

    +

    Functions +

    -
    • summarize_change(): Layout-creating function which can take statistics function arguments +

        +
      • summarize_change(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_change_from_baseline(): Statistics function that summarizes baseline or post-baseline visits.

      • a_change_from_baseline(): Formatted analysis function which is used as afun in summarize_change().

      • -
    + +
    -

    Note

    +

    Note +

    To be used after a split on visits in the layout, such that each data subset only contains either baseline or post-baseline data.

    The data in df must be either all be from baseline or post-baseline visits. Otherwise @@ -203,7 +298,8 @@

    Note

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     # Fabricate dataset
    @@ -249,17 +345,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/summarize_colvars.html b/main/reference/summarize_colvars.html index 6dbb078d09..5b05efa016 100644 --- a/main/reference/summarize_colvars.html +++ b/main/reference/summarize_colvars.html @@ -1,17 +1,40 @@ - -Summarize variables in columns — summarize_colvars • tern + + + + + +Summarize variables in columns — summarize_colvars • tern + + + + + + + + + + + + + +the analyze_vars_in_cols() function."> + + + + + Skip to contents @@ -27,26 +50,66 @@ + + @@ -69,7 +132,8 @@
    -

    Usage

    +

    Usage +

    summarize_colvars(
       lyt,
       ...,
    @@ -82,53 +146,66 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    ...
    +
    ... +

    arguments passed to s_summary().

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .stats
    +
    .stats +

    (character)
    statistics to select for the table.

    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named vector of integer)
    indent modifiers for the labels. Each element of the vector should be a name-value pair with name corresponding to a statistic specified in .stats and value the indentation for that statistic's row label.

    -
    + +
    -

    Value

    +

    Value +

    A layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will summarize the given variables, arrange the output in columns, and add it to the table layout.

    -

    Examples

    +

    Examples +

    dta_test <- data.frame(
       USUBJID = rep(1:6, each = 3),
       PARAMCD = rep("lab", 6 * 3),
    @@ -217,17 +294,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/summarize_functions.html b/main/reference/summarize_functions.html index 0aadc180a3..cbae6b283e 100644 --- a/main/reference/summarize_functions.html +++ b/main/reference/summarize_functions.html @@ -1,7 +1,30 @@ - -Summarize functions — summarize_functions • tern + + + + + + +Summarize functions — summarize_functions • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -55,9 +118,11 @@
    -

    Details

    +

    Details +

    - +

    Additionally, the summarize_coxreg() function utilizes rtables::summarize_row_groups() (in combination with several other rtables functions like rtables::analyze_colvars()) to output a Cox regression summary table.

    -

    See also

    +

    See also +

    -
    + +
    + + - + + - + + diff --git a/main/reference/summarize_glm_count.html b/main/reference/summarize_glm_count.html index fde9f0b543..465dd8738b 100644 --- a/main/reference/summarize_glm_count.html +++ b/main/reference/summarize_glm_count.html @@ -1,15 +1,38 @@ - -Summarize Poisson negative binomial regression — summarize_glm_count • tern + + + + + +Summarize Poisson negative binomial regression — summarize_glm_count • tern + + + + + + + + + + + + + +covariates."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    summarize_glm_count(
       lyt,
       vars,
    @@ -105,136 +169,178 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    variables
    -

    (named list of string)
    list of additional analysis variables, with -expected elements:

    • arm (string)
      group variable, for which the covariate adjusted means of multiple +

      variables +
      +
      +

      (named list of string)
      list of additional analysis variables, with +expected elements:

      +
        +
      • arm (string)
        group variable, for which the covariate adjusted means of multiple groups will be summarized. Specifically, the first level of arm variable is taken as the reference group.

      • covariates (character)
        a vector that can contain single variable names (such as "X1"), and/or interaction terms indicated by "X1 * X2".

      • offset (numeric)
        a numeric vector or scalar adding an offset.

      • -
      +
    +
    -
    distribution
    +
    distribution +

    (character)
    a character value specifying the distribution used in the regression (Poisson, Quasi-Poisson, negative binomial).

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    rate_mean_method
    +
    rate_mean_method +

    (character(1))
    method used to estimate the mean odds ratio. Defaults to emmeans. see details for more information.

    -
    weights
    +
    weights +

    (character)
    a character vector specifying weights used in averaging predictions. Number of weights must equal the number of levels included in the covariates. Weights option passed to emmeans::emmeans().

    -
    scale
    +
    scale +

    (numeric(1))
    linear scaling factor for rate and confidence intervals. Defaults to 1.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n', 'rate', 'rate_ci', 'rate_ratio', 'rate_ratio_ci', 'pval'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n', 'rate', 'rate_ci', 'rate_ratio', 'rate_ratio_ci', 'pval'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    dataset that includes all the variables that are called in .var and variables.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    + +
    -

    Value

    +

    Value +

    -
    • summarize_glm_count() returns a layout object suitable for passing to further layouting functions, +

        +
      • summarize_glm_count() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_glm_count() to the table layout.

      • -
      • s_glm_count() returns a named list of 5 statistics:

        • n: Count of complete sample size for the group.

        • +
        +
          +
        • +

          s_glm_count() returns a named list of 5 statistics:

          +
            +
          • n: Count of complete sample size for the group.

          • rate: Estimated event rate per follow-up time.

          • rate_ci: Confidence level for estimated rate per follow-up time.

          • rate_ratio: Ratio of event rates in each treatment arm to the reference arm.

          • rate_ratio_ci: Confidence level for the rate ratio.

          • pval: p-value.

          • -
        • -
    + + + +
    -

    Details

    +

    Details +

    summarize_glm_count() uses s_glm_count() to calculate the statistics for the table. This analysis function uses h_glm_count() to estimate the GLM with stats::glm() for Poisson and Quasi-Poisson distributions or MASS::glm.nb() for Negative Binomial distribution. All methods assume a @@ -248,16 +354,20 @@

    Detailsmethod = "trt.vs.ctrl" and ref equal to the first arm value.

    -

    Functions

    +

    Functions +

    -
    • summarize_glm_count(): Layout-creating function which can take statistics function arguments +

        +
      • summarize_glm_count(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_glm_count(): Statistics function that produces a named list of results of the investigated Poisson model.

      • -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     
     anl <- tern_ex_adtte %>% filter(PARAMCD == "TNE")
    @@ -325,17 +435,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/summarize_logistic.html b/main/reference/summarize_logistic.html index 54ce7d47bf..3cccc9f6be 100644 --- a/main/reference/summarize_logistic.html +++ b/main/reference/summarize_logistic.html @@ -1,5 +1,22 @@ - -Multivariate logistic regression table — summarize_logistic • tern + + + + + +Multivariate logistic regression table — summarize_logistic • tern + + + + + + + + + + + + + +each interaction degree of freedom."> + + + + + Skip to contents @@ -33,26 +56,66 @@ + + @@ -78,7 +141,8 @@
    -

    Usage

    +

    Usage +

    summarize_logistic(
       lyt,
       conf_level,
    @@ -88,39 +152,49 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    drop_and_remove_str
    +
    drop_and_remove_str +

    (string)
    string to be dropped and removed.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    + +
    -

    Value

    +

    Value +

    A layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add a logistic regression variable summary to the table layout.

    -

    Note

    +

    Note +

    For the formula, the variable names need to be standard data.frame column names without special characters.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(broom)
     
    @@ -215,17 +289,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/summarize_num_patients.html b/main/reference/summarize_num_patients.html index 1868464782..32b5aa99d8 100644 --- a/main/reference/summarize_num_patients.html +++ b/main/reference/summarize_num_patients.html @@ -1,5 +1,22 @@ - -Count number of patients — summarize_num_patients • tern + + + + + +Count number of patients — summarize_num_patients • tern + + + + + + + + + + + + + +the latest row split or the root of the table if no row splits have occurred."> + + + + + Skip to contents @@ -31,26 +54,66 @@ + + @@ -75,7 +138,8 @@
    -

    Usage

    +

    Usage +

    analyze_num_patients(
       lyt,
       vars,
    @@ -130,115 +194,153 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    required
    +
    required +

    (character or NULL)
    name of a variable that is required to be non-missing.

    -
    count_by
    +
    count_by +

    (character or NULL)
    name of a variable to be combined with vars when counting nonunique records.

    -
    unique_count_suffix
    +
    unique_count_suffix +

    (flag)
    whether the "(n)" suffix should be added to unique_count labels. Defaults to TRUE.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'unique', 'nonunique', 'unique_count'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'unique', 'nonunique', 'unique_count'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    riskdiff
    +
    riskdiff +

    (flag)
    whether a risk difference column is present. When set to TRUE, add_riskdiff() must be used as split_fun in the prior column split of the table layout, specifying which columns should be compared. See stat_propdiff_ci() for details on risk difference calculation.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    x
    +
    x +

    (character or factor)
    vector of patient IDs.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var, var
    +
    .var, var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    + +
    -

    Value

    +

    Value +

    -
    • analyze_num_patients() returns a layout object suitable for passing to further layouting functions, +

        +
      • analyze_num_patients() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_num_patients_content() to the table layout.

      • -
      • summarize_num_patients() returns a layout object suitable for passing to further layouting functions, +

      +
        +
      • summarize_num_patients() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_num_patients_content() to the table layout.

      • -
      • s_num_patients() returns a named list of 3 statistics:

        • unique: Vector of counts and percentages.

        • +
        +
          +
        • +

          s_num_patients() returns a named list of 3 statistics:

          +
            +
          • unique: Vector of counts and percentages.

          • nonunique: Vector of counts.

          • unique_count: Counts.

          • -
        • -
        • s_num_patients_content() returns the same values as s_num_patients().

        • -
    + + + +
      +
    • s_num_patients_content() returns the same values as s_num_patients().

    • +
    +
    -

    Details

    +

    Details +

    In general, functions that starts with analyze* are expected to work like rtables::analyze(), while functions that starts with summarize* are based upon rtables::summarize_row_groups(). The latter provides a @@ -247,9 +349,11 @@

    Details

    -

    Functions

    +

    Functions +

    -
    • analyze_num_patients(): Layout-creating function which can take statistics function arguments +

        +
      • analyze_num_patients(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • summarize_num_patients(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::summarize_row_groups().

      • @@ -259,14 +363,17 @@

        Functions -

        Note

        +

        Note +

        As opposed to summarize_num_patients(), this function does not repeat the produced rows.

    -

    Examples

    +

    Examples +

    df <- data.frame(
       USUBJID = as.character(c(1, 2, 1, 4, NA, 6, 6, 8, 9)),
       ARM = c("A", "A", "A", "A", "A", "B", "B", "B", "B"),
    @@ -386,17 +493,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/summarize_patients_exposure_in_cols.html b/main/reference/summarize_patients_exposure_in_cols.html index 021f391bb0..3666b1e09a 100644 --- a/main/reference/summarize_patients_exposure_in_cols.html +++ b/main/reference/summarize_patients_exposure_in_cols.html @@ -1,5 +1,22 @@ - -Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols • tern + + + + + +Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols • tern + + + + + + + + + + + + + +analyze_patients_exposure_in_cols() or summarize_patients_exposure_in_cols()."> + + + + + Skip to contents @@ -39,26 +62,66 @@ + + @@ -87,7 +150,8 @@
    -

    Usage

    +

    Usage +

    analyze_patients_exposure_in_cols(
       lyt,
       var = NULL,
    @@ -143,102 +207,138 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    var
    +
    var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    ex_var
    +
    ex_var +

    (string)
    name of the variable in df containing exposure values.

    -
    id
    +
    id +

    (string)
    subject variable name.

    -
    add_total_level
    +
    add_total_level +

    (flag)
    adds a "total" level after the others which includes all the levels that constitute the split. A custom label can be set for this level via the custom_label argument.

    -
    custom_label
    +
    custom_label +

    (string or NULL)
    if provided and labelstr is empty, this will be used as label.

    -
    col_split
    +
    col_split +

    (flag)
    whether the columns should be split. Set to FALSE when the required column split has been done already earlier in the layout pipe.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'n_patients', 'sum_exposure'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'n_patients', 'sum_exposure'

    +
    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .N_col
    +
    .N_col +

    (integer(1))
    column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    + +
    -

    Value

    +

    Value +

    -
    • analyze_patients_exposure_in_cols() returns a layout object suitable for passing to further +

        +
      • analyze_patients_exposure_in_cols() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted data rows, with the statistics from s_count_patients_sum_exposure() arranged in columns, to the table layout.

      • -
      • summarize_patients_exposure_in_cols() returns a layout object suitable for passing to further +

      +
        +
      • summarize_patients_exposure_in_cols() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted content rows, with the statistics from s_count_patients_sum_exposure() arranged in columns, to the table layout.

      • -
      • s_count_patients_sum_exposure() returns a named list with the statistics:

        • n_patients: Number of unique patients in df.

        • +
        +
          +
        • +

          s_count_patients_sum_exposure() returns a named list with the statistics:

          +
            +
          • n_patients: Number of unique patients in df.

          • sum_exposure: Sum of ex_var across all patients in df.

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • analyze_patients_exposure_in_cols(): Layout-creating function which can take statistics +

    + +
    -

    Note

    +

    Note +

    As opposed to summarize_patients_exposure_in_cols() which generates content rows, analyze_patients_exposure_in_cols() generates data rows which will not be repeated on multiple pages when pagination is used.

    -

    Examples

    +

    Examples +

    set.seed(1)
     df <- data.frame(
       USUBJID = c(paste("id", seq(1, 12), sep = "")),
    @@ -366,17 +469,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/survival_biomarkers_subgroups.html b/main/reference/survival_biomarkers_subgroups.html index 29d2de1ec2..85f0055448 100644 --- a/main/reference/survival_biomarkers_subgroups.html +++ b/main/reference/survival_biomarkers_subgroups.html @@ -1,15 +1,38 @@ - -Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups • tern + + + + + +Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups • tern + + + + + + + + + + + + + +A forest plot can be created from the resulting table using the g_forest() function."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    tabulate_survival_biomarkers(
       df,
       vars = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"),
    @@ -80,81 +144,104 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    df
    +
    +
    df +

    (data.frame)
    containing all analysis variables, as returned by extract_survival_biomarkers().

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n_tot_events: Total number of events per group.

    • +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n_tot_events: Total number of events per group.

      • n_tot: Total number of observations per group.

      • median: Median survival time.

      • hr: Hazard ratio.

      • ci: Confidence interval of hazard ratio.

      • pval: p-value of the effect. Note, one of the statistics n_tot and n_tot_events, as well as both hr and ci are required.

      • -
      +
    +
    -
    groups_lists
    +
    groups_lists +

    (named list of list)
    optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

    -
    control
    +
    control +

    (list)
    a list of parameters as returned by the helper function control_coxreg().

    -
    label_all
    +
    label_all +

    [Deprecated]
    please assign the label_all parameter within the extract_survival_biomarkers() function when creating df.

    -
    time_unit
    +
    time_unit +

    (string)
    label with unit of median survival time. Default NULL skips displaying unit.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    + +
    -

    Value

    +

    Value +

    An rtables table summarizing biomarker effects on survival by subgroup.

    -

    Details

    +

    Details +

    These functions create a layout starting from a data frame which contains the required statistics. The tables are then typically used as input for forest plots.

    -

    Functions

    +

    Functions +

    -
    • tabulate_survival_biomarkers(): Table-creating function which creates a table +

        +
      • tabulate_survival_biomarkers(): Table-creating function which creates a table summarizing biomarker effects on survival by subgroup.

      • -
    + +
    -

    Note

    +

    Note +

    In contrast to tabulate_survival_subgroups() this tabulation function does not start from an input layout lyt. This is because internally the table is created by combining multiple subtables.

    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte <- tern_ex_adtte
    @@ -298,17 +385,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/survival_coxph_pairwise.html b/main/reference/survival_coxph_pairwise.html index 0349158020..a05718d8fa 100644 --- a/main/reference/survival_coxph_pairwise.html +++ b/main/reference/survival_coxph_pairwise.html @@ -1,13 +1,36 @@ - -Analyze a pairwise Cox-PH model — survival_coxph_pairwise • tern + + + + + +Analyze a pairwise Cox-PH model — survival_coxph_pairwise • tern + + + + + + + + + + + + + +any stratification factors via the strata argument."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    coxph_pairwise(
       lyt,
       vars,
    @@ -105,128 +169,172 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    strata
    +
    strata +

    (character or NULL)
    variable names indicating stratification factors.

    -
    control
    -

    (list)
    parameters for comparison details, specified by using the helper function -control_coxph(). Some possible parameter options are:

    • pval_method (string)
      p-value method for testing the null hypothesis that hazard ratio = 1. Default +

      control +
      +
      +

      (list)
      parameters for comparison details, specified by using the helper function +control_coxph(). Some possible parameter options are:

      +
        +
      • pval_method (string)
        p-value method for testing the null hypothesis that hazard ratio = 1. Default method is "log-rank" which comes from survival::survdiff(), can also be set to "wald" or "likelihood" (from survival::coxph()).

      • ties (string)
        specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in survival::coxph().

      • conf_level (proportion)
        confidence level of the interval for HR.

      • -
      +
    +
    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'pvalue', 'hr', 'hr_ci', 'n_tot', 'n_tot_events'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'pvalue', 'hr', 'hr_ci', 'n_tot', 'n_tot_events'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    is_event
    +
    is_event +

    (flag)
    TRUE if event, FALSE if time to event is censored.

    -
    strat
    +
    strat +

    [Deprecated] Please use the strata argument instead.

    -
    + +
    -

    Value

    +

    Value +

    -
    • coxph_pairwise() returns a layout object suitable for passing to further layouting functions, +

        +
      • coxph_pairwise() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_coxph_pairwise() to the table layout.

      • -
      • s_coxph_pairwise() returns the statistics:

        • pvalue: p-value to test the null hypothesis that hazard ratio = 1.

        • +
        +
          +
        • +

          s_coxph_pairwise() returns the statistics:

          +
            +
          • pvalue: p-value to test the null hypothesis that hazard ratio = 1.

          • hr: Hazard ratio.

          • hr_ci: Confidence interval for hazard ratio.

          • n_tot: Total number of observations.

          • n_tot_events: Total number of events.

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • coxph_pairwise(): Layout-creating function which can take statistics function arguments +

        +
      • coxph_pairwise(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_coxph_pairwise(): Statistics function which analyzes HR, CIs of HR, and p-value of a Cox-PH model.

      • a_coxph_pairwise(): Formatted analysis function which is used as afun in coxph_pairwise().

      • -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte_f <- tern_ex_adtte %>%
    @@ -275,17 +383,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/survival_duration_subgroups.html b/main/reference/survival_duration_subgroups.html index e7009ebd7a..071714594f 100644 --- a/main/reference/survival_duration_subgroups.html +++ b/main/reference/survival_duration_subgroups.html @@ -1,15 +1,38 @@ - -Tabulate survival duration by subgroup — survival_duration_subgroups • tern + + + + + +Tabulate survival duration by subgroup — survival_duration_subgroups • tern + + + + + + + + + + + + + +A forest plot can be created from the resulting table using the g_forest() function."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,7 +129,8 @@
    -

    Usage

    +

    Usage +

    tabulate_survival_subgroups(
       lyt,
       df,
    @@ -90,20 +154,28 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    df
    +
    df +

    (list)
    list of data frames containing all analysis variables. List should be created using extract_survival_subgroups().

    -
    vars
    -

    (character)
    the names of statistics to be reported among:

    • n_tot_events: Total number of events per group.

    • +
      vars +
      +
      +

      (character)
      the names of statistics to be reported among:

      +
        +
      • n_tot_events: Total number of events per group.

      • n_events: Number of events per group.

      • n_tot: Total number of observations per group.

      • n: Number of observations per group.

      • @@ -113,66 +185,83 @@

        Argumentsgroups_lists +
        groups_lists +

        (named list of list)
        optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

        -
        label_all
        +
        label_all +

        [Deprecated]
        please assign the label_all parameter within the extract_survival_subgroups() function when creating df.

        -
        time_unit
        +
        time_unit +

        (string)
        label with unit of median survival time. Default NULL skips displaying unit.

        -
        riskdiff
        +
        riskdiff +

        (list)
        if a risk (proportion) difference column should be added, a list of settings to apply within the column. See control_riskdiff() for details. If NULL, no risk difference column will be added. If riskdiff$arm_x and riskdiff$arm_y are NULL, the first level of df$survtime$arm will be used as arm_x and the second level as arm_y.

        -
        na_str
        +
        na_str +

        (string)
        string used to replace all NA or empty values in the output.

        -
        .formats
        +
        .formats +

        (named character or list)
        formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

        -

    + +
    -

    Value

    +

    Value +

    An rtables table summarizing survival by subgroup.

    -
    + +
    -

    Details

    +

    Details +

    These functions create a layout starting from a data frame which contains the required statistics. Tables typically used as part of forest plot.

    -

    Functions

    +

    Functions +

    -
    • tabulate_survival_subgroups(): Table-creating function which creates a table +

        +
      • tabulate_survival_subgroups(): Table-creating function which creates a table summarizing survival by subgroup. This function is a wrapper for rtables::analyze_colvars() and rtables::summarize_row_groups().

      • a_survival_subgroups(): Formatted analysis function which is used as afun in tabulate_survival_subgroups().

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte <- tern_ex_adtte
    @@ -368,17 +457,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/survival_time.html b/main/reference/survival_time.html index f64e9fe055..6e6cbce2bc 100644 --- a/main/reference/survival_time.html +++ b/main/reference/survival_time.html @@ -1,13 +1,36 @@ - -Survival time analysis — survival_time • tern + + + + + +Survival time analysis — survival_time • tern + + + + + + + + + + + + + +not an event has occurred."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    surv_time(
       lyt,
       vars,
    @@ -101,108 +165,143 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    is_event
    +
    is_event +

    (flag)
    TRUE if event, FALSE if time to event is censored.

    -
    control
    -

    (list)
    parameters for comparison details, specified by using the helper function -control_surv_time(). Some possible parameter options are:

    • conf_level (proportion)
      confidence level of the interval for survival time.

    • +
      control +
      +
      +

      (list)
      parameters for comparison details, specified by using the helper function +control_surv_time(). Some possible parameter options are:

      +
        +
      • conf_level (proportion)
        confidence level of the interval for survival time.

      • conf_type (string)
        confidence interval type. Options are "plain" (default), "log", or "log-log", see more in survival::survfit(). Note option "none" is not supported.

      • quantiles (numeric)
        vector of length two to specify the quantiles of survival time.

      • -
      +
    +
    -
    ref_fn_censor
    +
    ref_fn_censor +

    (flag)
    whether referential footnotes indicating censored observations should be printed when the range statistic is included.

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    table_names
    +
    table_names +

    (character)
    this can be customized in the case that the same vars are analyzed multiple times, to avoid warnings from rtables.

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'median', 'median_ci', 'median_ci_3d', 'quantiles', 'quantiles_lower', 'quantiles_upper', 'range_censor', 'range_event', 'range'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'median', 'median_ci', 'median_ci_3d', 'quantiles', 'quantiles_lower', 'quantiles_upper', 'range_censor', 'range_event', 'range'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Each element of the vector should be a name-value pair with name corresponding to a statistic specified in .stats and value the indentation for that statistic's row label.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    labelstr
    +
    labelstr +

    (string)
    label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

    -
    .df_row
    +
    .df_row +

    (data.frame)
    data frame across all of the columns for the given row split.

    -
    + +
    -

    Value

    +

    Value +

    -
    • surv_time() returns a layout object suitable for passing to further layouting functions, +

        +
      • surv_time() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_surv_time() to the table layout.

      • -
      • s_surv_time() returns the statistics:

        • median: Median survival time.

        • +
        +
          +
        • +

          s_surv_time() returns the statistics:

          +
            +
          • median: Median survival time.

          • median_ci: Confidence interval for median time.

          • median_ci_3d: Median with confidence interval for median time.

          • quantiles: Survival time for two specified quantiles.

          • @@ -211,20 +310,28 @@

            Value

            range_censor: Survival time range for censored observations.

          • range_event: Survival time range for observations with events.

          • range: Survival time range for all observations.

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • surv_time(): Layout-creating function which can take statistics function arguments +

        +
      • surv_time(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_surv_time(): Statistics function which analyzes survival times.

      • a_surv_time(): Formatted analysis function which is used as afun in surv_time().

      • -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte_f <- tern_ex_adtte %>%
    @@ -276,17 +383,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/survival_timepoint.html b/main/reference/survival_timepoint.html index 3eb9b67cc4..20c617b148 100644 --- a/main/reference/survival_timepoint.html +++ b/main/reference/survival_timepoint.html @@ -1,17 +1,40 @@ - -Survival time point analysis — survival_timepoint • tern + +("both").'> + + + + + Skip to contents @@ -27,26 +50,66 @@ + + @@ -69,7 +132,8 @@
    -

    Usage

    +

    Usage +

    surv_timepoint(
       lyt,
       vars,
    @@ -133,127 +197,177 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    lyt
    +
    +
    lyt +

    (PreDataTableLayouts)
    layout that analyses will be added to.

    -
    vars
    +
    vars +

    (character)
    variable names for the primary analysis variable to be iterated over.

    -
    time_point
    +
    time_point +

    (numeric(1))
    survival time point of interest.

    -
    is_event
    +
    is_event +

    (flag)
    TRUE if event, FALSE if time to event is censored.

    -
    control
    -

    (list)
    parameters for comparison details, specified by using the helper function -control_surv_timepoint(). Some possible parameter options are:

    • conf_level (proportion)
      confidence level of the interval for survival rate.

    • +
      control +
      +
      +

      (list)
      parameters for comparison details, specified by using the helper function +control_surv_timepoint(). Some possible parameter options are:

      +
        +
      • conf_level (proportion)
        confidence level of the interval for survival rate.

      • conf_type (string)
        confidence interval type. Options are "plain" (default), "log", "log-log", see more in survival::survfit(). Note option "none" is no longer supported.

      • -
      +
    +
    -
    method
    +
    method +

    (string)
    "surv" (survival estimations), "surv_diff" (difference in survival with the control), or "both".

    -
    na_str
    +
    na_str +

    (string)
    string used to replace all NA or empty values in the output.

    -
    nested
    +
    nested +

    (flag)
    whether this layout instruction should be applied within the existing layout structure _if possible (TRUE, the default) or as a new top-level element (FALSE). Ignored if it would nest a split. underneath analyses, which is not allowed.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    table_names_suffix
    +
    table_names_suffix +

    (string)
    optional suffix for the table_names used for the rtables to avoid warnings from duplicate table names.

    -
    var_labels
    +
    var_labels +

    (character)
    variable labels.

    -
    show_labels
    +
    show_labels +

    (string)
    label visibility: one of "default", "visible" and "hidden".

    -
    .stats
    -

    (character)
    statistics to select for the table.

    -

    Options are: 'pt_at_risk', 'event_free_rate', 'rate_se', 'rate_ci', 'rate_diff', 'rate_diff_ci', 'ztest_pval', 'event_free_rate_3d'

    +
    .stats +
    +
    +

    (character)
    statistics to select for the table.

    +

    Options are: 'pt_at_risk', 'event_free_rate', 'rate_se', 'rate_ci', 'rate_diff', 'rate_diff_ci', 'ztest_pval', 'event_free_rate_3d'

    +
    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Each element of the vector should be a name-value pair with name corresponding to a statistic specified in .stats and value the indentation for that statistic's row label.

    -
    df
    +
    df +

    (data.frame)
    data set containing all analysis variables.

    -
    .var
    +
    .var +

    (string)
    single variable name that is passed by rtables when requested by a statistics function.

    -
    .ref_group
    +
    .ref_group +

    (data.frame or vector)
    the data corresponding to the reference group.

    -
    .in_ref_col
    +
    .in_ref_col +

    (flag)
    TRUE when working with the reference level, FALSE otherwise.

    -
    + +
    -

    Value

    +

    Value +

    -
    • surv_timepoint() returns a layout object suitable for passing to further layouting functions, +

        +
      • surv_timepoint() returns a layout object suitable for passing to further layouting functions, or to rtables::build_table(). Adding this function to an rtable layout will add formatted rows containing the statistics from s_surv_timepoint() and/or s_surv_timepoint_diff() to the table layout depending on the value of method.

      • -
      • s_surv_timepoint() returns the statistics:

        • pt_at_risk: Patients remaining at risk.

        • +
        +
          +
        • +

          s_surv_timepoint() returns the statistics:

          +
            +
          • pt_at_risk: Patients remaining at risk.

          • event_free_rate: Event-free rate (%).

          • rate_se: Standard error of event free rate.

          • rate_ci: Confidence interval for event free rate.

          • event_free_rate_3d: Event-free rate (%) with Confidence interval.

          • -
        • -
        • s_surv_timepoint_diff() returns the statistics:

          • rate_diff: Event-free rate difference between two groups.

          • +
          +
        • +
        + +
          +
        • +

          s_surv_timepoint_diff() returns the statistics:

          +
            +
          • rate_diff: Event-free rate difference between two groups.

          • rate_diff_ci: Confidence interval for the difference.

          • rate_diff_ci_3d: Event-free rate difference and confidence interval between two groups.

          • ztest_pval: p-value to test the difference is 0.

          • -
        • -
    + + + + +
    -

    Functions

    +

    Functions +

    -
    • surv_timepoint(): Layout-creating function which can take statistics function arguments +

        +
      • surv_timepoint(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper for rtables::analyze().

      • s_surv_timepoint(): Statistics function which analyzes survival rate.

      • a_surv_timepoint(): Formatted analysis function which is used as afun in surv_timepoint() @@ -261,10 +375,12 @@

        Functions.

      • -
    + +
    -

    Examples

    +

    Examples +

    library(dplyr)
     
     adtte_f <- tern_ex_adtte %>%
    @@ -340,17 +456,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/tern-package.html b/main/reference/tern-package.html index 0a20836554..807be95481 100644 --- a/main/reference/tern-package.html +++ b/main/reference/tern-package.html @@ -1,5 +1,28 @@ - -tern Package — tern-package • tern + + + + + + +tern Package — tern-package • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -52,16 +115,24 @@
    -

    Author

    +

    Author +

    Maintainer: Joe Zhu joe.zhu@roche.com

    -

    Authors:

    + +

    Other contributors:

    +
      +
    • F. Hoffmann-La Roche AG [copyright holder, funder]

    • +
    + + + - + + - + + diff --git a/main/reference/tidy.glm.html b/main/reference/tidy.glm.html index dc4831dec7..dbead78356 100644 --- a/main/reference/tidy.glm.html +++ b/main/reference/tidy.glm.html @@ -1,9 +1,32 @@ - -Custom tidy method for binomial GLM results — tidy.glm • tern + + + + + +Custom tidy method for binomial GLM results — tidy.glm • tern + + + + + + + + + + + + + +with binomial family."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,42 +120,53 @@
    -

    Usage

    +

    Usage +

    # S3 method for class 'glm'
     tidy(x, conf_level = 0.95, at = NULL, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (glm)
    logistic regression model fitted by stats::glm() with "binomial" family.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    at
    +
    at +

    (numeric or NULL)
    optional values for the interaction variable. Otherwise the median is used.

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    + +
    -

    Value

    +

    Value +

    A data.frame containing the tidied model.

    -

    See also

    +

    See also +

    h_logistic_regression for relevant helper functions.

    -

    Examples

    +

    Examples +

    library(dplyr)
     library(broom)
     
    @@ -131,17 +205,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/tidy.step.html b/main/reference/tidy.step.html index 119c4cf5f2..6e6324cf20 100644 --- a/main/reference/tidy.step.html +++ b/main/reference/tidy.step.html @@ -1,7 +1,30 @@ - -Custom tidy method for STEP results — tidy.step • tern + + + + + + +Custom tidy method for STEP results — tidy.step • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,35 +117,44 @@
    -

    Usage

    +

    Usage +

    # S3 method for class 'step'
     tidy(x, ...)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (matrix)
    results from fit_survival_step().

    -
    ...
    +
    ... +

    not used.

    -
    + +
    -

    Value

    +

    Value +

    A tibble with one row per STEP subgroup. The estimates and CIs are on the HR or OR scale, respectively. Additional attributes carry metadata also used for plotting.

    -

    See also

    +

    See also +

    g_step() which consumes the result from this function.

    -

    Examples

    +

    Examples +

    library(survival)
     lung$sex <- factor(lung$sex)
     vars <- list(
    @@ -117,17 +189,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/tidy_coxreg.html b/main/reference/tidy_coxreg.html index 60c3042743..a59247d114 100644 --- a/main/reference/tidy_coxreg.html +++ b/main/reference/tidy_coxreg.html @@ -1,5 +1,28 @@ - -Custom tidy methods for Cox regression — tidy_coxreg • tern + + + + + + +Custom tidy methods for Cox regression — tidy_coxreg • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,7 +114,8 @@
    -

    Usage

    +

    Usage +

    # S3 method for class 'summary.coxph'
     tidy(x, ...)
     
    @@ -63,44 +127,64 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (list)
    result of the Cox regression model fitted by fit_coxreg_univar() (for univariate models) or fit_coxreg_multivar() (for multivariate models).

    -
    ...
    +
    ... +

    additional arguments for the lower level functions.

    -
    + +
    -

    Value

    -

    broom::tidy() returns:

    • For summary.coxph objects, a data.frame with columns: Pr(>|z|), exp(coef), exp(-coef), lower .95, +

      Value +

      +

      broom::tidy() returns:

      +
        +
      • For summary.coxph objects, a data.frame with columns: Pr(>|z|), exp(coef), exp(-coef), lower .95, upper .95, level, and n.

      • For coxreg.univar objects, a data.frame with columns: effect, term, term_label, level, n, hr, lcl, ucl, pval, and ci.

      • For coxreg.multivar objects, a data.frame with columns: term, pval, term_label, hr, lcl, ucl, level, and ci.

      • -
    + +
    -

    Functions

    - -
    • tidy(summary.coxph): Custom tidy method for survival::coxph() summary results.

      -

      Tidy the survival::coxph() results into a data.frame to extract model results.

    • -
    • tidy(coxreg.univar): Custom tidy method for a univariate Cox regression.

      -

      Tidy up the result of a Cox regression model fitted by fit_coxreg_univar().

    • -
    • tidy(coxreg.multivar): Custom tidy method for a multivariate Cox regression.

      -

      Tidy up the result of a Cox regression model fitted by fit_coxreg_multivar().

    • -
    +

    Functions +

    + +
      +
    • +

      tidy(summary.coxph): Custom tidy method for survival::coxph() summary results.

      +

      Tidy the survival::coxph() results into a data.frame to extract model results.

      +
    • +
    • +

      tidy(coxreg.univar): Custom tidy method for a univariate Cox regression.

      +

      Tidy up the result of a Cox regression model fitted by fit_coxreg_univar().

      +
    • +
    • +

      tidy(coxreg.multivar): Custom tidy method for a multivariate Cox regression.

      +

      Tidy up the result of a Cox regression model fitted by fit_coxreg_multivar().

      +
    • +
    +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(survival)
     library(broom)
     
    @@ -221,17 +305,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/to_n.html b/main/reference/to_n.html index cd811f2ff5..e9b310439c 100644 --- a/main/reference/to_n.html +++ b/main/reference/to_n.html @@ -1,7 +1,30 @@ - -Replicate entries of a vector if required — to_n • tern + + + + + + +Replicate entries of a vector if required — to_n • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -17,26 +40,66 @@ + + @@ -54,44 +117,54 @@
    -

    Usage

    +

    Usage +

    to_n(x, n)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (numeric)
    vector of numbers we want to analyze.

    -
    n
    +
    n +

    (integer(1))
    number of entries that are needed.

    -
    + +
    -

    Value

    +

    Value +

    x if it has the required length already or is NULL, otherwise if it is scalar the replicated version of it with n entries.

    -

    Note

    +

    Note +

    This function will fail if x is not of length n and/or is not a scalar.

    + + - + + - + + diff --git a/main/reference/to_string_matrix.html b/main/reference/to_string_matrix.html index 99ae452903..9ad3a265e6 100644 --- a/main/reference/to_string_matrix.html +++ b/main/reference/to_string_matrix.html @@ -1,13 +1,36 @@ - -Convert table into matrix of strings — to_string_matrix • tern + + + + + +Convert table into matrix of strings — to_string_matrix • tern + + + + + + + + + + + + + +formatted text that needs only to be copied and pasted in the expected output."> + + + + + Skip to contents @@ -23,26 +46,66 @@ + + @@ -63,7 +126,8 @@
    -

    Usage

    +

    Usage +

    to_string_matrix(
       x,
       widths = NULL,
    @@ -75,49 +139,60 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (VTableTree)
    rtables table object.

    -
    widths
    +
    widths +

    (numeric or NULL)
    Proposed widths for the columns of x. The expected length of this numeric vector can be retrieved with ncol(x) + 1 as the column of row names must also be considered.

    -
    max_width
    +
    max_width +

    (integer(1), string or NULL)
    width that title and footer (including footnotes) materials should be word-wrapped to. If NULL, it is set to the current print width of the session (getOption("width")). If set to "auto", the width of the table (plus any table inset) is used. Parameter is ignored if tf_wrap = FALSE.

    -
    hsep
    +
    hsep +

    (string)
    character to repeat to create header/body separator line. If NULL, the object value will be used. If " ", an empty separator will be printed. See default_hsep() for more information.

    -
    with_spaces
    +
    with_spaces +

    (flag)
    whether the tested table should keep the indentation and other relevant spaces.

    -
    print_txt_to_copy
    +
    print_txt_to_copy +

    (flag)
    utility to have a way to copy the input table directly into the expected variable instead of copying it too manually.

    -
    + +
    -

    Value

    +

    Value +

    A matrix of strings. If print_txt_to_copy = TRUE the well formatted printout of the table will be printed to console, ready to be copied as a expected value.

    -

    Examples

    +

    Examples +

    tbl <- basic_table() %>%
       split_rows_by("SEX") %>%
       split_cols_by("ARM") %>%
    @@ -136,17 +211,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/try_car_anova.html b/main/reference/try_car_anova.html index 4fa78d4876..a7809006b3 100644 --- a/main/reference/try_car_anova.html +++ b/main/reference/try_car_anova.html @@ -1,5 +1,28 @@ - -tryCatch around car::Anova — try_car_anova • tern + + + + + + +tryCatch around car::Anova — try_car_anova • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,33 +38,75 @@ + +
    @@ -51,21 +116,26 @@
    -

    Usage

    +

    Usage +

    try_car_anova(mod, test.statistic)
    -

    Arguments

    +

    Arguments +

    -
    mod
    +
    +
    mod +

    lm, aov, glm, multinom, polr mlm, coxph, coxme, lme, mer, merMod, svyglm, svycoxph, rlm, clm, clmm, or other suitable model object.

    -
    test.statistic
    +
    test.statistic +

    for a generalized linear model, whether to calculate "LR" (likelihood-ratio), "Wald", or "F" tests; for a Cox or Cox mixed-effects model, whether to calculate "LR" (partial-likelihood ratio) or @@ -79,14 +149,17 @@

    Arguments -

    Value

    +

    Value +

    A list with item aov for the result of the model and error_text for the captured warnings.

    -

    Examples

    +

    Examples +

    # `car::Anova` on cox regression model including strata and expected
     # a likelihood ratio test triggers a warning as only Wald method is
     # accepted.
    @@ -101,17 +174,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/ungroup_stats.html b/main/reference/ungroup_stats.html index 60625f7c2b..a77f46c49c 100644 --- a/main/reference/ungroup_stats.html +++ b/main/reference/ungroup_stats.html @@ -1,5 +1,28 @@ - -Ungroup non-numeric statistics — ungroup_stats • tern + + + + + + +Ungroup non-numeric statistics — ungroup_stats • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,53 +114,65 @@
    -

    Usage

    +

    Usage +

    ungroup_stats(x, .formats, .labels, .indent_mods)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (named list of numeric)
    list of numeric statistics containing the statistics to ungroup.

    -
    .formats
    +
    .formats +

    (named character or list)
    formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

    -
    .labels
    +
    .labels +

    (named character)
    labels for the statistics (without indent).

    -
    .indent_mods
    +
    .indent_mods +

    (named integer)
    indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

    -
    + +
    -

    Value

    +

    Value +

    A list with modified elements x, .formats, .labels, and .indent_mods.

    -

    See also

    +

    See also +

    a_summary() which uses this function internally.

    + + - + + - + + diff --git a/main/reference/univariate.html b/main/reference/univariate.html index 240587933d..3a4f87c84f 100644 --- a/main/reference/univariate.html +++ b/main/reference/univariate.html @@ -1,9 +1,32 @@ - -Univariate formula special term — univariate • tern + + + + + +Univariate formula special term — univariate • tern + + + + + + + + + + + + + +every variable included in univariate."> + + + + + Skip to contents @@ -19,26 +42,66 @@ + + @@ -57,43 +120,55 @@
    -

    Usage

    +

    Usage +

    univariate(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (character)
    a vector of variable names separated by commas.

    -
    + +
    -

    Value

    +

    Value +

    When used within a model formula, produces univariate models for each variable provided.

    -

    Details

    +

    Details +

    If provided alongside with pairwise specification, the model -y ~ ARM + univariate(SEX, AGE, RACE) lead to the study and comparison of the models

    • y ~ ARM

    • +y ~ ARM + univariate(SEX, AGE, RACE) lead to the study and comparison of the models

      +
        +
      • y ~ ARM

      • y ~ ARM + SEX

      • y ~ ARM + AGE

      • y ~ ARM + RACE

      • -
    + + + + - + + - + + diff --git a/main/reference/unlist_and_blank_na.html b/main/reference/unlist_and_blank_na.html index da33b4c21d..c5b1252d97 100644 --- a/main/reference/unlist_and_blank_na.html +++ b/main/reference/unlist_and_blank_na.html @@ -1,5 +1,28 @@ - -Blank for missing input — unlist_and_blank_na • tern + + + + + + +Blank for missing input — unlist_and_blank_na • tern + + + + + + + + + + + + + + + + + + Skip to contents @@ -15,26 +38,66 @@ + + @@ -51,36 +114,44 @@
    -

    Usage

    +

    Usage +

    unlist_and_blank_na(x)
    -

    Arguments

    +

    Arguments +

    -
    x
    +
    +
    x +

    (vector)
    input for a cell.

    -
    + +
    -

    Value

    +

    Value +

    An empty character vector if all entries in x are missing (NA), otherwise the unlisted version of x.

    + + - + + - + + diff --git a/main/reference/update_weights_strat_wilson.html b/main/reference/update_weights_strat_wilson.html index f9ee1670a9..18b0840b00 100644 --- a/main/reference/update_weights_strat_wilson.html +++ b/main/reference/update_weights_strat_wilson.html @@ -1,11 +1,34 @@ - -Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson • tern + + + + + +Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson • tern + + + + + + + + + + + + + +weighted squared length of the confidence interval."> + + + + + Skip to contents @@ -21,33 +44,74 @@ + +
    @@ -60,7 +124,8 @@
    -

    Usage

    +

    Usage +

    update_weights_strat_wilson(
       vars,
       strata_qnorm,
    @@ -73,49 +138,62 @@ 

    Usage

    -

    Arguments

    +

    Arguments +

    -
    vars
    +
    +
    vars +

    (numeric)
    normalized proportions for each strata.

    -
    strata_qnorm
    +
    strata_qnorm +

    (numeric(1))
    initial estimation with identical weights of the quantiles.

    -
    initial_weights
    +
    initial_weights +

    (numeric)
    initial weights used to calculate strata_qnorm. This can be optimized in the future if we need to estimate better initial weights.

    -
    n_per_strata
    +
    n_per_strata +

    (numeric)
    number of elements in each strata.

    -
    max_iterations
    +
    max_iterations +

    (integer(1))
    maximum number of iterations to be tried. Convergence is always checked.

    -
    conf_level
    +
    conf_level +

    (proportion)
    confidence level of the interval.

    -
    tol
    +
    tol +

    (numeric(1))
    tolerance threshold for convergence.

    -
    + +
    -

    Value

    +

    Value +

    A list of 3 elements: n_it, weights, and diff_v.

    -

    See also

    +

    See also +

    For references and details see prop_strat_wilson().

    -

    Examples

    +

    Examples +

    vs <- c(0.011, 0.013, 0.012, 0.014, 0.017, 0.018)
     sq <- 0.674
     ws <- rep(1 / length(vs), length(vs))
    @@ -135,17 +213,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/reference/util_handling_additional_fun_params.html b/main/reference/util_handling_additional_fun_params.html index 7ca92bb876..446af3405e 100644 --- a/main/reference/util_handling_additional_fun_params.html +++ b/main/reference/util_handling_additional_fun_params.html @@ -1,15 +1,38 @@ - -Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params • tern + + + + + +Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params • tern + + + + + + + + + + + + + +will get them through argument matching."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,52 +129,68 @@
    -

    Usage

    +

    Usage +

    retrieve_extra_afun_params(extra_afun_params)
     
     get_additional_afun_params(add_alt_df = FALSE)
    -

    Arguments

    +

    Arguments +

    -
    extra_afun_params
    +
    +
    extra_afun_params +

    (list)
    list of additional parameters (character) to be retrieved from the environment. Curated list is present in rtables::additional_fun_params.

    -
    add_alt_df
    +
    add_alt_df +

    (logical)
    if TRUE, the function will also add .alt_df and .alt_df_row parameters.

    -
    + +
    -

    Value

    - -
    • retrieve_extra_afun_params returns a list of the values of the parameters in the environment.

    • -
    • get_additional_afun_params returns a list of additional parameters.

    • -
    +

    Value +

    + +
      +
    • retrieve_extra_afun_params returns a list of the values of the parameters in the environment.

    • +
    +
      +
    • get_additional_afun_params returns a list of additional parameters.

    • +
    +
    -

    Functions

    +

    Functions +

    -
    • retrieve_extra_afun_params(): Retrieve additional parameters from the environment.

    • +
        +
      • retrieve_extra_afun_params(): Retrieve additional parameters from the environment.

      • get_additional_afun_params(): Curated list of additional parameters for analysis functions. Please check rtables::additional_fun_params for precise descriptions.

      • -
    + + + + - + + - + + diff --git a/main/reference/utils_split_funs.html b/main/reference/utils_split_funs.html index 353357d8fe..ec48db8190 100644 --- a/main/reference/utils_split_funs.html +++ b/main/reference/utils_split_funs.html @@ -1,15 +1,38 @@ - -Custom split functions — utils_split_funs • tern + + + + + +Custom split functions — utils_split_funs • tern + + + + + + + + + + + + + +happens. For other split functions, consider consulting rtables::split_funcs."> + + + + + Skip to contents @@ -25,26 +48,66 @@ + + @@ -66,48 +129,64 @@
    -

    Usage

    +

    Usage +

    ref_group_position(position = "first")
     
     level_order(order)
    -

    Arguments

    +

    Arguments +

    -
    position
    +
    +
    position +

    (string or integer)
    position to use for the reference group facet. Can be "first", "last", or a specific position.

    -
    order
    +
    order +

    (character or numeric)
    vector of ordering indices for the split facets.

    -
    + +
    -

    Value

    +

    Value +

    -
    • ref_group_position() returns an utility function that puts the reference group +

        +
      • ref_group_position() returns an utility function that puts the reference group as first, last or at a certain position and needs to be assigned to split_fun.

      • -
      • level_order() returns an utility function that changes the original levels' order, +

      +
        +
      • level_order() returns an utility function that changes the original levels' order, depending on input order and split levels.

      • -
    + +
    -

    Functions

    +

    Functions +

    -
    • ref_group_position(): Split function to place reference group facet at a specific position +

        +
      • ref_group_position(): Split function to place reference group facet at a specific position during post-processing stage.

      • level_order(): Split function to change level order based on an integer vector or a character vector that represent the split variable's factor levels.

      • -
    + +
    -

    See also

    +

    See also +

    -

    Examples

    +

    Examples +

    library(dplyr)
     
     dat <- data.frame(
    @@ -191,17 +270,19 @@ 

    Examples

    + +
    - + + - + + diff --git a/main/search.json b/main/search.json index f914116a17..278bd1e2e9 100644 --- a/main/search.json +++ b/main/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement [INSERT CONTACT METHOD]. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired Mozilla’s code conduct enforcement ladder. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contribution Guidelines","title":"Contribution Guidelines","text":"🙏 Thank taking time contribute! input deeply valued, whether issue, pull request, even feedback, regardless size, content scope.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"table-of-contents","dir":"","previous_headings":"","what":"Table of contents","title":"Contribution Guidelines","text":"👶 Getting started 📔 Code Conduct 🗃 License 📜 Issues 🚩 Pull requests 💻 Coding guidelines 🏆 Recognition model ❓ Questions","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Contribution Guidelines","text":"Please refer project documentation brief introduction. Please also see articles within project documentation additional information.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contribution Guidelines","text":"Code Conduct governs project. Participants contributors expected follow rules outlined therein.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"license","dir":"","previous_headings":"","what":"License","title":"Contribution Guidelines","text":"contributions covered project’s license.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"issues","dir":"","previous_headings":"","what":"Issues","title":"Contribution Guidelines","text":"use GitHub track issues, feature requests, bugs. submitting new issue, please check issue already reported. issue already exists, please upvote existing issue 👍. new feature requests, please elaborate context benefit feature users, developers, relevant personas.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"github-flow","dir":"","previous_headings":"Pull requests","what":"GitHub Flow","title":"Contribution Guidelines","text":"repository uses GitHub Flow model collaboration. submit pull request: Create branch Please see branch naming convention . don’t write access repository, please fork . Make changes Make sure code passes checks imposed GitHub Actions well documented well tested unit tests sufficiently covering changes introduced Create pull request (PR) pull request description, please link relevant issue (), provide detailed description change, include assumptions. Address review comments, Post approval Merge PR write access. Otherwise, reviewer merge PR behalf. Pat back Congratulations! 🎉 now official contributor project! grateful contribution.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"branch-naming-convention","dir":"","previous_headings":"Pull requests","what":"Branch naming convention","title":"Contribution Guidelines","text":"Suppose changes related current issue current project; please name branch follows: _. Please use underscore (_) delimiter word separation. example, 420_fix_ui_bug suitable branch name change resolving UI-related bug reported issue number 420 current project. change affects multiple repositories, please name branches follows: __. example, 69_awesomeproject_fix_spelling_error reference issue 69 reported project awesomeproject aims resolve one spelling errors multiple (likely related) repositories.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"monorepo-and-stageddependencies","dir":"","previous_headings":"Pull requests","what":"monorepo and staged.dependencies","title":"Contribution Guidelines","text":"Sometimes might need change upstream dependent package(s) able submit meaningful change. using staged.dependencies functionality simulate monorepo behavior. dependency configuration already specified project’s staged_dependencies.yaml file. need name feature branches appropriately. exception branch naming convention described . Please refer staged.dependencies package documentation details.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"coding-guidelines","dir":"","previous_headings":"","what":"Coding guidelines","title":"Contribution Guidelines","text":"repository follows unified processes standards adopted maintainers ensure software development carried consistently within teams cohesively across repositories.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"style-guide","dir":"","previous_headings":"Coding guidelines","what":"Style guide","title":"Contribution Guidelines","text":"repository follows standard tidyverse style guide uses lintr lint checks. Customized lint configurations available repository’s .lintr file.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"dependency-management","dir":"","previous_headings":"Coding guidelines","what":"Dependency management","title":"Contribution Guidelines","text":"Lightweight right weight. repository follows tinyverse recommedations limiting dependencies minimum.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"dependency-version-management","dir":"","previous_headings":"Coding guidelines","what":"Dependency version management","title":"Contribution Guidelines","text":"code compatible (!) historical versions given dependenct package, required specify minimal version DESCRIPTION file. particular: development version requires (imports) development version another package - required put abc (>= 1.2.3.9000).","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"r--package-versions","dir":"","previous_headings":"Coding guidelines > Recommended development environment & tools","what":"R & package versions","title":"Contribution Guidelines","text":"continuously test packages newest R version along recent dependencies CRAN BioConductor. recommend working environment also set way. can find details R version packages used R CMD check GitHub Action execution log - step prints R sessionInfo(). discover bugs older R versions older set dependencies, please create relevant bug reports.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"pre-commit","dir":"","previous_headings":"Coding guidelines > Recommended development environment & tools","what":"pre-commit","title":"Contribution Guidelines","text":"highly recommend use pre-commit tool combined R hooks pre-commit execute checks committing pushing changes. Pre-commit hooks already available repository’s .pre-commit-config.yaml file.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"recognition-model","dir":"","previous_headings":"","what":"Recognition model","title":"Contribution Guidelines","text":"mentioned previously, contributions deeply valued appreciated. contribution data available part repository insights, recognize significant contribution hence add contributor package authors list, following rules enforced: Minimum 5% lines code authored* (determined git blame query) top 5 contributors terms number commits lines added lines removed* *Excluding auto-generated code, including limited roxygen comments renv.lock files. package maintainer also reserves right adjust criteria recognize contributions.","code":""},{"path":"https://insightsengineering.github.io/tern/CONTRIBUTING.html","id":"questions","dir":"","previous_headings":"","what":"Questions","title":"Contribution Guidelines","text":"questions regarding contribution guidelines, please contact package/repository maintainer.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/SECURITY.html","id":"reporting-security-issues","dir":"","previous_headings":"","what":"Reporting Security Issues","title":"Security Policy","text":"believe found security vulnerability repositories organization, please report us coordinated disclosure. Please report security vulnerabilities public GitHub issues, discussions, pull requests. Instead, please send email vulnerability.management[@]roche.com. Please include much information listed can help us better understand resolve issue: type issue (e.g., buffer overflow, SQL injection, cross-site scripting) Full paths source file(s) related manifestation issue location affected source code (tag/branch/commit direct URL) special configuration required reproduce issue Step--step instructions reproduce issue Proof--concept exploit code (possible) Impact issue, including attacker might exploit issue information help us triage report quickly.","code":""},{"path":"https://insightsengineering.github.io/tern/SECURITY.html","id":"data-security-standards-dss","dir":"","previous_headings":"","what":"Data Security Standards (DSS)","title":"Security Policy","text":"Please make sure reporting issues form bug, feature, pull request, sensitive information PII, PHI, PCI completely removed text attachments, including pictures videos.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/missing_values.html","id":"variable-class-conversion","dir":"Articles","previous_headings":"","what":"Variable Class Conversion","title":"Missing Values in Tern","text":"rtables requires split variables factors. try split variable isn’t, warning message appear. purposefully convert SEX variable character demonstrate happens try splitting rows variable. fix , df_explict_na convert factor resulting table generated.","code":"adsl <- tern_ex_adsl adsl$SEX <- as.character(adsl$SEX) vars <- c(\"AGE\", \"SEX\", \"RACE\", \"BMRKR1\") var_labels <- c( \"Age (yr)\", \"Sex\", \"Race\", \"Continous Level Biomarker 1\" ) result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 69 73 58 200 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) 35.3 (7.1) #> Median 32.8 35.4 36.2 34.8 #> Min - Max 22.4 - 48.0 23.3 - 57.5 23.0 - 58.3 22.4 - 58.3 #> Sex #> n 69 73 58 200 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) 110 (55%) #> M 31 (44.9%) 33 (45.2%) 26 (44.8%) 90 (45%) #> Race #> n 69 73 58 200 #> ASIAN 38 (55.1%) 43 (58.9%) 29 (50%) 110 (55%) #> BLACK OR AFRICAN AMERICAN 15 (21.7%) 13 (17.8%) 12 (20.7%) 40 (20%) #> WHITE 11 (15.9%) 12 (16.4%) 11 (19%) 34 (17%) #> AMERICAN INDIAN OR ALASKA NATIVE 4 (5.8%) 3 (4.1%) 6 (10.3%) 13 (6.5%) #> MULTIPLE 1 (1.4%) 1 (1.4%) 0 2 (1%) #> NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (1.4%) 0 1 (0.5%) #> OTHER 0 0 0 0 #> UNKNOWN 0 0 0 0 #> Continous Level Biomarker 1 #> n 69 73 58 200 #> Mean (SD) 6.3 (3.6) 6.7 (3.5) 6.2 (3.3) 6.4 (3.5) #> Median 5.4 6.3 5.4 5.6 #> Min - Max 0.4 - 17.8 1.0 - 18.5 2.4 - 19.1 0.4 - 19.1"},{"path":"https://insightsengineering.github.io/tern/articles/missing_values.html","id":"including-missing-values-in-rtables","dir":"Articles","previous_headings":"","what":"Including Missing Values in rtables","title":"Missing Values in Tern","text":"purposefully convert M values NA SEX variable. running df_explicit_na NA values encoded included table. well, missing values included n count included denominator value calculating percent values. want Na values displayed table included n count denominator calculating percent values, use na_level argument.","code":"adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl) vars <- c(\"AGE\", \"SEX\") var_labels <- c( \"Age (yr)\", \"Sex\" ) result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ——————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 69 73 58 200 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) 35.3 (7.1) #> Median 32.8 35.4 36.2 34.8 #> Min - Max 22.4 - 48.0 23.3 - 57.5 23.0 - 58.3 22.4 - 58.3 #> Sex #> n 38 40 32 110 #> F 38 (100%) 40 (100%) 32 (100%) 110 (100%) #> M 0 0 0 0 adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl, na_level = \"Missing Values\") result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ———————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 69 73 58 200 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) 35.3 (7.1) #> Median 32.8 35.4 36.2 34.8 #> Min - Max 22.4 - 48.0 23.3 - 57.5 23.0 - 58.3 22.4 - 58.3 #> Sex #> n 69 73 58 200 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) 110 (55%) #> M 0 0 0 0 #> Missing Values 31 (44.9%) 33 (45.2%) 26 (44.8%) 90 (45%)"},{"path":"https://insightsengineering.github.io/tern/articles/missing_values.html","id":"missing-values-in-numeric-variables","dir":"Articles","previous_headings":"","what":"Missing Values in Numeric Variables","title":"Missing Values in Tern","text":"Numeric variables missing values altered. means NA value numeric variable included summary statistics, included denominator value calculating percent values. make value less 30 missing AGE variable valued greater 30 included table .","code":"adsl <- tern_ex_adsl adsl$AGE[adsl$AGE < 30] <- NA adsl <- df_explicit_na(adsl) vars <- c(\"AGE\", \"SEX\") var_labels <- c( \"Age (yr)\", \"Sex\" ) result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ——————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 46 56 44 146 #> Mean (SD) 37.8 (5.2) 38.3 (6.3) 39.1 (5.9) 38.3 (5.8) #> Median 37.2 37.3 37.5 37.5 #> Min - Max 30.3 - 48.0 30.0 - 57.5 30.5 - 58.3 30.0 - 58.3 #> Sex #> n 69 73 58 200 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) 110 (55%) #> M 31 (44.9%) 33 (45.2%) 26 (44.8%) 90 (45%)"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"tern-tabulation","dir":"Articles","previous_headings":"","what":"tern Tabulation","title":"Tabulation","text":"tern R package provides functions create common analyses clinical trials R. core functionality tabulation built general purpose rtables package. New users first begin reading “Introduction tern” “Introduction rtables” vignettes. packages used vignette : datasets used vignette :","code":"library(rtables) library(tern) library(dplyr) adsl <- ex_adsl adae <- ex_adae adrs <- ex_adrs"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"tern-analyze-functions","dir":"Articles","previous_headings":"","what":"tern Analyze Functions","title":"Tabulation","text":"Analyze functions used combination rtables layout functions, pipeline creates rtables table. apply statistical logic layout rtables table. table layout materialized rtables::build_table function data. tern analyze functions wrappers around rtables::analyze function, offer various methods useful perspective clinical trials statistical projects. Examples tern analyze functions count_occurrences, summarize_ancova analyze_vars. one prefix identify tern analyze functions recommended use tern website functions reference.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"internals-of-tern-analyze-functions","dir":"Articles","previous_headings":"tern Analyze Functions","what":"Internals of tern Analyze Functions","title":"Tabulation","text":"Please skip subsection interested internals tern analyze functions. Internally tern analyze functions like summarize_ancova mainly built 4 elements chain: descriptions function type: analysis helper functions h_*. functions useful help define analysis. statistics function s_*. Statistics functions computation numbers tabulated later. order separate computation formatting, take care rcell type formatting . formatted analysis functions a_*. arguments corresponding statistics functions, can customized calling rtables::make_afun() . used afun rtables::analyze(). analyze functions rtables::analyze(..., afun = make_afun(tern::a_*)). Analyze functions used combination rtables layout functions, pipeline creates table. last element chain. use native rtables::analyze function tern formatted analysis functions afun parameter. rtables::make_afun function helpful somebody wants attach format formatted analysis function.","code":"h_ancova() -> tern:::s_ancova() -> tern:::a_ancova() -> summarize_ancova() l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze(vars = \"AVAL\", afun = a_summary) build_table(l, df = adrs) afun <- make_afun( a_summary, .stats = NULL, .formats = c(median = \"xx.\"), .labels = c(median = \"My median\"), .indent_mods = c(median = 1L) ) l2 <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze(vars = \"AVAL\", afun = afun) build_table(l2, df = adrs)"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"tabulation-examples","dir":"Articles","previous_headings":"","what":"Tabulation Examples","title":"Tabulation","text":"going create 3 different tables using tern analyze functions rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"demographic-table","dir":"Articles","previous_headings":"Tabulation Examples","what":"Demographic Table","title":"Tabulation","text":"Demographic tables provide summary characteristics patients enrolled clinical trial. Typically table columns represent treatment arms variables summarized table demographic properties age, sex, race, etc. example function tern analyze_vars() remaining layout functions rtables. change display order categorical variables table use factor variables explicitly set order levels. case display order columns rows. Note forcats package many useful functions help types data processing steps (used ). tern package includes many functions similar analyze_vars(). functions called layout creating functions used combination rtables layout functions just like examples . Layout creating functions wrapping calls rtables analyze(), analyze_colvars() summarize_row_groups() provide options easy formatting analysis modifications. customize display demographics table, can via arguments analyze_vars(). layout creating functions tern include standard arguments .stats, .formats, .labels .indent_mods control statistics displayed numbers formatted. Refer package help help(\"analyze_vars\") ?analyze_vars see full set options. example change default summary numeric variables include number records, mean standard deviation (single statistic, .e. within single cell). categorical variables modify summary include number records counts categories. also modify display format mean standard deviation print two decimal places instead just one. One feature layout can used different datasets create different summaries. example, can easily create summary demographics Brazil China subgroups, respectively:","code":"# Select variables to include in table. vars <- c(\"AGE\", \"SEX\") var_labels <- c(\"Age (yr)\", \"Sex\") basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 134 134 132 400 #> Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) #> Median 33.0 35.0 35.0 34.0 #> Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 #> Sex #> n 134 134 132 400 #> F 79 (59%) 77 (57.5%) 66 (50%) 222 (55.5%) #> M 51 (38.1%) 55 (41%) 60 (45.5%) 166 (41.5%) #> U 3 (2.2%) 2 (1.5%) 4 (3%) 9 (2.2%) #> UNDIFFERENTIATED 1 (0.7%) 0 2 (1.5%) 3 (0.8%) # Reorder the levels in the ARM variable. adsl$ARM <- factor(adsl$ARM, levels = c(\"B: Placebo\", \"A: Drug X\", \"C: Combination\")) # Reorder the levels in the SEX variable. adsl$SEX <- factor(adsl$SEX, levels = c(\"M\", \"F\", \"U\", \"UNDIFFERENTIATED\")) basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) #> B: Placebo A: Drug X C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 134 134 132 400 #> Mean (SD) 35.4 (7.9) 33.8 (6.6) 35.4 (7.7) 34.9 (7.4) #> Median 35.0 33.0 35.0 34.0 #> Min - Max 21.0 - 62.0 21.0 - 50.0 20.0 - 69.0 20.0 - 69.0 #> Sex #> n 134 134 132 400 #> M 55 (41%) 51 (38.1%) 60 (45.5%) 166 (41.5%) #> F 77 (57.5%) 79 (59%) 66 (50%) 222 (55.5%) #> U 2 (1.5%) 3 (2.2%) 4 (3%) 9 (2.2%) #> UNDIFFERENTIATED 0 1 (0.7%) 2 (1.5%) 3 (0.8%) # Select statistics and modify default formats. basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels, .stats = c(\"n\", \"mean_sd\", \"count\"), .formats = c(mean_sd = \"xx.xx (xx.xx)\") ) %>% build_table(adsl) #> B: Placebo A: Drug X C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ———————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 134 134 132 400 #> Mean (SD) 35.43 (7.90) 33.77 (6.55) 35.43 (7.72) 34.88 (7.44) #> Sex #> n 134 134 132 400 #> M 55 51 60 166 #> F 77 79 66 222 #> U 2 3 4 9 #> UNDIFFERENTIATED 0 1 2 3 lyt <- basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels ) build_table(lyt, df = adsl %>% dplyr::filter(COUNTRY == \"BRA\")) #> B: Placebo A: Drug X C: Combination All Patients #> (N=7) (N=13) (N=10) (N=30) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 7 13 10 30 #> Mean (SD) 32.0 (6.1) 36.7 (6.4) 38.3 (10.6) 36.1 (8.1) #> Median 32.0 37.0 35.0 35.5 #> Min - Max 25.0 - 42.0 24.0 - 47.0 25.0 - 64.0 24.0 - 64.0 #> Sex #> n 7 13 10 30 #> M 4 (57.1%) 8 (61.5%) 5 (50%) 17 (56.7%) #> F 3 (42.9%) 5 (38.5%) 5 (50%) 13 (43.3%) #> U 0 0 0 0 #> UNDIFFERENTIATED 0 0 0 0 build_table(lyt, df = adsl %>% dplyr::filter(COUNTRY == \"CHN\")) #> B: Placebo A: Drug X C: Combination All Patients #> (N=81) (N=74) (N=64) (N=219) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 81 74 64 219 #> Mean (SD) 35.7 (7.3) 33.0 (6.4) 35.2 (6.4) 34.6 (6.8) #> Median 36.0 32.0 35.0 34.0 #> Min - Max 21.0 - 58.0 23.0 - 48.0 21.0 - 49.0 21.0 - 58.0 #> Sex #> n 81 74 64 219 #> M 35 (43.2%) 27 (36.5%) 30 (46.9%) 92 (42%) #> F 45 (55.6%) 44 (59.5%) 29 (45.3%) 118 (53.9%) #> U 1 (1.2%) 2 (2.7%) 3 (4.7%) 6 (2.7%) #> UNDIFFERENTIATED 0 1 (1.4%) 2 (3.1%) 3 (1.4%)"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"adverse-event-table","dir":"Articles","previous_headings":"Tabulation Examples","what":"Adverse Event Table","title":"Tabulation","text":"standard table adverse events summary system organ class preferred term. frequency counts preferred term, multiple occurrences AE individual count . create table need use combination several layout creating functions tabulation pipeline. start creating high-level summary. layout creating function tern can summarize_num_patients(): Note table, denominator used percentages shown header table (N = xx) defined based subject-level dataset adsl. done using alt_df_counts argument build_table(), provides alternative data set deriving counts header. often required work data sets include multiple records per patient df, adae .","code":"basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) #> Overall total number of events 609 622 703 1934"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"statistics-functions","dir":"Articles","previous_headings":"Tabulation Examples > Adverse Event Table","what":"Statistics Functions","title":"Tabulation","text":"building rest AE table helpful introduce tern package design conventions. layout creating function tern wrapper Statistics function. Statistics functions ones actual computation numbers table. functions always return named lists whose elements statistics available include layout via .stats argument layout creating function level. Statistics functions follow naming convention always begin s_* ease use documented page layout creating function counterpart. helpful review Statistic function understand logic used calculate numbers table see options may available modify analysis. example, Statistics function calculating numbers summarize_num_patients() s_num_patients(). results Statistics function list elements unique, nonunique unique_count: results can see unique nonunique statistics displayed “Patients” column initial AE table output . Also can see raw numbers formatted way. formatting functionality handled layout creating function level .formats argument. Now know types statistics can derived s_num_patients(), can try modifying default layout returned summarize_num_patients(). Instead reporting unique nonqunie statistics, specify analysis include unique_count statistic. result show counts unique patients. Note make update .stats .labels argument summarize_num_patients(). Let’s now continue building layout adverse event table. top-level summary, can repeat summary system organ class level. split analysis data split_rows_by() calling summarize_num_patients(). table looks almost ready. final step, need layout creating function can produce count table event frequencies. layout creating function count_occurrences(). Let’s first try using function simpler layout without row splits: Putting everything together, final AE table looks like :","code":"s_num_patients(x = adae$USUBJID, labelstr = \"\", .N_col = nrow(adae)) #> $unique #> [1] 365.000000 0.188728 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 1934 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 365 #> attr(,\"label\") #> [1] \"(n)\" basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = \"unique_count\", .labels = c(unique_count = \"Total number of patients with at least one AE\") ) %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> —————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 123 120 365 basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% split_rows_by( \"AEBODSYS\", child_labels = \"visible\", nested = FALSE, indent_mod = -1L, split_fun = drop_split_levels ) %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) #> Overall total number of events 609 622 703 1934 #> cl A.1 #> Total number of patients with at least one AE 78 (58.2%) 75 (56.0%) 89 (67.4%) 242 (60.5%) #> Overall total number of events 132 130 160 422 #> cl B.1 #> Total number of patients with at least one AE 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> Overall total number of events 56 60 62 178 #> cl B.2 #> Total number of patients with at least one AE 79 (59.0%) 74 (55.2%) 85 (64.4%) 238 (59.5%) #> Overall total number of events 129 138 143 410 #> cl C.1 #> Total number of patients with at least one AE 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> Overall total number of events 55 63 64 182 #> cl C.2 #> Total number of patients with at least one AE 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> Overall total number of events 48 53 65 166 #> cl D.1 #> Total number of patients with at least one AE 79 (59.0%) 67 (50.0%) 80 (60.6%) 226 (56.5%) #> Overall total number of events 127 106 135 368 #> cl D.2 #> Total number of patients with at least one AE 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) #> Overall total number of events 62 72 74 208 basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% count_occurrences(vars = \"AEDECOD\") %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ——————————————————————————————————————————————————————————————————————— #> dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) #> dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) #> dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) #> dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) #> dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) #> dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) #> dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% split_rows_by( \"AEBODSYS\", child_labels = \"visible\", nested = FALSE, indent_mod = -1L, split_fun = drop_split_levels ) %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% count_occurrences(vars = \"AEDECOD\") %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) #> Overall total number of events 609 622 703 1934 #> cl A.1 #> Total number of patients with at least one AE 78 (58.2%) 75 (56.0%) 89 (67.4%) 242 (60.5%) #> Overall total number of events 132 130 160 422 #> dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) #> dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) #> cl B.1 #> Total number of patients with at least one AE 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> Overall total number of events 56 60 62 178 #> dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> cl B.2 #> Total number of patients with at least one AE 79 (59.0%) 74 (55.2%) 85 (64.4%) 238 (59.5%) #> Overall total number of events 129 138 143 410 #> dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) #> dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) #> cl C.1 #> Total number of patients with at least one AE 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> Overall total number of events 55 63 64 182 #> dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> cl C.2 #> Total number of patients with at least one AE 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> Overall total number of events 48 53 65 166 #> dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> cl D.1 #> Total number of patients with at least one AE 79 (59.0%) 67 (50.0%) 80 (60.6%) 226 (56.5%) #> Overall total number of events 127 106 135 368 #> dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) #> dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) #> cl D.2 #> Total number of patients with at least one AE 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) #> Overall total number of events 62 72 74 208 #> dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%)"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"response-table","dir":"Articles","previous_headings":"Tabulation Examples","what":"Response Table","title":"Tabulation","text":"typical response table binary clinical trial endpoint may composed several different analyses: Proportion responders treatment group Difference proportion responders comparison groups vs. control group Chi-Square test difference response rates comparison groups vs. control group can build table layout like following approach used AE table: table section produced using different layout creating function tern. First start data preparation steps set analysis dataset. select endpoint analyze PARAMCD define logical variable is_rsp indicates whether patient classified responder . create summary proportion responders treatment group, use estimate_proportion() layout creating function: specify arm table used reference, use argument ref_group split_cols_by(). change reference arm “B: Placebo” arm displayed first column: customize analysis, can use method conf_level arguments modify type confidence interval calculated: next table section needed summarize difference response rates reference arm comparison arm. Use estimate_proportion_diff() layout creating function : final section needed complete table includes statistical test difference response rates. Use test_proportion_diff() layout creating function : customize output, use method argument select Chi-Squared test Schouten correction. Now can put table sections together one layout pipeline. Note one small change needed. Since primary analysis variable table sections (is_rsp), need give sub-table unique name. done adding table_names argument providing unique names :","code":"# Preprocessing to select an analysis endpoint. anl <- adrs %>% dplyr::filter(PARAMCD == \"BESRSPI\") %>% dplyr::mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) basic_table() %>% split_cols_by(var = \"ARM\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\", table_names = \"est_prop\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ————————————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 95% CI (Wald, with correction) (78.7, 91.5) (58.8, 75.5) (85.6, 96.2) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ————————————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 95% CI (Wald, with correction) (78.7, 91.5) (58.8, 75.5) (85.6, 96.2) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\", method = \"clopper-pearson\", conf_level = 0.9 ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ——————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 90% CI (Clopper-Pearson) (79.1, 89.9) (59.9, 73.9) (85.7, 94.7) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion_diff( vars = \"is_rsp\", show_labels = \"visible\", var_labels = \"Unstratified Analysis\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> —————————————————————————————————————————————————————————————————————————————— #> Unstratified Analysis #> Difference in Response rate (%) 17.9 23.7 #> 95% CI (Wald, with correction) (7.2, 28.6) (13.7, 33.8) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% test_proportion_diff(vars = \"is_rsp\") %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> —————————————————————————————————————————————————————————————————————— #> p-value (Chi-Squared Test) 0.0006 <0.0001 basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% test_proportion_diff( vars = \"is_rsp\", method = \"schouten\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> p-value (Chi-Squared Test with Schouten Correction) 0.0008 <0.0001 basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\", method = \"clopper-pearson\", conf_level = 0.9, table_names = \"est_prop\" ) %>% estimate_proportion_diff( vars = \"is_rsp\", show_labels = \"visible\", var_labels = \"Unstratified Analysis\", table_names = \"est_prop_diff\" ) %>% test_proportion_diff( vars = \"is_rsp\", method = \"schouten\", table_names = \"test_prop_diff\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ———————————————————————————————————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 90% CI (Clopper-Pearson) (79.1, 89.9) (59.9, 73.9) (85.7, 94.7) #> Unstratified Analysis #> Difference in Response rate (%) 17.9 23.7 #> 95% CI (Wald, with correction) (7.2, 28.6) (13.7, 33.8) #> p-value (Chi-Squared Test with Schouten Correction) 0.0008 <0.0001"},{"path":"https://insightsengineering.github.io/tern/articles/tables.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Tabulation","text":"Tabulation tern builds top layout tabulation framework rtables. Complex tables built step step pipeline combining layout creating functions perform specific type analysis. tern analyze functions introduced vignette : analyze_vars() summarize_num_patients() count_occurrences() estimate_proportion() estimate_proportion_diff() test_proportion_diff() Layout creating functions build formatted layout controlling features labels, numerical display formats indentation. functions wrappers Statistics functions calculate raw summaries analysis. can easily spot Statistics functions documentation always begin prefix s_. can helpful inspect run Statistics functions understand ways analysis can customized.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern.html","id":"common-clinical-trials-analyses","dir":"Articles","previous_headings":"","what":"Common Clinical Trials Analyses","title":"Introduction to tern","text":"package provides large range functionality create tables graphs used clinical trial statistical analysis. rtables tabulation extended clinical trials specific functions: demographics unique patients exposure across patients change baseline parameters statistical model fits: MMRM, logistic regression, Cox regression, … … rtables tabulation helper functions: pre-processing conversions transformations … data visualizations connected clinical trials: Kaplan-Meier plots forest plots line plots … data visualizations helper functions: arrange/stack multiple graphs embellishing graphs/tables metadata details, adding titles, footnotes, page number, etc. … reference tern functions available tern website functions reference.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern.html","id":"analytical-functions-for-rtables","dir":"Articles","previous_headings":"","what":"Analytical Functions for rtables","title":"Introduction to tern","text":"Analytical functions used combination rtables layout functions, pipeline creates rtables table. apply statistical logic layout rtables table. table layout materialized rtables::build_table function data. tern analytical functions wrappers around rtables::analyze function; offer various methods useful perspective clinical trials statistical projects. Examples tern analytical functions count_occurrences, summarize_ancova analyze_vars. one prefix identify tern analytical functions recommended use reference subsection tern website. rtables code first describe two tables assign descriptions variables lyt lyt2. built tables using actual data rtables::build_table. description table called table layout. analyze instruction adds layout ARM variable analyzed mean analysis function result rounded 1 decimal place. Hence, layout “pre-data”; , ’s description build table get data. Defining table layout pure rtables code: , tern function used analyze_vars replaces rtables::analyze function used . see tern offers advanced analysis extending rtables function calls one additional function call. examples tabulation analyze functions presented Tabulation vignette.","code":"library(tern) library(dplyr) # Create table layout pure rtables lyt <- rtables::basic_table() %>% rtables::split_cols_by(var = \"ARM\") %>% rtables::split_rows_by(var = \"AVISIT\") %>% rtables::analyze(vars = \"AVAL\", mean, format = \"xx.x\") # Create table layout with tern analyze_vars analyze function lyt2 <- rtables::basic_table() %>% rtables::split_cols_by(var = \"ARM\") %>% rtables::split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\", .formats = c(\"mean_sd\" = \"(xx.xx, xx.xx)\")) # Apply table layout to data and produce `rtables` object adrs <- formatters::ex_adrs rtables::build_table(lyt, df = adrs) #> A: Drug X B: Placebo C: Combination #> —————————————————————————————————————————————————————————— #> SCREENING #> mean 3.0 3.0 3.0 #> BASELINE #> mean 2.5 2.8 2.5 #> END OF INDUCTION #> mean 1.7 2.1 1.6 #> FOLLOW UP #> mean 2.2 2.9 2.0 rtables::build_table(lyt2, df = adrs) #> A: Drug X B: Placebo C: Combination #> ——————————————————————————————————————————————————————————————— #> SCREENING #> n 154 178 144 #> Mean (SD) (3.00, 0.00) (3.00, 0.00) (3.00, 0.00) #> Median 3.0 3.0 3.0 #> Min - Max 3.0 - 3.0 3.0 - 3.0 3.0 - 3.0 #> BASELINE #> n 136 146 124 #> Mean (SD) (2.46, 0.88) (2.77, 1.00) (2.46, 1.08) #> Median 3.0 3.0 3.0 #> Min - Max 1.0 - 4.0 1.0 - 5.0 1.0 - 5.0 #> END OF INDUCTION #> n 218 205 217 #> Mean (SD) (1.75, 0.90) (2.14, 1.28) (1.65, 1.06) #> Median 2.0 2.0 1.0 #> Min - Max 1.0 - 4.0 1.0 - 5.0 1.0 - 5.0 #> FOLLOW UP #> n 164 153 167 #> Mean (SD) (2.23, 1.26) (2.89, 1.29) (1.97, 1.01) #> Median 2.0 4.0 2.0 #> Min - Max 1.0 - 4.0 1.0 - 4.0 1.0 - 4.0"},{"path":"https://insightsengineering.github.io/tern/articles/tern.html","id":"clinical-trial-visualizations","dir":"Articles","previous_headings":"","what":"Clinical Trial Visualizations","title":"Introduction to tern","text":"Clinical trial related plots complement rich palette tern tabulation analysis functions. Thus tern package delivers full-featured tool clinical trial reporting. tern plot functions return graphs ggplot2 objects. nestcolor package can loaded apply standardized NEST color palette tern plots. Line plot without table generated g_lineplot function. Line plot table generated g_lineplot function. tern functions used plot generation g_ prefixed listed tern website functions reference.","code":"adsl <- formatters::ex_adsl adlb <- formatters::ex_adlb adlb <- dplyr::filter(adlb, PARAMCD == \"ALT\", AVISIT != \"SCREENING\") library(nestcolor) # Mean with CI g_lineplot(adlb, adsl, subtitle = \"Laboratory Test:\") # Mean with CI, table, and customized confidence level g_lineplot( adlb, adsl, table = c(\"n\", \"mean\", \"mean_ci\"), title = \"Plot of Mean and 80% Confidence Limits by Visit\" )"},{"path":"https://insightsengineering.github.io/tern/articles/tern.html","id":"interactive-apps","dir":"Articles","previous_headings":"","what":"Interactive Apps","title":"Introduction to tern","text":"tern outputs can easily converted shiny apps. recommend building apps using teal package, shiny-based interactive exploration framework analyzing data. variety pre-made teal shiny apps tern outputs available teal.modules.clinical package.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Introduction to tern","text":"summary, tern contains many additional functions creating tables, listings, graphs used clinical trials statistical analyses. design package gives users flexibility meet analysis needs regulatory exploratory reporting contexts. information please explore tern website.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"tern-formatting-functions-overview","dir":"Articles","previous_headings":"","what":"tern Formatting Functions Overview","title":"Formatting Functions","text":"tern R package provides functions create common analyses clinical trials R functions default formatting arguments displaying values output specific way. tern formatting differs compared formatting available formatters package tern formats capable handling logical statements, allowing fine-tuning output displayed. Depending type value displayed, value , format output change. Whereas using formatters package, specified format applied regardless value. see available formatting functions available tern see ?formatting_functions. see available format strings available formatters see formatters::list_valid_format_labels().","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"comparing-tern-formatters-formats","dir":"Articles","previous_headings":"","what":"Comparing tern & formatters Formats","title":"Formatting Functions","text":"packages used vignette : example demonstrates use tern formatting count_abnormal() function. example “low” category non-zero numerator value fraction percentage value displayed, “high” value numerator value zero fraction value displayed without also displaying redundant zero percentage value. following example count_abnormal() function utilized . time “low” values “high” values non-zero numerator show percentage. following example demonstrates difference formatters used instead format output. choose use \"xx / xx\" value format. “high” value zero numerator value “low” value non-zero numerator, yet displayed format. concept occurs using available formats formatters package. following example displays result using \"xx.x / xx.x\" format instead. Use formatters::list_valid_format_labels() see full list available formats formatters.","code":"library(rtables) library(formatters) library(tern) library(dplyr) df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = format_fraction) ) %>% build_table(df2) #> all obs #> ————————————————— #> low 2/2 (100%) #> high 0/2 df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = format_fraction) ) %>% build_table(df2) #> all obs #> ———————————————— #> low 1/2 (50%) #> high 1/2 (50%) df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = \"xx / xx\") ) %>% build_table(df2) #> all obs #> —————————————— #> low 2 / 2 #> high 0 / 2 df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = \"xx.x / xx.x\") ) %>% build_table(df2) #> all obs #> ———————————————— #> low 2.0 / 2.0 #> high 0.0 / 2.0"},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"formatting-function-basics","dir":"Articles","previous_headings":"","what":"Formatting Function Basics","title":"Formatting Functions","text":"Current tern formatting functions consider following aspects setting custom behaviors: Missing values - custom value string can set display missing values instead NA. 0’s - cell value zero, tern fraction formatting functions exclude accompanying percentage value. Number decimal places display - number decimal places can fixed needed. Value thresholds - different format value can displayed depending whether value within certain threshold.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"number-of-decimal-places-to-display","dir":"Articles","previous_headings":"Formatting Function Basics","what":"Number of Decimal Places to Display","title":"Formatting Functions","text":"Two functions set fixed number decimal places (specifically 1) format_fraction_fixed_dp() format_count_fraction_fixed_dp(). default, formatting functions remove trailing zeros, two functions always one decimal place percentage, even digit zero. See following example:","code":"format_fraction_fixed_dp(x = c(num = 1L, denom = 3L)) #> [1] \"1/3 (33.3%)\" format_fraction_fixed_dp(x = c(num = 1L, denom = 2L)) #> [1] \"1/2 (50.0%)\" format_count_fraction_fixed_dp(x = c(2, 0.6667)) #> [1] \"2 (66.7%)\" format_count_fraction_fixed_dp(x = c(2, 0.25)) #> [1] \"2 (25.0%)\""},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"value-thresholds","dir":"Articles","previous_headings":"Formatting Function Basics","what":"Value Thresholds","title":"Formatting Functions","text":"Functions set custom values according certain threshold include format_extreme_values(), format_extreme_values_ci(), format_fraction_threshold(). extreme value formats work similarly allow user specify maximum number digits include, large small values given special string value. example: format_fraction_threshold() function allows user specify lower percentage threshold, values instead assigned special string value. example: See documentation function specific details behavior customize .","code":"extreme_format <- format_extreme_values(digits = 2) extreme_format(0.235) #> [1] \"0.23\" extreme_format(0.001) #> [1] \"<0.01\" extreme_format(Inf) #> [1] \">999.99\" fraction_format <- format_fraction_threshold(0.05) fraction_format(x = c(20, 0.1)) #> [1] 10 fraction_format(x = c(2, 0.01)) #> [1] \"<5\""},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"creating-custom-formatting-functions","dir":"Articles","previous_headings":"","what":"Creating Custom Formatting Functions","title":"Formatting Functions","text":"table requires customized output displayed using one pre-existing tern formatting functions, may want consider creating new formatting function. creating formatting function important consider aspects listed Formatting Function Customization section . section create custom formatting function derived format_fraction_fixed_dp() function. First take look function detail customize . see numerator value greater 0, fraction percentage displayed. numerator 0, fraction shown. Percent values always display 1 decimal place. create dummy dataset observe output value behavior formatting function applied. Now modify function make custom formatting function, custom_format. want display 3 decimal places percent value, numerator value 0 want display 0 value (without denominator).","code":"# First we will see how the format_fraction_fixed_dp code works and displays the outputs format_fraction_fixed_dp <- function(x, ...) { attr(x, \"label\") <- NULL checkmate::assert_vector(x) checkmate::assert_count(x[\"num\"]) checkmate::assert_count(x[\"denom\"]) result <- if (x[\"num\"] == 0) { paste0(x[\"num\"], \"/\", x[\"denom\"]) } else { paste0( x[\"num\"], \"/\", x[\"denom\"], \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" ) } return(result) } df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = format_fraction_fixed_dp) ) %>% build_table(df2) #> all obs #> ——————————————————— #> low 2/2 (100.0%) #> high 0/2 custom_format <- function(x, ...) { attr(x, \"label\") <- NULL checkmate::assert_vector(x) checkmate::assert_count(x[\"num\"]) checkmate::assert_count(x[\"denom\"]) result <- if (x[\"num\"] == 0) { paste0(x[\"num\"]) # We remove the denominator on this line so that only a 0 is displayed } else { paste0( x[\"num\"], \"/\", x[\"denom\"], \" (\", sprintf(\"%.3f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" # We include 3 decimal places with %.3f ) } return(result) } basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = custom_format) # Here we implement our new custom_format function ) %>% build_table(df2) #> all obs #> ————————————————————— #> low 2/2 (100.000%) #> high 0"},{"path":"https://insightsengineering.github.io/tern/articles/tern_formats.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Formatting Functions","text":"tern analysis function pre-specified default format functions implement generating output, taken formatters package custom formatting functions stored tern. tern functions differ compared formatters logical statements can used set value-dependent customized formats. like create custom formatting function use tern, sure carefully consider rules want implement handle different input values.","code":""},{"path":"https://insightsengineering.github.io/tern/articles/tern_functions_guide.html","id":"understanding-tern-functions","dir":"Articles","previous_headings":"","what":"Understanding tern functions","title":"Understanding `tern` functions","text":"Every function tern package designed certain structure can cooperate well every user’s need, maintaining consistent predictable behavior. document guide example function package, explaining purpose many building blocks can used. recently worked consider summarize_change() example. function used calculate change baseline value given variable. realistic example can found LBT03 TLG-catalog. summarize_change() main function available user. can find lists functions ?tern::analyze_functions. build around rtables::analyze() function, core analysis function rtables. wrapper functions call specific analysis functions (always written a_*) meant handle statistic functions (always written s_*) format results rtables::in_row() function. can summarize structure follows: summarize_change() (1)-> a_change_from_baseline() (2)-> [s_change_from_baseline() + rtables::in_row()] main questions may arise : Handling NA. Handling formats. Additional statistics. Data set library loading. Classic use summarize_change(). .formats, .labels, .indent_mods depend names .stats. can change default formatting. want something special format? Adding custom statistic (custom format):","code":"library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(tern) #> Loading required package: rtables #> Loading required package: formatters #> #> Attaching package: 'formatters' #> The following object is masked from 'package:base': #> #> %||% #> Loading required package: magrittr #> #> Attaching package: 'rtables' #> The following object is masked from 'package:utils': #> #> str #> Registered S3 method overwritten by 'tern': #> method from #> tidy.glm broom ## Fabricate dataset dta_test <- data.frame( USUBJID = rep(1:6, each = 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)) ) %>% mutate(ABLFLL = AVISIT == \"V1\") %>% group_by(USUBJID) %>% mutate( BLVAL = AVAL[ABLFLL], CHG = AVAL - BLVAL ) %>% ungroup() fix_layout <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") # Dealing with NAs: na_rm = TRUE fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\")) %>% build_table(dta_test) %>% print() #> A B C #> ———————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 (NA) NA #> Median 7.50 3.00 NA #> Min - Max 6.00 - 9.00 3.00 - 3.00 NA #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 (NA) NA #> Median -1.00 -1.00 NA #> Min - Max -1.00 - -1.00 -1.00 - -1.00 NA #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 (NA) NA #> Median -2.00 -2.00 NA #> Min - Max -2.00 - -2.00 -2.00 - -2.00 NA # Dealing with NAs: na_rm = FALSE fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), na_rm = FALSE) %>% build_table(dta_test) %>% print() #> A B C #> ———————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 (NA) NA #> Median 7.50 3.00 NA #> Min - Max 6.00 - 9.00 3.00 - 3.00 NA #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 (NA) NA #> Median -1.00 -1.00 NA #> Min - Max -1.00 - -1.00 -1.00 - -1.00 NA #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 (NA) NA #> Median -2.00 -2.00 NA #> Min - Max -2.00 - -2.00 -2.00 - -2.00 NA # changing the NA string (it is done on all levels) fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), na_str = \"my_na\") %>% build_table(dta_test) %>% print() #> A B C #> ——————————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 (my_na) my_na #> Median 7.50 3.00 my_na #> Min - Max 6.00 - 9.00 3.00 - 3.00 my_na #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 (my_na) my_na #> Median -1.00 -1.00 my_na #> Min - Max -1.00 - -1.00 -1.00 - -1.00 my_na #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 (my_na) my_na #> Median -2.00 -2.00 my_na #> Min - Max -2.00 - -2.00 -2.00 - -2.00 my_na # changing n count format and label and indentation fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), .stats = c(\"n\", \"mean\"), # reducing the number of stats for visual appreciation .formats = c(n = \"xx.xx\"), .labels = c(n = \"NnNn\"), .indent_mods = c(n = 5), na_str = \"nA\" ) %>% build_table(dta_test) %>% print() #> A B C #> ————————————————————————————————————— #> V1 #> NnNn 2.00 1.00 0.00 #> Mean 7.5 3.0 nA #> V2 #> NnNn 2.00 1.00 0.00 #> Mean -1.0 -1.0 nA #> V3 #> NnNn 2.00 1.00 0.00 #> Mean -2.0 -2.0 nA # changing n count format and label and indentation fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), .stats = c(\"n\", \"mean\"), # reducing the number of stats for visual appreciation .formats = c(n = function(x, ...) as.character(x * 100)) ) %>% # Note you need ...!!! build_table(dta_test) %>% print() #> A B C #> ————————————————————————— #> V1 #> n 200 100 0 #> Mean 7.5 3.0 NA #> V2 #> n 200 100 0 #> Mean -1.0 -1.0 NA #> V3 #> n 200 100 0 #> Mean -2.0 -2.0 NA # changing n count format and label and indentation fix_layout %>% summarize_change( \"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), .stats = c(\"n\", \"my_stat\" = function(df, ...) { a <- mean(df$AVAL, na.rm = TRUE) b <- list(...)$.N_row # It has access at all `?rtables::additional_fun_params` a / b }), .formats = c(\"my_stat\" = function(x, ...) sprintf(\"%.2f\", x)) ) %>% build_table(dta_test) #> A B C #> ———————————————————————————— #> V1 #> n 2 1 0 #> my_stat 1.25 0.50 NA #> V2 #> n 2 1 0 #> my_stat 1.08 0.33 NA #> V3 #> n 2 1 0 #> my_stat 0.92 0.17 NA"},{"path":"https://insightsengineering.github.io/tern/articles/tern_functions_guide.html","id":"for-developers","dir":"Articles","previous_headings":"","what":"For Developers","title":"Understanding `tern` functions","text":"layers specific parameters need available, , rtables multiple way handle formatting NA values, decide correctly handle additional extra arguments. follow following scheme: Level 1: summarize_change(): parameters without starting dot .* used added extra_args. Specifically, solve NA values using inclNAs option rtables::analyze(). add ... na.rm = inclNAs. Also na_str set. may want statistic dependent future, still need think accomplish . add rtables::additional_fun_params analysis function make available ... next level. Level 2: a_change_from_baseline(): parameters starting dot . used. Mainly .stats, .formats, .labels, .indent_mods used. also add extra_afun_params ... list statistical function. Notice handling additional parameters .call() function.","code":""},{"path":"https://insightsengineering.github.io/tern/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Joe Zhu. Author, maintainer. Daniel Sabanés Bové. Author. Jana Stoilova. Author. Davide Garolini. Author. Emily de la Rua. Author. Abinaya Yogasekaram. Author. Heng Wang. Author. Francois Collin. Author. Adrian Waddell. Author. Pawel Rucki. Author. Chendi Liao. Author. Jennifer Li. Author. F. Hoffmann-La Roche AG. Copyright holder, funder.","code":""},{"path":"https://insightsengineering.github.io/tern/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Zhu J, Sabanés Bové D, Stoilova J, Garolini D, de la Rua E, Yogasekaram , Wang H, Collin F, Waddell , Rucki P, Liao C, Li J (2024). tern: Create Common TLGs Used Clinical Trials. R package version 0.9.6.9015, https://github.com/insightsengineering/tern/, https://insightsengineering.github.io/tern/.","code":"@Manual{, title = {tern: Create Common TLGs Used in Clinical Trials}, author = {Joe Zhu and Daniel {Sabanés Bové} and Jana Stoilova and Davide Garolini and Emily {de la Rua} and Abinaya Yogasekaram and Heng Wang and Francois Collin and Adrian Waddell and Pawel Rucki and Chendi Liao and Jennifer Li}, year = {2024}, note = {R package version 0.9.6.9015, https://github.com/insightsengineering/tern/}, url = {https://insightsengineering.github.io/tern/}, }"},{"path":"https://insightsengineering.github.io/tern/index.html","id":"tern-","dir":"","previous_headings":"","what":"Create Common TLGs Used in Clinical Trials","title":"Create Common TLGs Used in Clinical Trials","text":"tern R package contains analysis functions create tables graphs used clinical trial reporting. package provides large range functionality, : Data visualizations: Line plots (g_lineplot) Kaplan-Meier plots (g_km) Forest plots (g_forest) STEP graphs (g_step) Individual patient plots (g_ipp) Waterfall plots (g_waterfall) Bland-Altman plots (g_bland_altman) Statistical model fit summaries: Logistic regression (summarize_logistic) Cox regression (summarize_coxreg) Analysis tables: See list available analyze functions See list available summarize functions See list available column-wise analysis functions Many outputs available added teal shiny applications interactive exploration data. teal modules available teal.modules.clinical package. See TLG Catalog extensive catalog example clinical trial tables, listings, graphs created using tern functionality.","code":""},{"path":"https://insightsengineering.github.io/tern/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Create Common TLGs Used in Clinical Trials","text":"tern available CRAN can install latest released version : can install latest development version directly GitHub running following:","code":"install.packages(\"tern\") # install.packages(\"pak\") pak::pak(\"insightsengineering/tern\")"},{"path":"https://insightsengineering.github.io/tern/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Create Common TLGs Used in Clinical Trials","text":"understand use package, please refer Introduction tern article, provides multiple examples code implementation. See package vignettes browseVignettes(package = \"tern\") usage package.","code":""},{"path":"https://insightsengineering.github.io/tern/index.html","id":"related","dir":"","previous_headings":"","what":"Related","title":"Create Common TLGs Used in Clinical Trials","text":"rtables - table engine used tlg-catalog - website showcasing many examples clinical trial tables, listings, graphs teal.modules.clinical - teal modules interactive data analysis","code":""},{"path":"https://insightsengineering.github.io/tern/index.html","id":"acknowledgment","dir":"","previous_headings":"","what":"Acknowledgment","title":"Create Common TLGs Used in Clinical Trials","text":"package result joint efforts many developers stakeholders. like thank everyone contributed far!","code":""},{"path":[]},{"path":[]},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with abnormal range values — abnormal","title":"Count patients with abnormal range values — abnormal","text":"analyze function count_abnormal() creates layout element count patients abnormal analysis range values direction. function analyzes primary analysis variable var indicates abnormal range results. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, baseline (defaults BNRIND), variable indicate baseline reference ranges. direction specified via abnormal parameter (e.g. High Low), fraction patient counts returned, numerator denominator calculated follows: num: number patients abnormality recorded treatment. denom: total number patients least one post-baseline assessment. function assumes df filtered include post-baseline records.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with abnormal range values — abnormal","text":"","code":"count_abnormal( lyt, var, abnormal = list(Low = \"LOW\", High = \"HIGH\"), variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), exclude_base_abn = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = var, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal( df, .var, abnormal = list(Low = \"LOW\", High = \"HIGH\"), variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), exclude_base_abn = FALSE ) a_count_abnormal( df, .var, abnormal = list(Low = \"LOW\", High = \"HIGH\"), variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), exclude_base_abn = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with abnormal range values — abnormal","text":"lyt (PreDataTableLayouts) layout analyses added . abnormal (named list) list identifying abnormal range level(s) var. Defaults list(Low = \"LOW\", High = \"HIGH\") can also group different levels named list, example, abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")). variables (named list string) list additional analysis variables. exclude_base_abn (flag) whether exclude subjects baseline abnormality numerator denominator. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with abnormal range values — abnormal","text":"count_abnormal() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal() table layout. s_count_abnormal() returns statistic fraction vector num denom counts patients. a_count_abnormal() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with abnormal range values — abnormal","text":"count_abnormal(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal(): Statistics function counts patients abnormal range values single abnormal level. a_count_abnormal(): Formatted analysis function used afun count_abnormal().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count patients with abnormal range values — abnormal","text":"count_abnormal() considers single variable contains multiple abnormal levels. df filtered include post-baseline records. denominator includes patients may abnormal levels baseline, patients missing baseline records. Patients abnormalities baseline can optionally excluded numerator denominator via exclude_base_abn parameter.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with abnormal range values — abnormal","text":"","code":"library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following object is masked from ‘package:testthat’: #> #> matches #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union df <- data.frame( USUBJID = as.character(c(1, 1, 2, 2)), ANRIND = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BNRIND = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) # Select only post-baseline records. df <- df %>% filter(ONTRTFL == \"Y\") # Layout creating function. basic_table() %>% count_abnormal(var = \"ANRIND\", abnormal = list(high = \"HIGH\", low = \"LOW\")) %>% build_table(df) #> all obs #> ———————————————— #> high 1/2 (50%) #> low 1/2 (50%) # Passing of statistics function and formatting arguments. df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) # Select only post-baseline records. df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\") ) %>% build_table(df2) #> all obs #> ———————————————— #> low 1/2 (50%) #> high 1/2 (50%)"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"analyze function count_abnormal_by_baseline() creates layout element count patients abnormal analysis range values, categorized baseline status. function analyzes primary analysis variable var indicates abnormal range results. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, baseline (defaults BNRIND), variable indicate baseline reference ranges. direction specified via abnormal parameter (e.g. High Low), condition baseline range result count patients numerator denominator follows following categories: num: number patients without abnormality baseline (excluding missing baseline) least one abnormality post-baseline. denom: number patients without abnormality baseline (excluding missing baseline). num: number patients abnormality baseline least one abnormality post-baseline. denom: number patients abnormality baseline. Total num: number patients least one post-baseline record least one abnormality post-baseline. denom: number patients least one post-baseline record. function assumes df filtered include post-baseline records.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"","code":"count_abnormal_by_baseline( lyt, var, abnormal, variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), na_str = \"\", nested = TRUE, ..., table_names = abnormal, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_by_baseline( df, .var, abnormal, na_str = \"\", variables = list(id = \"USUBJID\", baseline = \"BNRIND\") ) a_count_abnormal_by_baseline( df, .var, abnormal, na_str = \"\", variables = list(id = \"USUBJID\", baseline = \"BNRIND\") )"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"lyt (PreDataTableLayouts) layout analyses added . abnormal (character) values identifying abnormal range level(s) .var. variables (named list string) list additional analysis variables. na_str (string) explicit na_level argument used pre-processing steps (maybe df_explicit_na()). default \"\". nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"count_abnormal_by_baseline() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_by_baseline() table layout. s_count_abnormal_by_baseline() returns statistic fraction named list 3 labeled elements: not_abnormal, abnormal, total. element contains vector num denom patient counts. a_count_abnormal_by_baseline() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"count_abnormal_by_baseline(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_by_baseline(): Statistics function single abnormal level. a_count_abnormal_by_baseline(): Formatted analysis function used afun count_abnormal_by_baseline().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"df filtered include post-baseline records. baseline variable analysis variable contains NA records, expected df pre-processed using df_explicit_na() explicit_na().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_baseline.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"","code":"df <- data.frame( USUBJID = as.character(c(1:6)), ANRIND = factor(c(rep(\"LOW\", 4), \"NORMAL\", \"HIGH\")), BNRIND = factor(c(\"LOW\", \"NORMAL\", \"HIGH\", NA, \"LOW\", \"NORMAL\")) ) df <- df_explicit_na(df) # Layout creating function. basic_table() %>% count_abnormal_by_baseline(var = \"ANRIND\", abnormal = c(High = \"HIGH\")) %>% build_table(df) #> all obs #> ———————————————————————— #> High #> Not high 1/4 (25%) #> High 0/1 #> Total 1/6 (16.7%) # Passing of statistics function and formatting arguments. df2 <- data.frame( ID = as.character(c(1, 2, 3, 4)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BLRANGE = factor(c(\"LOW\", \"HIGH\", \"HIGH\", \"NORMAL\")) ) basic_table() %>% count_abnormal_by_baseline( var = \"RANGE\", abnormal = c(Low = \"LOW\"), variables = list(id = \"ID\", baseline = \"BLRANGE\"), .formats = c(fraction = \"xx / xx\"), .indent_mods = c(fraction = 2L) ) %>% build_table(df2) #> all obs #> ——————————————————————— #> Low #> Not low 1 / 3 #> Low 0 / 1 #> Total 1 / 4"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with marked laboratory abnormalities — abnormal_by_marked","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"analyze function count_abnormal_by_marked() creates layout element count patients marked laboratory abnormalities direction abnormality, categorized parameter value. function analyzes primary analysis variable var indicates whether single, replicated, last marked laboratory abnormality observed. Levels var include marked lab abnormality (single last_replicated) can supplied via category parameter. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, param (defaults PARAM), variable indicate parameter values, direction (defaults abn_dir), variable indicate abnormality directions. combination param direction levels, marked lab abnormality counts calculated follows: Single, last & Last replicated: number patients Single, last Last replicated values, respectively. : number patients either single replicated marked abnormalities. Fractions calculated dividing counts number patients least one valid measurement recorded analysis. Prior using function table layout must use rtables::split_rows_by() create two row splits, one variable param one variable direction.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"","code":"count_abnormal_by_marked( lyt, var, category = list(single = \"SINGLE\", last_replicated = c(\"LAST\", \"REPLICATED\")), variables = list(id = \"USUBJID\", param = \"PARAM\", direction = \"abn_dir\"), na_str = default_na_str(), nested = TRUE, ..., .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_by_marked( df, .var = \"AVALCAT1\", .spl_context, category = list(single = \"SINGLE\", last_replicated = c(\"LAST\", \"REPLICATED\")), variables = list(id = \"USUBJID\", param = \"PARAM\", direction = \"abn_dir\") ) a_count_abnormal_by_marked( df, .var = \"AVALCAT1\", .spl_context, category = list(single = \"SINGLE\", last_replicated = c(\"LAST\", \"REPLICATED\")), variables = list(id = \"USUBJID\", param = \"PARAM\", direction = \"abn_dir\") )"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"lyt (PreDataTableLayouts) layout analyses added . category (list) list different marked category names single last replicated. variables (named list string) list additional analysis variables. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function. .spl_context (data.frame) gives information ancestor split states passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"count_abnormal_by_marked() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_by_marked() table layout. s_count_abnormal_by_marked() returns statistic count_fraction Single, last, Last replicated, results. a_count_abnormal_by_marked() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"count_abnormal_by_marked(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_by_marked(): Statistics function patients marked lab abnormalities. a_count_abnormal_by_marked(): Formatted analysis function used afun count_abnormal_by_marked().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"Single, last Last replicated levels mutually exclusive. patient abnormalities meet Single, last Last replicated criteria, patient counted Last replicated category.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_marked.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"","code":"library(dplyr) df <- data.frame( USUBJID = as.character(c(rep(1, 5), rep(2, 5), rep(1, 5), rep(2, 5))), ARMCD = factor(c(rep(\"ARM A\", 5), rep(\"ARM B\", 5), rep(\"ARM A\", 5), rep(\"ARM B\", 5))), ANRIND = factor(c( \"NORMAL\", \"HIGH\", \"HIGH\", \"HIGH HIGH\", \"HIGH\", \"HIGH\", \"HIGH\", \"HIGH HIGH\", \"NORMAL\", \"HIGH HIGH\", \"NORMAL\", \"LOW\", \"LOW\", \"LOW LOW\", \"LOW\", \"LOW\", \"LOW\", \"LOW LOW\", \"NORMAL\", \"LOW LOW\" )), ONTRTFL = rep(c(\"\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\"), 2), PARAMCD = factor(c(rep(\"CRP\", 10), rep(\"ALT\", 10))), AVALCAT1 = factor(rep(c(\"\", \"\", \"\", \"SINGLE\", \"REPLICATED\", \"\", \"\", \"LAST\", \"\", \"SINGLE\"), 2)), stringsAsFactors = FALSE ) df <- df %>% mutate(abn_dir = factor( case_when( ANRIND == \"LOW LOW\" ~ \"Low\", ANRIND == \"HIGH HIGH\" ~ \"High\", TRUE ~ \"\" ), levels = c(\"Low\", \"High\") )) # Select only post-baseline records. df <- df %>% filter(ONTRTFL == \"Y\") df_crp <- df %>% filter(PARAMCD == \"CRP\") %>% droplevels() full_parent_df <- list(df_crp, \"not_needed\") cur_col_subset <- list(rep(TRUE, nrow(df_crp)), \"not_needed\") spl_context <- data.frame( split = c(\"PARAMCD\", \"GRADE_DIR\"), full_parent_df = I(full_parent_df), cur_col_subset = I(cur_col_subset) ) map <- unique( df[df$abn_dir %in% c(\"Low\", \"High\") & df$AVALCAT1 != \"\", c(\"PARAMCD\", \"abn_dir\")] ) %>% lapply(as.character) %>% as.data.frame() %>% arrange(PARAMCD, abn_dir) basic_table() %>% split_cols_by(\"ARMCD\") %>% split_rows_by(\"PARAMCD\") %>% summarize_num_patients( var = \"USUBJID\", .stats = \"unique_count\" ) %>% split_rows_by( \"abn_dir\", split_fun = trim_levels_to_map(map) ) %>% count_abnormal_by_marked( var = \"AVALCAT1\", variables = list( id = \"USUBJID\", param = \"PARAMCD\", direction = \"abn_dir\" ) ) %>% build_table(df = df) #> ARM A ARM B #> ———————————————————————————————————————————— #> ALT (n) 1 1 #> Low #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%) #> CRP (n) 1 1 #> High #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%) basic_table() %>% split_cols_by(\"ARMCD\") %>% split_rows_by(\"PARAMCD\") %>% summarize_num_patients( var = \"USUBJID\", .stats = \"unique_count\" ) %>% split_rows_by( \"abn_dir\", split_fun = trim_levels_in_group(\"abn_dir\") ) %>% count_abnormal_by_marked( var = \"AVALCAT1\", variables = list( id = \"USUBJID\", param = \"PARAMCD\", direction = \"abn_dir\" ) ) %>% build_table(df = df) #> ARM A ARM B #> ———————————————————————————————————————————— #> ALT (n) 1 1 #> Low #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%) #> CRP (n) 1 1 #> High #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%)"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"analyze function count_abnormal_by_worst_grade() creates layout element count patients highest (worst) analysis toxicity grade post-baseline direction, categorized parameter value. function analyzes primary analysis variable var indicates toxicity grades. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, param (defaults PARAM), variable indicate parameter values, grade_dir (defaults GRADE_DIR), variable indicate directions (e.g. High Low) toxicity grade supplied var. combination param grade_dir levels, patient counts worst grade calculated follows: 1 4: number patients worst grades 1-4, respectively. : number patients least one abnormality (.e. grade 0). Fractions calculated dividing counts number patients least one valid measurement recorded treatment. Pre-processing crucial using function can done automatically using h_adlb_abnormal_by_worst_grade() helper function. See description function details necessary pre-processing steps. Prior using function table layout must use rtables::split_rows_by() create two row splits, one variable param one variable grade_dir.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"","code":"count_abnormal_by_worst_grade( lyt, var, variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\"), na_str = default_na_str(), nested = TRUE, ..., .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_by_worst_grade( df, .var = \"GRADE_ANL\", .spl_context, variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\") ) a_count_abnormal_by_worst_grade( df, .var = \"GRADE_ANL\", .spl_context, variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\") )"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"lyt (PreDataTableLayouts) layout analyses added . variables (named list string) list additional analysis variables. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function. .spl_context (data.frame) gives information ancestor split states passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"count_abnormal_by_worst_grade() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_by_worst_grade() table layout. s_count_abnormal_by_worst_grade() returns single statistic count_fraction grades 1 4 \"\" results. a_count_abnormal_by_worst_grade() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"count_abnormal_by_worst_grade(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_by_worst_grade(): Statistics function counts patients worst grade. a_count_abnormal_by_worst_grade(): Formatted analysis function used afun count_abnormal_by_worst_grade().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"","code":"library(dplyr) library(forcats) adlb <- tern_ex_adlb # Data is modified in order to have some parameters with grades only in one direction # and simulate the real data. adlb$ATOXGR[adlb$PARAMCD == \"ALT\" & adlb$ATOXGR %in% c(\"1\", \"2\", \"3\", \"4\")] <- \"-1\" adlb$ANRIND[adlb$PARAMCD == \"ALT\" & adlb$ANRIND == \"HIGH\"] <- \"LOW\" adlb$WGRHIFL[adlb$PARAMCD == \"ALT\"] <- \"\" adlb$ATOXGR[adlb$PARAMCD == \"IGA\" & adlb$ATOXGR %in% c(\"-1\", \"-2\", \"-3\", \"-4\")] <- \"1\" adlb$ANRIND[adlb$PARAMCD == \"IGA\" & adlb$ANRIND == \"LOW\"] <- \"HIGH\" adlb$WGRLOFL[adlb$PARAMCD == \"IGA\"] <- \"\" # Pre-processing adlb_f <- adlb %>% h_adlb_abnormal_by_worst_grade() # Map excludes records without abnormal grade since they should not be displayed # in the table. map <- unique(adlb_f[adlb_f$GRADE_DIR != \"ZERO\", c(\"PARAM\", \"GRADE_DIR\", \"GRADE_ANL\")]) %>% lapply(as.character) %>% as.data.frame() %>% arrange(PARAM, desc(GRADE_DIR), GRADE_ANL) basic_table() %>% split_cols_by(\"ARMCD\") %>% split_rows_by(\"PARAM\") %>% split_rows_by(\"GRADE_DIR\", split_fun = trim_levels_to_map(map)) %>% count_abnormal_by_worst_grade( var = \"GRADE_ANL\", variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\") ) %>% build_table(df = adlb_f) #> ARM A ARM B ARM C #> ——————————————————————————————————————————————————————————————————————————— #> Alanine Aminotransferase Measurement #> LOW #> 1 12 (17.4%) 5 (6.8%) 8 (13.8%) #> 2 9 (13%) 13 (17.8%) 6 (10.3%) #> 3 6 (8.7%) 4 (5.5%) 6 (10.3%) #> 4 7 (10.1%) 7 (9.6%) 6 (10.3%) #> Any 34 (49.3%) 29 (39.7%) 26 (44.8%) #> C-Reactive Protein Measurement #> LOW #> 1 11 (15.9%) 12 (16.4%) 7 (12.1%) #> 2 8 (11.6%) 2 (2.7%) 6 (10.3%) #> 3 4 (5.8%) 9 (12.3%) 6 (10.3%) #> 4 7 (10.1%) 6 (8.2%) 4 (6.9%) #> Any 30 (43.5%) 29 (39.7%) 23 (39.7%) #> HIGH #> 1 8 (11.6%) 11 (15.1%) 2 (3.4%) #> 2 9 (13%) 11 (15.1%) 11 (19%) #> 3 14 (20.3%) 10 (13.7%) 5 (8.6%) #> 4 2 (2.9%) 4 (5.5%) 6 (10.3%) #> Any 33 (47.8%) 36 (49.3%) 24 (41.4%) #> Immunoglobulin A Measurement #> HIGH #> 1 7 (10.1%) 7 (9.6%) 6 (10.3%) #> 2 8 (11.6%) 6 (8.2%) 8 (13.8%) #> 3 7 (10.1%) 5 (6.8%) 9 (15.5%) #> 4 6 (8.7%) 2 (2.7%) 3 (5.2%) #> Any 28 (40.6%) 20 (27.4%) 26 (44.8%)"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade_worsen.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"analyze function count_abnormal_lab_worsen_by_baseline() creates layout element count patients analysis toxicity grades worsened baseline, categorized highest (worst) grade post-baseline. function analyzes primary analysis variable var indicates analysis toxicity grades. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, baseline_var (defaults BTOXGR), variable indicate baseline toxicity grades, direction_var (defaults GRADDIR), variable indicate toxicity grade directions interest include (e.g. \"H\" (high), \"L\" (low), \"B\" ()). direction(s) specified direction_var, patient counts worst grade patients worsened baseline calculated follows: 1 4: number patients worsened baseline grades worst grades 1-4, respectively. : total number patients worsened baseline grades. Fractions calculated dividing counts number patients analysis toxicity grades worsened baseline toxicity grades treatment. Prior using function table layout must use rtables::split_rows_by() create row split variable direction_var.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade_worsen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"","code":"count_abnormal_lab_worsen_by_baseline( lyt, var, variables = list(id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\"), na_str = default_na_str(), nested = TRUE, ..., table_names = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_lab_worsen_by_baseline( df, .var = \"ATOXGR\", variables = list(id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\") ) a_count_abnormal_lab_worsen_by_baseline( df, .var = \"ATOXGR\", variables = list(id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\") )"},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade_worsen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"lyt (PreDataTableLayouts) layout analyses added . variables (named list string) list additional analysis variables including: id (string) subject variable name. baseline_var (string) name data column containing baseline toxicity variable. direction_var (string) see direction_var details. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade_worsen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"count_abnormal_lab_worsen_by_baseline() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_lab_worsen_by_baseline() table layout. s_count_abnormal_lab_worsen_by_baseline() returns counts fraction patients whose worst post-baseline lab grades worse baseline grades, post-baseline worst grades \"1\", \"2\", \"3\", \"4\" \"\". a_count_abnormal_lab_worsen_by_baseline() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade_worsen.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"count_abnormal_lab_worsen_by_baseline(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_lab_worsen_by_baseline(): Statistics function patients whose worst post-baseline lab grades worse baseline grades. a_count_abnormal_lab_worsen_by_baseline(): Formatted analysis function used afun count_abnormal_lab_worsen_by_baseline().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/abnormal_by_worst_grade_worsen.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"","code":"library(dplyr) # The direction variable, GRADDR, is based on metadata adlb <- tern_ex_adlb %>% mutate( GRADDR = case_when( PARAMCD == \"ALT\" ~ \"B\", PARAMCD == \"CRP\" ~ \"L\", PARAMCD == \"IGA\" ~ \"H\" ) ) %>% filter(SAFFL == \"Y\" & ONTRTFL == \"Y\" & GRADDR != \"\") df <- h_adlb_worsen( adlb, worst_flag_low = c(\"WGRLOFL\" = \"Y\"), worst_flag_high = c(\"WGRHIFL\" = \"Y\"), direction_var = \"GRADDR\" ) basic_table() %>% split_cols_by(\"ARMCD\") %>% add_colcounts() %>% split_rows_by(\"PARAMCD\") %>% split_rows_by(\"GRADDR\") %>% count_abnormal_lab_worsen_by_baseline( var = \"ATOXGR\", variables = list( id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\" ) ) %>% append_topleft(\"Direction of Abnormality\") %>% build_table(df = df, alt_counts_df = tern_ex_adsl) #> ARM A ARM B ARM C #> Direction of Abnormality (N=69) (N=73) (N=58) #> ———————————————————————————————————————————————————————————————————————— #> IGA #> High #> 1 6/63 (9.5%) 6/64 (9.4%) 4/50 (8%) #> 2 8/64 (12.5%) 5/67 (7.5%) 8/53 (15.1%) #> 3 7/66 (10.6%) 5/68 (7.4%) 9/57 (15.8%) #> 4 6/68 (8.8%) 2/72 (2.8%) 3/58 (5.2%) #> Any 27/68 (39.7%) 18/72 (25%) 24/58 (41.4%) #> ALT #> High #> 1 7/63 (11.1%) 6/62 (9.7%) 2/48 (4.2%) #> 2 12/63 (19%) 4/67 (6%) 11/50 (22%) #> 3 4/65 (6.2%) 11/71 (15.5%) 7/56 (12.5%) #> 4 1/67 (1.5%) 8/71 (11.3%) 4/57 (7%) #> Any 24/67 (35.8%) 29/71 (40.8%) 24/57 (42.1%) #> Low #> 1 12/67 (17.9%) 4/66 (6.1%) 7/52 (13.5%) #> 2 9/68 (13.2%) 12/69 (17.4%) 6/55 (10.9%) #> 3 6/69 (8.7%) 4/71 (5.6%) 5/56 (8.9%) #> 4 7/69 (10.1%) 7/73 (9.6%) 6/58 (10.3%) #> Any 34/69 (49.3%) 27/73 (37%) 24/58 (41.4%) #> CRP #> Low #> 1 11/66 (16.7%) 10/67 (14.9%) 4/47 (8.5%) #> 2 8/66 (12.1%) 1/70 (1.4%) 6/50 (12%) #> 3 4/68 (5.9%) 9/70 (12.9%) 5/53 (9.4%) #> 4 7/69 (10.1%) 6/72 (8.3%) 4/55 (7.3%) #> Any 30/69 (43.5%) 26/72 (36.1%) 19/55 (34.5%)"},{"path":"https://insightsengineering.github.io/tern/reference/add_riskdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Split function to configure risk difference column — add_riskdiff","title":"Split function to configure risk difference column — add_riskdiff","text":"Wrapper function rtables::add_combo_levels() configures settings risk difference column added rtables object. add risk difference column table, function used split_fun calls rtables::split_cols_by(), followed setting argument riskdiff TRUE following analyze function calls.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/add_riskdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split function to configure risk difference column — add_riskdiff","text":"","code":"add_riskdiff( arm_x, arm_y, col_label = paste0(\"Risk Difference (%) (95% CI)\", if (length(arm_y) > 1) paste0(\"\\n\", arm_x, \" vs. \", arm_y)), pct = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/add_riskdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split function to configure risk difference column — add_riskdiff","text":"arm_x (string) name reference arm use risk difference calculations. arm_y (character) names one arms compare reference arm risk difference calculations. new column added value arm_y. col_label (character) labels use rendering risk difference column within table. one comparison arm specified arm_y, default labels specify two arms compared (reference arm vs. comparison arm). pct (flag) whether output returned percentages. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/add_riskdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split function to configure risk difference column — add_riskdiff","text":"closure suitable use split function (split_fun) within rtables::split_cols_by() creating table layout.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/add_riskdiff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split function to configure risk difference column — add_riskdiff","text":"","code":"adae <- tern_ex_adae adae$AESEV <- factor(adae$AESEV) lyt <- basic_table() %>% split_cols_by(\"ARMCD\", split_fun = add_riskdiff(arm_x = \"ARM A\", arm_y = c(\"ARM B\", \"ARM C\"))) %>% count_occurrences_by_grade( var = \"AESEV\", riskdiff = TRUE ) tbl <- build_table(lyt, df = adae) tbl #> Risk Difference (%) (95% CI) Risk Difference (%) (95% CI) #> ARM A ARM B ARM C ARM A vs. ARM B ARM A vs. ARM C #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> MILD 6 (3.0%) 4 (2.3%) 2 (1.2%) 0.7 (-2.5 - 3.9) 1.7 (-1.2 - 4.6) #> MODERATE 19 (9.4%) 15 (8.5%) 14 (8.6%) 0.9 (-4.8 - 6.7) 0.8 (-5.1 - 6.7) #> SEVERE 34 (16.8%) 38 (21.5%) 32 (19.8%) -4.6 (-12.6 - 3.3) -2.9 (-10.9 - 5.1)"},{"path":"https://insightsengineering.github.io/tern/reference/add_rowcounts.html","id":null,"dir":"Reference","previous_headings":"","what":"Layout-creating function to add row total counts — add_rowcounts","title":"Layout-creating function to add row total counts — add_rowcounts","text":"works analogously rtables::add_colcounts() rows. function wrapper rtables::summarize_row_groups().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/add_rowcounts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Layout-creating function to add row total counts — add_rowcounts","text":"","code":"add_rowcounts(lyt, alt_counts = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/add_rowcounts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Layout-creating function to add row total counts — add_rowcounts","text":"lyt (PreDataTableLayouts) layout analyses added . alt_counts (flag) whether row counts taken alt_counts_df (TRUE) df (FALSE). Defaults FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/add_rowcounts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Layout-creating function to add row total counts — add_rowcounts","text":"modified layout latest row split labels now row-wise total counts (.e. without column-based subsetting) attached parentheses.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/add_rowcounts.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Layout-creating function to add row total counts — add_rowcounts","text":"Row count values contained row count rows displayed considered zero rows default pruning.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/add_rowcounts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Layout-creating function to add row total counts — add_rowcounts","text":"","code":"basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% split_rows_by(\"RACE\", split_fun = drop_split_levels) %>% add_rowcounts() %>% analyze(\"AGE\", afun = list_wrap_x(summary), format = \"xx.xx\") %>% build_table(DM) #> A: Drug X B: Placebo C: Combination #> (N=121) (N=106) (N=129) #> —————————————————————————————————————————————————————————————————————————— #> ASIAN (N=231) #> Min. 20.00 21.00 22.00 #> 1st Qu. 29.00 28.00 30.00 #> Median 33.00 32.50 33.50 #> Mean 34.20 32.68 34.63 #> 3rd Qu. 38.50 36.00 38.00 #> Max. 58.00 55.00 53.00 #> BLACK OR AFRICAN AMERICAN (N=79) #> Min. 23.00 21.00 24.00 #> 1st Qu. 29.00 28.75 29.00 #> Median 33.00 30.00 32.00 #> Mean 34.68 31.71 34.00 #> 3rd Qu. 37.25 36.25 39.00 #> Max. 60.00 42.00 51.00 #> WHITE (N=46) #> Min. 30.00 25.00 28.00 #> 1st Qu. 38.00 31.00 30.25 #> Median 40.50 37.50 35.00 #> Mean 39.36 36.93 35.11 #> 3rd Qu. 43.50 40.00 37.50 #> Max. 47.00 55.00 47.00"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/aesi_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for adverse event baskets — aesi_label","text":"","code":"aesi_label(aesi, scope = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/aesi_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for adverse event baskets — aesi_label","text":"aesi (character) vector standardized MedDRA query name (e.g. SMQxxNAM) customized query name (e.g. CQxxNAM). scope (character) vector scope query (e.g. SMQxxSC).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/aesi_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for adverse event baskets — aesi_label","text":"string standard label AE basket.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/aesi_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Labels for adverse event baskets — aesi_label","text":"","code":"adae <- tern_ex_adae # Standardized query label includes scope. aesi_label(adae$SMQ01NAM, scope = adae$SMQ01SC) #> [1] \"C.1.1.1.3/B.2.2.3.1 aesi (BROAD)\" # Customized query label. aesi_label(adae$CQ01NAM) #> [1] \"D.2.1.5.3/A.1.1.1.1 aesi\""},{"path":"https://insightsengineering.github.io/tern/reference/afun_riskdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Analysis function to calculate risk difference column values — afun_riskdiff","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"risk difference column, function uses statistics function associated afun calculates risk difference values arm X (reference group) arm Y. arms specified configuring risk difference column done using add_riskdiff() split function previous call rtables::split_cols_by(). columns, applies afun usual. function utilizes stat_propdiff_ci() function perform risk difference calculations.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/afun_riskdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"","code":"afun_riskdiff( df, labelstr = \"\", .var, .N_col, .N_row, .df_row, .spl_context, .all_col_counts, .stats, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str(), afun, s_args = list() )"},{"path":"https://insightsengineering.github.io/tern/reference/afun_riskdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .var (string) single variable name passed rtables requested statistics function. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .df_row (data.frame) data frame across columns given row split. .spl_context (data.frame) gives information ancestor split states passed rtables. .all_col_counts (integer) vector value represents global count column. Values taken alt_counts_df specified (see rtables::build_table()). .stats (character) statistics select table. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. na_str (string) string used replace NA empty values output. afun (named list) named list containing one name-value pair name corresponds name statistics function used calculations value corresponding analysis function. s_args (named list) additional arguments passed statistics function analysis function supplied afun.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/afun_riskdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"list formatted rtables::CellValue().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/afun_selected_stats.html","id":null,"dir":"Reference","previous_headings":"","what":"Get selected statistics names — afun_selected_stats","title":"Get selected statistics names — afun_selected_stats","text":"Helper function used creating afun.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/afun_selected_stats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get selected statistics names — afun_selected_stats","text":"","code":"afun_selected_stats(.stats, all_stats)"},{"path":"https://insightsengineering.github.io/tern/reference/afun_selected_stats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get selected statistics names — afun_selected_stats","text":".stats (vector NULL) input layout creating function. Note NULL means context default statistics used. all_stats (character) statistics can selected potentially.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/afun_selected_stats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get selected statistics names — afun_selected_stats","text":"character vector selected statistics.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_colvars_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze functions in columns — analyze_colvars_functions","title":"Analyze functions in columns — analyze_colvars_functions","text":"functions wrappers rtables::analyze_colvars() apply corresponding tern statistics functions add analysis given table layout. particular, functions designed analysis methods split different columns. analyze_vars_in_cols(): fundamental tabulation analysis methods onto columns. words, analysis methods defined column space, .e. become column labels. changing variable vector, list functions can applied different variables, caveat number statistical functions. tabulate_rsp_subgroups(): similarly analyze_vars_in_cols, function combines analyze_colvars summarize_row_groups compact way produce standard tables show analysis methods columns. tabulate_survival_subgroups(): function similar , used tables. analyze_patients_exposure_in_cols(): based analyze_colvars. needs summarize_patients_exposure_in_cols() leverage nesting label rows analysis rtables::summarize_row_groups(). summarize_coxreg(): generally based rtables::summarize_row_groups(), behaves similarly tabulate_* functions described designed provide specific standard tables may contain nested structure combination summarize_row_groups() rtables::analyze_colvars().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/analyze_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze functions — analyze_functions","title":"Analyze functions — analyze_functions","text":"functions wrappers rtables::analyze() apply corresponding tern statistics functions add analysis given table layout: analyze_num_patients() analyze_vars() compare_vars() count_abnormal() count_abnormal_by_baseline() count_abnormal_by_marked() count_abnormal_by_worst_grade() count_cumulative() count_missed_doses() count_occurrences() count_occurrences_by_grade() count_patients_events_in_cols() count_patients_with_event() count_patients_with_flags() count_values() coxph_pairwise() estimate_incidence_rate() estimate_multinomial_rsp() estimate_odds_ratio() estimate_proportion() estimate_proportion_diff() summarize_ancova() summarize_colvars(): even function uses rtables::analyze_colvars(), applies analysis methods different rows one variables split different columns. comparison, analyze_colvars_functions leverage analyze_colvars context split rows analysis methods columns. summarize_change() surv_time() surv_timepoint() test_proportion_diff()","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze variables — analyze_variables","title":"Analyze variables — analyze_variables","text":"analyze function analyze_vars() creates layout element summarize one variables, using S3 generic function s_summary() calculate list summary statistics. list available statistics numeric variables can viewed running get_stats(\"analyze_vars_numeric\") non-numeric variables running get_stats(\"analyze_vars_counts\"). Use .stats parameter specify statistics include output summary table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analyze variables — analyze_variables","text":"","code":"analyze_vars( lyt, vars, var_labels = vars, na_str = default_na_str(), nested = TRUE, ..., na.rm = TRUE, show_labels = \"default\", table_names = vars, section_div = NA_character_, .stats = c(\"n\", \"mean_sd\", \"median\", \"range\", \"count_fraction\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_summary(x, na.rm = TRUE, denom, .N_row, .N_col, .var, ...) # S3 method for class 'numeric' s_summary( x, na.rm = TRUE, denom, .N_row, .N_col, .var, control = control_analyze_vars(), ... ) # S3 method for class 'factor' s_summary( x, na.rm = TRUE, denom = c(\"n\", \"N_col\", \"N_row\"), .N_row, .N_col, ... ) # S3 method for class 'character' s_summary( x, na.rm = TRUE, denom = c(\"n\", \"N_col\", \"N_row\"), .N_row, .N_col, .var, verbose = TRUE, ... ) # S3 method for class 'logical' s_summary( x, na.rm = TRUE, denom = c(\"n\", \"N_col\", \"N_row\"), .N_row, .N_col, ... ) a_summary( x, .N_col, .N_row, .var = NULL, .df_row = NULL, .ref_group = NULL, .in_ref_col = FALSE, compare = FALSE, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na.rm = TRUE, na_str = default_na_str(), ... )"},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analyze variables — analyze_variables","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... arguments passed s_summary(). na.rm (flag) whether NA values removed x prior analysis. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. .stats (character) statistics select table. Options numeric variables : 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d' Options non-numeric variables : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. x (numeric) vector numbers want analyze. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .var (string) single variable name passed rtables requested statistics function. control (list) parameters descriptive statistics details, specified using helper function control_analyze_vars(). possible parameter options : conf_level (proportion) confidence level interval mean median. quantiles (numeric(2)) vector length two specify quantiles. quantile_type (numeric(1)) 1 9 selecting quantile algorithms used. See type stats::quantile(). test_mean (numeric(1)) value test mean null hypothesis calculating p-value. verbose (flag) defaults TRUE, prints warnings messages. mainly used print information factor casting. .df_row (data.frame) data frame across columns given row split. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. compare (flag) whether comparison statistics analyzed instead summary statistics (compare = TRUE adds pval statistic comparing reference group).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Analyze variables — analyze_variables","text":"analyze_vars() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_summary() table layout. s_summary() returns different statistics depending class x. x class numeric, returns list following named numeric items: n: length() x. sum: sum() x. mean: mean() x. sd: stats::sd() x. se: standard error x mean, .e.: (sd(x) / sqrt(length(x))). mean_sd: mean() stats::sd() x. mean_se: mean() x standard error (see ). mean_ci: CI mean x (stat_mean_ci()). mean_sei: SE interval mean x, .e.: (mean() -/+ stats::sd() / sqrt()). mean_sdi: SD interval mean x, .e.: (mean() -/+ stats::sd()). mean_pval: two-sided p-value mean x (stat_mean_pval()). median: stats::median() x. mad: median absolute deviation x, .e.: (stats::median() xc, xc = x - stats::median()). median_ci: CI median x (stat_median_ci()). quantiles: Two sample quantiles x (stats::quantile()). iqr: stats::IQR() x. range: range_noinf() x. min: max() x. max: min() x. median_range: median() range_noinf() x. cv: coefficient variation x, .e.: (stats::sd() / mean() * 100). geom_mean: geometric mean x, .e.: (exp(mean(log(x)))). geom_cv: geometric coefficient variation x, .e.: (sqrt(exp(sd(log(x)) ^ 2) - 1) * 100). x class factor converted character, returns list named numeric items: n: length() x. count: list number cases level factor x. count_fraction: Similar count also includes proportion cases level factor x relative denominator, NA denominator zero. x class logical, returns list named numeric items: n: length() x (possibly removing NAs). count: Count TRUE x. count_fraction: Count proportion TRUE x relative denominator, NA denominator zero. Note NAs x never counted leading NA . a_summary() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Analyze variables — analyze_variables","text":"Automatic digit formatting: number digits display can automatically determined analyzed variable(s) (vars) certain statistics setting statistic format \"auto\" .formats. utilizes format_auto() formatting function. Note data current row & variable (columns) considered (.df_row[[.var]], see rtables::additional_fun_params) whole dataset.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Analyze variables — analyze_variables","text":"analyze_vars(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_summary(): S3 generic function produces variable summary. s_summary(numeric): Method numeric class. s_summary(factor): Method factor class. s_summary(character): Method character class. makes automatic conversion factor (warning) forwards method factors. s_summary(logical): Method logical class. a_summary(): Formatted analysis function used afun analyze_vars() compare_vars() cfun summarize_colvars().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Analyze variables — analyze_variables","text":"x empty vector, NA returned. expected feature return rcell content rtables intersection column row delimits empty data selection. mean function applied empty vector, NA returned instead NaN, latter standard behavior R. x empty factor, list still returned counts one element per factor level. levels x, function fails. factor variables contain NA, NA values excluded default. include NA values set na.rm = FALSE missing values displayed NA level. Alternatively, explicit factor level can defined NA values pre-processing via df_explicit_na() - default na_level (\"\") also excluded na.rm set TRUE. Automatic conversion character factor guarantee table can generated correctly. particular sparse tables likely can fail. therefore better always pre-process dataset factors manually created character variables passing dataset rtables::build_table(). use comparison (additional p-value statistic), parameter compare must set TRUE. Ensure either NA values converted explicit NA level NA values left .","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_variables.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Analyze variables — analyze_variables","text":"","code":"## Fabricated dataset. dta_test <- data.frame( USUBJID = rep(1:6, each = 3), PARAMCD = rep(\"lab\", 6 * 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)) ) # `analyze_vars()` in `rtables` pipelines ## Default output within a `rtables` pipeline. l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\") build_table(l, df = dta_test) #> A B C #> ———————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.5 (2.1) 3.0 (NA) NA #> Median 7.5 3.0 NA #> Min - Max 6.0 - 9.0 3.0 - 3.0 NA #> V2 #> n 2 1 0 #> Mean (SD) 6.5 (2.1) 2.0 (NA) NA #> Median 6.5 2.0 NA #> Min - Max 5.0 - 8.0 2.0 - 2.0 NA #> V3 #> n 2 1 0 #> Mean (SD) 5.5 (2.1) 1.0 (NA) NA #> Median 5.5 1.0 NA #> Min - Max 4.0 - 7.0 1.0 - 1.0 NA ## Select and format statistics output. l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars( vars = \"AVAL\", .stats = c(\"n\", \"mean_sd\", \"quantiles\"), .formats = c(\"mean_sd\" = \"xx.x, xx.x\"), .labels = c(n = \"n\", mean_sd = \"Mean, SD\", quantiles = c(\"Q1 - Q3\")) ) build_table(l, df = dta_test) #> A B C #> ——————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean, SD 7.5, 2.1 3.0, NA NA #> Q1 - Q3 6.0 - 9.0 3.0 - 3.0 NA #> V2 #> n 2 1 0 #> Mean, SD 6.5, 2.1 2.0, NA NA #> Q1 - Q3 5.0 - 8.0 2.0 - 2.0 NA #> V3 #> n 2 1 0 #> Mean, SD 5.5, 2.1 1.0, NA NA #> Q1 - Q3 4.0 - 7.0 1.0 - 1.0 NA ## Use arguments interpreted by `s_summary`. l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\", na.rm = FALSE) build_table(l, df = dta_test) #> A B C #> ————————————————————————————————— #> V1 #> n 2 2 2 #> Mean (SD) 7.5 (2.1) NA NA #> Median 7.5 NA NA #> Min - Max 6.0 - 9.0 NA NA #> V2 #> n 2 2 2 #> Mean (SD) 6.5 (2.1) NA NA #> Median 6.5 NA NA #> Min - Max 5.0 - 8.0 NA NA #> V3 #> n 2 2 2 #> Mean (SD) 5.5 (2.1) NA NA #> Median 5.5 NA NA #> Min - Max 4.0 - 7.0 NA NA ## Handle `NA` levels first when summarizing factors. dta_test$AVISIT <- NA_character_ dta_test <- df_explicit_na(dta_test) l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% analyze_vars(vars = \"AVISIT\", na.rm = FALSE) build_table(l, df = dta_test) #> A B C #> —————————————————————————————————————————— #> n 6 6 6 #> 6 (100%) 6 (100%) 6 (100%) # auto format dt <- data.frame(\"VAR\" = c(0.001, 0.2, 0.0011000, 3, 4)) basic_table() %>% analyze_vars( vars = \"VAR\", .stats = c(\"n\", \"mean\", \"mean_sd\", \"range\"), .formats = c(\"mean_sd\" = \"auto\", \"range\" = \"auto\") ) %>% build_table(dt) #> all obs #> ————————————————————————————— #> n 5 #> Mean 1.4 #> Mean (SD) 1.44042 (1.91481) #> Min - Max 0.0010 - 4.0000 # `s_summary.numeric` ## Basic usage: empty numeric returns NA-filled items. s_summary(numeric()) #> $n #> n #> 0 #> #> $sum #> sum #> NA #> #> $mean #> mean #> NA #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> NA NA #> #> $mean_se #> mean se #> NA NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> NA #> #> $mad #> mad #> NA #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> NA #> #> $range #> min max #> NA NA #> #> $min #> min #> NA #> #> $max #> max #> NA #> #> $median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> NaN #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> ## Management of NA values. x <- c(NA_real_, 1) s_summary(x, na.rm = TRUE) #> $n #> n #> 1 #> #> $sum #> sum #> 1 #> #> $mean #> mean #> 1 #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> 1 NA #> #> $mean_se #> mean se #> 1 NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 1 NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 1 #> #> $mad #> mad #> 0 #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 1 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 1 1 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 0 #> #> $range #> min max #> 1 1 #> #> $min #> min #> 1 #> #> $max #> max #> 1 #> #> $median_range #> median min max #> 1 1 1 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> 1 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 1 NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> s_summary(x, na.rm = FALSE) #> $n #> n #> 2 #> #> $sum #> sum #> NA #> #> $mean #> mean #> NA #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> NA NA #> #> $mean_se #> mean se #> NA NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> NA #> #> $mad #> mad #> NA #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> NA #> #> $range #> min max #> NA NA #> #> $min #> min #> NA #> #> $max #> max #> NA #> #> $median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> NA #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> x <- c(NA_real_, 1, 2) s_summary(x, stats = NULL) #> $n #> n #> 2 #> #> $sum #> sum #> 3 #> #> $mean #> mean #> 1.5 #> #> $sd #> sd #> 0.7071068 #> #> $se #> se #> 0.5 #> #> $mean_sd #> mean sd #> 1.5000000 0.7071068 #> #> $mean_se #> mean se #> 1.5 0.5 #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> 1 2 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 0.7928932 2.2071068 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 1.500000 -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> 0.2048328 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 1.5 #> #> $mad #> mad #> 0 #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 1.5 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 1 2 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 1 #> #> $range #> min max #> 1 2 #> #> $min #> min #> 1 #> #> $max #> max #> 2 #> #> $median_range #> median min max #> 1.5 1.0 2.0 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> 47.14045 #> #> $geom_mean #> geom_mean #> 1.414214 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> 52.10922 #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 1.41421356 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> ## Benefits in `rtables` contructions: dta_test <- data.frame( Group = rep(LETTERS[1:3], each = 2), sub_group = rep(letters[1:2], each = 3), x = 1:6 ) ## The summary obtained in with `rtables`: basic_table() %>% split_cols_by(var = \"Group\") %>% split_rows_by(var = \"sub_group\") %>% analyze(vars = \"x\", afun = s_summary) %>% build_table(df = dta_test) #> A B C #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> a #> n 2 1 0 #> sum 3 3 NA #> mean 1.5 3 NA #> sd 0.707106781186548 NA NA #> se 0.5 NA NA #> mean_sd 1.5, 0.707106781186548 3, NA NA #> mean_se 1.5, 0.5 3, NA NA #> Mean 95% CI -4.85310236808735, 7.85310236808735 NA NA #> Mean -/+ 1xSE 1, 2 NA NA #> Mean -/+ 1xSD 0.792893218813452, 2.20710678118655 NA NA #> Mean (95% CI) 1.5, -4.85310236808735, 7.85310236808735 3, NA, NA NA #> Mean p-value (H0: mean = 0) 0.204832764699133 NA NA #> median 1.5 3 NA #> mad 0 0 NA #> Median 95% CI NA NA NA #> Median (95% CI) 1.5, NA, NA 3, NA, NA NA #> 25% and 75%-ile 1, 2 3, 3 NA #> iqr 1 0 NA #> range 1, 2 3, 3 NA #> min 1 3 NA #> max 2 3 NA #> Median (Min - Max) 1.5, 1, 2 3, 3, 3 NA #> cv 47.1404520791032 NA NA #> geom_mean 1.41421356237309 3 NA #> Geometric Mean 95% CI 0.0172997815631007, 115.608396135236 NA NA #> geom_cv 52.1092246837487 NA NA #> Geometric Mean (95% CI) 1.41421356237309, 0.0172997815631007, 115.608396135236 3, NA, NA NA #> b #> n 0 1 2 #> sum NA 4 11 #> mean NA 4 5.5 #> sd NA NA 0.707106781186548 #> se NA NA 0.5 #> mean_sd NA 4, NA 5.5, 0.707106781186548 #> mean_se NA 4, NA 5.5, 0.5 #> Mean 95% CI NA NA -0.853102368087347, 11.8531023680873 #> Mean -/+ 1xSE NA NA 5, 6 #> Mean -/+ 1xSD NA NA 4.79289321881345, 6.20710678118655 #> Mean (95% CI) NA 4, NA, NA 5.5, -0.853102368087347, 11.8531023680873 #> Mean p-value (H0: mean = 0) NA NA 0.0577158767526089 #> median NA 4 5.5 #> mad NA 0 0 #> Median 95% CI NA NA NA #> Median (95% CI) NA 4, NA, NA 5.5, NA, NA #> 25% and 75%-ile NA 4, 4 5, 6 #> iqr NA 0 1 #> range NA 4, 4 5, 6 #> min NA 4 5 #> max NA 4 6 #> Median (Min - Max) NA 4, 4, 4 5.5, 5, 6 #> cv NA NA 12.8564869306645 #> geom_mean NA 4 5.47722557505166 #> Geometric Mean 95% CI NA NA 1.71994304449266, 17.4424380482025 #> geom_cv NA NA 12.945835316564 #> Geometric Mean (95% CI) NA 4, NA, NA 5.47722557505166, 1.71994304449266, 17.4424380482025 ## By comparison with `lapply`: X <- split(dta_test, f = with(dta_test, interaction(Group, sub_group))) lapply(X, function(x) s_summary(x$x)) #> $A.a #> $A.a$n #> n #> 2 #> #> $A.a$sum #> sum #> 3 #> #> $A.a$mean #> mean #> 1.5 #> #> $A.a$sd #> sd #> 0.7071068 #> #> $A.a$se #> se #> 0.5 #> #> $A.a$mean_sd #> mean sd #> 1.5000000 0.7071068 #> #> $A.a$mean_se #> mean se #> 1.5 0.5 #> #> $A.a$mean_ci #> mean_ci_lwr mean_ci_upr #> -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $A.a$mean_sei #> mean_sei_lwr mean_sei_upr #> 1 2 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $A.a$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 0.7928932 2.2071068 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $A.a$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 1.500000 -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $A.a$mean_pval #> p_value #> 0.2048328 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $A.a$median #> median #> 1.5 #> #> $A.a$mad #> mad #> 0 #> #> $A.a$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $A.a$median_ci_3d #> median median_ci_lwr median_ci_upr #> 1.5 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $A.a$quantiles #> quantile_0.25 quantile_0.75 #> 1 2 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $A.a$iqr #> iqr #> 1 #> #> $A.a$range #> min max #> 1 2 #> #> $A.a$min #> min #> 1 #> #> $A.a$max #> max #> 2 #> #> $A.a$median_range #> median min max #> 1.5 1.0 2.0 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $A.a$cv #> cv #> 47.14045 #> #> $A.a$geom_mean #> geom_mean #> 1.414214 #> #> $A.a$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $A.a$geom_cv #> geom_cv #> 52.10922 #> #> $A.a$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 1.41421356 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $B.a #> $B.a$n #> n #> 1 #> #> $B.a$sum #> sum #> 3 #> #> $B.a$mean #> mean #> 3 #> #> $B.a$sd #> sd #> NA #> #> $B.a$se #> se #> NA #> #> $B.a$mean_sd #> mean sd #> 3 NA #> #> $B.a$mean_se #> mean se #> 3 NA #> #> $B.a$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $B.a$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $B.a$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $B.a$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 3 NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $B.a$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $B.a$median #> median #> 3 #> #> $B.a$mad #> mad #> 0 #> #> $B.a$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $B.a$median_ci_3d #> median median_ci_lwr median_ci_upr #> 3 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $B.a$quantiles #> quantile_0.25 quantile_0.75 #> 3 3 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $B.a$iqr #> iqr #> 0 #> #> $B.a$range #> min max #> 3 3 #> #> $B.a$min #> min #> 3 #> #> $B.a$max #> max #> 3 #> #> $B.a$median_range #> median min max #> 3 3 3 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $B.a$cv #> cv #> NA #> #> $B.a$geom_mean #> geom_mean #> 3 #> #> $B.a$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $B.a$geom_cv #> geom_cv #> NA #> #> $B.a$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 3 NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $C.a #> $C.a$n #> n #> 0 #> #> $C.a$sum #> sum #> NA #> #> $C.a$mean #> mean #> NA #> #> $C.a$sd #> sd #> NA #> #> $C.a$se #> se #> NA #> #> $C.a$mean_sd #> mean sd #> NA NA #> #> $C.a$mean_se #> mean se #> NA NA #> #> $C.a$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $C.a$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $C.a$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $C.a$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $C.a$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $C.a$median #> median #> NA #> #> $C.a$mad #> mad #> NA #> #> $C.a$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $C.a$median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $C.a$quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $C.a$iqr #> iqr #> NA #> #> $C.a$range #> min max #> NA NA #> #> $C.a$min #> min #> NA #> #> $C.a$max #> max #> NA #> #> $C.a$median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $C.a$cv #> cv #> NA #> #> $C.a$geom_mean #> geom_mean #> NaN #> #> $C.a$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $C.a$geom_cv #> geom_cv #> NA #> #> $C.a$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $A.b #> $A.b$n #> n #> 0 #> #> $A.b$sum #> sum #> NA #> #> $A.b$mean #> mean #> NA #> #> $A.b$sd #> sd #> NA #> #> $A.b$se #> se #> NA #> #> $A.b$mean_sd #> mean sd #> NA NA #> #> $A.b$mean_se #> mean se #> NA NA #> #> $A.b$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $A.b$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $A.b$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $A.b$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $A.b$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $A.b$median #> median #> NA #> #> $A.b$mad #> mad #> NA #> #> $A.b$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $A.b$median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $A.b$quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $A.b$iqr #> iqr #> NA #> #> $A.b$range #> min max #> NA NA #> #> $A.b$min #> min #> NA #> #> $A.b$max #> max #> NA #> #> $A.b$median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $A.b$cv #> cv #> NA #> #> $A.b$geom_mean #> geom_mean #> NaN #> #> $A.b$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $A.b$geom_cv #> geom_cv #> NA #> #> $A.b$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $B.b #> $B.b$n #> n #> 1 #> #> $B.b$sum #> sum #> 4 #> #> $B.b$mean #> mean #> 4 #> #> $B.b$sd #> sd #> NA #> #> $B.b$se #> se #> NA #> #> $B.b$mean_sd #> mean sd #> 4 NA #> #> $B.b$mean_se #> mean se #> 4 NA #> #> $B.b$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $B.b$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $B.b$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $B.b$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 4 NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $B.b$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $B.b$median #> median #> 4 #> #> $B.b$mad #> mad #> 0 #> #> $B.b$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $B.b$median_ci_3d #> median median_ci_lwr median_ci_upr #> 4 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $B.b$quantiles #> quantile_0.25 quantile_0.75 #> 4 4 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $B.b$iqr #> iqr #> 0 #> #> $B.b$range #> min max #> 4 4 #> #> $B.b$min #> min #> 4 #> #> $B.b$max #> max #> 4 #> #> $B.b$median_range #> median min max #> 4 4 4 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $B.b$cv #> cv #> NA #> #> $B.b$geom_mean #> geom_mean #> 4 #> #> $B.b$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $B.b$geom_cv #> geom_cv #> NA #> #> $B.b$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 4 NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $C.b #> $C.b$n #> n #> 2 #> #> $C.b$sum #> sum #> 11 #> #> $C.b$mean #> mean #> 5.5 #> #> $C.b$sd #> sd #> 0.7071068 #> #> $C.b$se #> se #> 0.5 #> #> $C.b$mean_sd #> mean sd #> 5.5000000 0.7071068 #> #> $C.b$mean_se #> mean se #> 5.5 0.5 #> #> $C.b$mean_ci #> mean_ci_lwr mean_ci_upr #> -0.8531024 11.8531024 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $C.b$mean_sei #> mean_sei_lwr mean_sei_upr #> 5 6 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $C.b$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 4.792893 6.207107 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $C.b$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 5.5000000 -0.8531024 11.8531024 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $C.b$mean_pval #> p_value #> 0.05771588 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $C.b$median #> median #> 5.5 #> #> $C.b$mad #> mad #> 0 #> #> $C.b$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $C.b$median_ci_3d #> median median_ci_lwr median_ci_upr #> 5.5 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $C.b$quantiles #> quantile_0.25 quantile_0.75 #> 5 6 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $C.b$iqr #> iqr #> 1 #> #> $C.b$range #> min max #> 5 6 #> #> $C.b$min #> min #> 5 #> #> $C.b$max #> max #> 6 #> #> $C.b$median_range #> median min max #> 5.5 5.0 6.0 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $C.b$cv #> cv #> 12.85649 #> #> $C.b$geom_mean #> geom_mean #> 5.477226 #> #> $C.b$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 1.719943 17.442438 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $C.b$geom_cv #> geom_cv #> 12.94584 #> #> $C.b$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 5.477226 1.719943 17.442438 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> # `s_summary.factor` ## Basic usage: s_summary(factor(c(\"a\", \"a\", \"b\", \"c\", \"a\"))) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> # Empty factor returns zero-filled items. s_summary(factor(levels = c(\"a\", \"b\", \"c\"))) #> $n #> [1] 0 #> #> $count #> $count$a #> [1] 0 #> #> $count$b #> [1] 0 #> #> $count$c #> [1] 0 #> #> #> $count_fraction #> $count_fraction$a #> [1] 0 0 #> #> $count_fraction$b #> [1] 0 0 #> #> $count_fraction$c #> [1] 0 0 #> #> #> $fraction #> $fraction$a #> num denom #> 0 0 #> #> $fraction$b #> num denom #> 0 0 #> #> $fraction$c #> num denom #> 0 0 #> #> #> $n_blq #> [1] 0 #> ## Management of NA values. x <- factor(c(NA, \"Female\")) x <- explicit_na(x) s_summary(x, na.rm = TRUE) #> $n #> [1] 1 #> #> $count #> $count$Female #> [1] 1 #> #> #> $count_fraction #> $count_fraction$Female #> [1] 1 1 #> #> #> $fraction #> $fraction$Female #> num denom #> 1 1 #> #> #> $n_blq #> [1] 0 #> s_summary(x, na.rm = FALSE) #> $n #> [1] 2 #> #> $count #> $count$Female #> [1] 1 #> #> $count$`` #> [1] 1 #> #> #> $count_fraction #> $count_fraction$Female #> [1] 1.0 0.5 #> #> $count_fraction$`` #> [1] 1.0 0.5 #> #> #> $fraction #> $fraction$Female #> num denom #> 1 2 #> #> $fraction$`` #> num denom #> 1 2 #> #> #> $n_blq #> [1] 0 #> ## Different denominators. x <- factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")) s_summary(x, denom = \"N_row\", .N_row = 10L) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.3 #> #> $count_fraction$b #> [1] 1.0 0.1 #> #> $count_fraction$c #> [1] 1.0 0.1 #> #> #> $fraction #> $fraction$a #> num denom #> 3 10 #> #> $fraction$b #> num denom #> 1 10 #> #> $fraction$c #> num denom #> 1 10 #> #> #> $n_blq #> [1] 0 #> s_summary(x, denom = \"N_col\", .N_col = 20L) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.00 0.15 #> #> $count_fraction$b #> [1] 1.00 0.05 #> #> $count_fraction$c #> [1] 1.00 0.05 #> #> #> $fraction #> $fraction$a #> num denom #> 3 20 #> #> $fraction$b #> num denom #> 1 20 #> #> $fraction$c #> num denom #> 1 20 #> #> #> $n_blq #> [1] 0 #> # `s_summary.character` ## Basic usage: s_summary(c(\"a\", \"a\", \"b\", \"c\", \"a\"), .var = \"x\", verbose = FALSE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> s_summary(c(\"a\", \"a\", \"b\", \"c\", \"a\", \"\"), .var = \"x\", na.rm = FALSE, verbose = FALSE) #> $n #> [1] 6 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> $count$`NA` #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.5 #> #> $count_fraction$b #> [1] 1.0000000 0.1666667 #> #> $count_fraction$c #> [1] 1.0000000 0.1666667 #> #> $count_fraction$`NA` #> [1] 1.0000000 0.1666667 #> #> #> $fraction #> $fraction$a #> num denom #> 3 6 #> #> $fraction$b #> num denom #> 1 6 #> #> $fraction$c #> num denom #> 1 6 #> #> $fraction$`NA` #> num denom #> 1 6 #> #> #> $n_blq #> [1] 0 #> # `s_summary.logical` ## Basic usage: s_summary(c(TRUE, FALSE, TRUE, TRUE)) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.00 0.75 #> #> $n_blq #> [1] 0 #> # Empty factor returns zero-filled items. s_summary(as.logical(c())) #> $n #> [1] 0 #> #> $count #> [1] 0 #> #> $count_fraction #> [1] 0 0 #> #> $n_blq #> [1] 0 #> ## Management of NA values. x <- c(NA, TRUE, FALSE) s_summary(x, na.rm = TRUE) #> $n #> [1] 2 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0 0.5 #> #> $n_blq #> [1] 0 #> s_summary(x, na.rm = FALSE) #> $n #> [1] 3 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0000000 0.3333333 #> #> $n_blq #> [1] 0 #> ## Different denominators. x <- c(TRUE, FALSE, TRUE, TRUE) s_summary(x, denom = \"N_row\", .N_row = 10L) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.0 0.3 #> #> $n_blq #> [1] 0 #> s_summary(x, denom = \"N_col\", .N_col = 20L) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.00 0.15 #> #> $n_blq #> [1] 0 #> a_summary(factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")), .N_row = 10, .N_col = 10) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 5 0 n #> 2 count.a 3 0 a #> 3 count.b 1 0 b #> 4 count.c 1 0 c #> 5 count_fraction.a 3 (60%) 0 a #> 6 count_fraction.b 1 (20%) 0 b #> 7 count_fraction.c 1 (20%) 0 c #> 8 count_fraction_fixed_dp.a 3 (60.0%) 0 a #> 9 count_fraction_fixed_dp.b 1 (20.0%) 0 b #> 10 count_fraction_fixed_dp.c 1 (20.0%) 0 c #> 11 fraction.a 3/5 (60.0%) 0 a #> 12 fraction.b 1/5 (20.0%) 0 b #> 13 fraction.c 1/5 (20.0%) 0 c #> 14 n_blq 0 0 n_blq a_summary( factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")), .ref_group = factor(c(\"a\", \"a\", \"b\", \"c\")), compare = TRUE ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 n 5 0 #> 2 count.a 3 0 #> 3 count.b 1 0 #> 4 count.c 1 0 #> 5 count_fraction.a 3 (60%) 0 #> 6 count_fraction.b 1 (20%) 0 #> 7 count_fraction.c 1 (20%) 0 #> 8 count_fraction_fixed_dp.a 3 (60.0%) 0 #> 9 count_fraction_fixed_dp.b 1 (20.0%) 0 #> 10 count_fraction_fixed_dp.c 1 (20.0%) 0 #> 11 fraction.a 3/5 (60.0%) 0 #> 12 fraction.b 1/5 (20.0%) 0 #> 13 fraction.c 1/5 (20.0%) 0 #> 14 n_blq 0 0 #> 15 pval_counts 0.9560 0 #> row_label #> 1 n #> 2 a #> 3 b #> 4 c #> 5 a #> 6 b #> 7 c #> 8 a #> 9 b #> 10 c #> 11 a #> 12 b #> 13 c #> 14 n_blq #> 15 p-value (chi-squared test) a_summary(c(\"A\", \"B\", \"A\", \"C\"), .var = \"x\", .N_col = 10, .N_row = 10, verbose = FALSE) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 4 0 n #> 2 count.A 2 0 A #> 3 count.B 1 0 B #> 4 count.C 1 0 C #> 5 count_fraction.A 2 (50%) 0 A #> 6 count_fraction.B 1 (25%) 0 B #> 7 count_fraction.C 1 (25%) 0 C #> 8 count_fraction_fixed_dp.A 2 (50.0%) 0 A #> 9 count_fraction_fixed_dp.B 1 (25.0%) 0 B #> 10 count_fraction_fixed_dp.C 1 (25.0%) 0 C #> 11 fraction.A 2/4 (50.0%) 0 A #> 12 fraction.B 1/4 (25.0%) 0 B #> 13 fraction.C 1/4 (25.0%) 0 C #> 14 n_blq 0 0 n_blq a_summary( c(\"A\", \"B\", \"A\", \"C\"), .ref_group = c(\"B\", \"A\", \"C\"), .var = \"x\", compare = TRUE, verbose = FALSE ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 n 4 0 #> 2 count.A 2 0 #> 3 count.B 1 0 #> 4 count.C 1 0 #> 5 count_fraction.A 2 (50%) 0 #> 6 count_fraction.B 1 (25%) 0 #> 7 count_fraction.C 1 (25%) 0 #> 8 count_fraction_fixed_dp.A 2 (50.0%) 0 #> 9 count_fraction_fixed_dp.B 1 (25.0%) 0 #> 10 count_fraction_fixed_dp.C 1 (25.0%) 0 #> 11 fraction.A 2/4 (50.0%) 0 #> 12 fraction.B 1/4 (25.0%) 0 #> 13 fraction.C 1/4 (25.0%) 0 #> 14 n_blq 0 0 #> 15 pval_counts 0.9074 0 #> row_label #> 1 n #> 2 A #> 3 B #> 4 C #> 5 A #> 6 B #> 7 C #> 8 A #> 9 B #> 10 C #> 11 A #> 12 B #> 13 C #> 14 n_blq #> 15 p-value (chi-squared test) a_summary(c(TRUE, FALSE, FALSE, TRUE, TRUE), .N_row = 10, .N_col = 10) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 5 0 n #> 2 count 3 0 count #> 3 count_fraction 3 (60%) 0 count_fraction #> 4 count_fraction_fixed_dp 3 (60.0%) 0 count_fraction #> 5 fraction 0 fraction #> 6 n_blq 0 0 n_blq a_summary( c(TRUE, FALSE, FALSE, TRUE, TRUE), .ref_group = c(TRUE, FALSE), .in_ref_col = TRUE, compare = TRUE ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 5 0 n #> 2 count 3 0 count #> 3 count_fraction 3 (60%) 0 count_fraction #> 4 count_fraction_fixed_dp 3 (60.0%) 0 count_fraction #> 5 fraction 0 fraction #> 6 n_blq 0 0 n_blq #> 7 pval_counts 0 p-value (chi-squared test) a_summary(rnorm(10), .N_col = 10, .N_row = 20, .var = \"bla\") #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 10 0 n #> 2 sum -4.4 0 Sum #> 3 mean -0.4 0 Mean #> 4 sd 1.1 0 SD #> 5 se 0.4 0 SE #> 6 mean_sd -0.4 (1.1) 0 Mean (SD) #> 7 mean_se -0.4 (0.4) 0 Mean (SE) #> 8 mean_ci (-1.24, 0.36) 0 Mean 95% CI #> 9 mean_sei (-0.79, -0.09) 0 Mean -/+ 1xSE #> 10 mean_sdi (-1.56, 0.68) 0 Mean -/+ 1xSD #> 11 mean_pval 0.2432 0 Mean p-value (H0: mean = 0) #> 12 median -0.2 0 Median #> 13 mad 0.0 0 Median Absolute Deviation #> 14 median_ci (-1.82, 0.62) 0 Median 95% CI #> 15 quantiles -1.4 - 0.3 0 25% and 75%-ile #> 16 iqr 1.7 0 IQR #> 17 range -2.4 - 1.1 0 Min - Max #> 18 min -2.4 0 Minimum #> 19 max 1.1 0 Maximum #> 20 median_range -0.2 (-2.4 - 1.1) 0 Median (Min - Max) #> 21 cv -253.2 0 CV (%) #> 22 geom_mean NA 0 Geometric Mean #> 23 geom_mean_ci NA 0 Geometric Mean 95% CI #> 24 geom_cv NA 0 CV % Geometric Mean #> 25 median_ci_3d -0.25 (-1.82 - 0.62) 0 Median (95% CI) #> 26 mean_ci_3d -0.44 (-1.24 - 0.36) 0 Mean (95% CI) #> 27 geom_mean_ci_3d NA 0 Geometric Mean (95% CI) a_summary(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .var = \"bla\", compare = TRUE) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 10 0 n #> 2 sum 48.2 0 Sum #> 3 mean 4.8 0 Mean #> 4 sd 1.2 0 SD #> 5 se 0.4 0 SE #> 6 mean_sd 4.8 (1.2) 0 Mean (SD) #> 7 mean_se 4.8 (0.4) 0 Mean (SE) #> 8 mean_ci (3.98, 5.66) 0 Mean 95% CI #> 9 mean_sei (4.45, 5.19) 0 Mean -/+ 1xSE #> 10 mean_sdi (3.65, 6.00) 0 Mean -/+ 1xSD #> 11 mean_pval <0.0001 0 Mean p-value (H0: mean = 0) #> 12 median 4.7 0 Median #> 13 mad 0.0 0 Median Absolute Deviation #> 14 median_ci (3.37, 5.63) 0 Median 95% CI #> 15 quantiles 4.1 - 5.5 0 25% and 75%-ile #> 16 iqr 1.5 0 IQR #> 17 range 3.1 - 7.1 0 Min - Max #> 18 min 3.1 0 Minimum #> 19 max 7.1 0 Maximum #> 20 median_range 4.7 (3.1 - 7.1) 0 Median (Min - Max) #> 21 cv 24.4 0 CV (%) #> 22 geom_mean 4.7 0 Geometric Mean #> 23 geom_mean_ci (3.93, 5.60) 0 Geometric Mean 95% CI #> 24 geom_cv 25.2 0 CV % Geometric Mean #> 25 median_ci_3d 4.71 (3.37 - 5.63) 0 Median (95% CI) #> 26 mean_ci_3d 4.82 (3.98 - 5.66) 0 Mean (95% CI) #> 27 geom_mean_ci_3d 4.69 (3.93 - 5.60) 0 Geometric Mean (95% CI) #> 28 pval <0.0001 0 p-value (t-test)"},{"path":"https://insightsengineering.github.io/tern/reference/analyze_vars_in_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze numeric variables in columns — analyze_vars_in_cols","title":"Analyze numeric variables in columns — analyze_vars_in_cols","text":"layout-creating function analyze_vars_in_cols() creates layout element generate column-wise analysis table. function sets analysis methods column labels wrapper rtables::analyze_colvars(). designed principally PK tables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/analyze_vars_in_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analyze numeric variables in columns — analyze_vars_in_cols","text":"","code":"analyze_vars_in_cols( lyt, vars, ..., .stats = c(\"n\", \"mean\", \"sd\", \"se\", \"cv\", \"geom_cv\"), .labels = c(n = \"n\", mean = \"Mean\", sd = \"SD\", se = \"SE\", cv = \"CV (%)\", geom_cv = \"CV % Geometric Mean\"), row_labels = NULL, do_summarize_row_groups = FALSE, split_col_vars = TRUE, imp_rule = NULL, avalcat_var = \"AVALCAT1\", cache = FALSE, .indent_mods = NULL, na_str = default_na_str(), nested = TRUE, .formats = NULL, .aligns = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/analyze_vars_in_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analyze numeric variables in columns — analyze_vars_in_cols","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . ... additional arguments lower level functions. .stats (character) statistics select table. .labels (named character) labels statistics (without indent). row_labels (character) function works columns space, usually .labels character vector applies column space. can change row labels defining parameter named character vector names corresponding split values. defaults NULL contains one string, duplicate row label. do_summarize_row_groups (flag) defaults FALSE applies analysis current label rows. wrapper rtables::summarize_row_groups() can accept labelstr define row labels. behavior supported never need overload row labels. split_col_vars (flag) defaults TRUE puts analysis results onto columns. option allows add multiple instances functions, also nested fashion, without adding splits. split must happen one time single layout. imp_rule (string NULL) imputation rule setting. Defaults NULL imputation rule. Can also \"1/3\" implement 1/3 imputation rule \"1/2\" implement 1/2 imputation rule. order use imputation rule, avalcat_var argument must specified. See imputation_rule() details imputation. avalcat_var (string) imp_rule NULL, name variable indicates whether row data corresponds analysis value category \"BLQ\", \"LTR\", \"% h_pkparam_sort() lyt <- basic_table() %>% split_rows_by(var = \"STRATA1\", label_pos = \"topleft\") %>% split_rows_by( var = \"SEX\", label_pos = \"topleft\", child_labels = \"hidden\" ) %>% # Removes duplicated labels analyze_vars_in_cols(vars = \"AGE\") result <- build_table(lyt = lyt, df = adpp) result #> STRATA1 #> SEX n Mean SD SE CV (%) CV % Geometric Mean #> ———————————————————————————————————————————————————————————————— #> A #> F 81 38.8 5.4 0.6 13.8 14.3 #> M 81 38.9 5.9 0.7 15.1 14.9 #> B #> F 90 36.0 6.4 0.7 17.7 17.9 #> M 81 36.4 6.5 0.7 17.9 17.8 #> C #> F 117 34.1 6.2 0.6 18.2 18.3 #> M 72 33.2 11.5 1.4 34.6 31.6 # By selecting just some statistics and ad-hoc labels lyt <- basic_table() %>% split_rows_by(var = \"ARM\", label_pos = \"topleft\") %>% split_rows_by( var = \"SEX\", label_pos = \"topleft\", child_labels = \"hidden\", split_fun = drop_split_levels ) %>% analyze_vars_in_cols( vars = \"AGE\", .stats = c(\"n\", \"cv\", \"geom_mean\"), .labels = c( n = \"aN\", cv = \"aCV\", geom_mean = \"aGeomMean\" ) ) result <- build_table(lyt = lyt, df = adpp) result #> ARM #> SEX aN aCV aGeomMean #> ——————————————————————————————————————— #> A: Drug X #> B: Placebo #> C: Combination #> F 288 17.6 35.5 #> M 234 23.4 35.3 # Changing row labels lyt <- basic_table() %>% analyze_vars_in_cols( vars = \"AGE\", row_labels = \"some custom label\" ) result <- build_table(lyt, df = adpp) result #> n Mean SD SE CV (%) CV % Geometric Mean #> ————————————————————————————————————————————————————————————————————————— #> some custom label 522 36.1 7.4 0.3 20.4 20.6 # Pharmacokinetic parameters lyt <- basic_table() %>% split_rows_by( var = \"TLG_DISPLAY\", split_label = \"PK Parameter\", label_pos = \"topleft\", child_labels = \"hidden\" ) %>% analyze_vars_in_cols( vars = \"AVAL\" ) result <- build_table(lyt, df = adpp) result #> PK Parameter n Mean SD SE CV (%) CV % Geometric Mean #> ————————————————————————————————————————————————————————————————————— #> Cmax 58 29.7 5.6 0.7 19.0 19.3 #> AUCinf obs 58 207.5 34.9 4.6 16.8 17.3 #> CL obs 58 5.1 1.0 0.1 20.6 22.7 #> Ae 58 1.5 0.3 0.0 21.3 24.1 #> Fe 58 15.7 3.6 0.5 22.7 24.0 #> CLR 58 0.0 0.0 0.0 19.9 22.2 #> Rmax 58 9.6 2.0 0.3 21.1 21.6 #> Tonset 58 3.0 0.7 0.1 22.4 23.3 #> RENALCLD 58 0.0 0.0 0.0 19.0 19.4 # Multiple calls (summarize label and analyze underneath) lyt <- basic_table() %>% split_rows_by( var = \"TLG_DISPLAY\", split_label = \"PK Parameter\", label_pos = \"topleft\" ) %>% analyze_vars_in_cols( vars = \"AVAL\", do_summarize_row_groups = TRUE # does a summarize level ) %>% split_rows_by(\"SEX\", child_labels = \"hidden\", label_pos = \"topleft\" ) %>% analyze_vars_in_cols( vars = \"AVAL\", split_col_vars = FALSE # avoids re-splitting the columns ) result <- build_table(lyt, df = adpp) result #> PK Parameter #> SEX n Mean SD SE CV (%) CV % Geometric Mean #> ————————————————————————————————————————————————————————————————————— #> Cmax 58 29.7 5.6 0.7 19.0 19.3 #> F 32 30.1 6.1 1.1 20.4 21.0 #> M 26 29.2 5.0 1.0 17.2 17.2 #> AUCinf obs 58 207.5 34.9 4.6 16.8 17.3 #> F 32 209.5 43.3 7.7 20.7 21.6 #> M 26 205.0 20.9 4.1 10.2 10.4 #> CL obs 58 5.1 1.0 0.1 20.6 22.7 #> F 32 5.1 1.1 0.2 20.8 23.2 #> M 26 5.1 1.1 0.2 20.7 22.5 #> Ae 58 1.5 0.3 0.0 21.3 24.1 #> F 32 1.5 0.3 0.1 19.3 20.8 #> M 26 1.5 0.4 0.1 23.9 27.9 #> Fe 58 15.7 3.6 0.5 22.7 24.0 #> F 32 16.3 3.4 0.6 20.9 22.3 #> M 26 15.0 3.7 0.7 24.7 25.6 #> CLR 58 0.0 0.0 0.0 19.9 22.2 #> F 32 0.0 0.0 0.0 20.5 24.8 #> M 26 0.0 0.0 0.0 19.5 18.9 #> Rmax 58 9.6 2.0 0.3 21.1 21.6 #> F 32 9.6 2.2 0.4 22.4 23.5 #> M 26 9.6 1.9 0.4 19.7 19.5 #> Tonset 58 3.0 0.7 0.1 22.4 23.3 #> F 32 3.0 0.7 0.1 24.7 25.9 #> M 26 3.0 0.6 0.1 19.8 20.0 #> RENALCLD 58 0.0 0.0 0.0 19.0 19.4 #> F 32 0.0 0.0 0.0 19.6 20.4 #> M 26 0.0 0.0 0.0 18.0 17.6"},{"path":"https://insightsengineering.github.io/tern/reference/append_varlabels.html","id":null,"dir":"Reference","previous_headings":"","what":"Add variable labels to top left corner in table — append_varlabels","title":"Add variable labels to top left corner in table — append_varlabels","text":"Helper layout-creating function append variable labels given variables vector given dataset top left corner. variable label found variable name used instead. Multiple variable labels concatenated slashes.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/append_varlabels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add variable labels to top left corner in table — append_varlabels","text":"","code":"append_varlabels(lyt, df, vars, indent = 0L)"},{"path":"https://insightsengineering.github.io/tern/reference/append_varlabels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add variable labels to top left corner in table — append_varlabels","text":"lyt (PreDataTableLayouts) layout analyses added . df (data.frame) data set containing analysis variables. vars (character) variable names labels looked df. indent (integer(1)) non-negative number nested indent space, default 0L means indent. 1L means two spaces indent, 2L means four spaces indent .","code":""},{"path":"https://insightsengineering.github.io/tern/reference/append_varlabels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add variable labels to top left corner in table — append_varlabels","text":"modified layout new variable label(s) added top-left material.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/append_varlabels.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Add variable labels to top left corner in table — append_varlabels","text":"optimal implementation course, since using data set layout creation. mature rtables implementation also improved necessary anymore.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/append_varlabels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add variable labels to top left corner in table — append_varlabels","text":"","code":"lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% split_rows_by(\"SEX\") %>% append_varlabels(DM, \"SEX\") %>% analyze(\"AGE\", afun = mean) %>% append_varlabels(DM, \"AGE\", indent = 1) build_table(lyt, DM) #> SEX A: Drug X B: Placebo C: Combination #> Age (N=121) (N=106) (N=129) #> ————————————————————————————————————————————————————————————————————————— #> F #> mean 33.7142857142857 33.8392857142857 34.8852459016393 #> M #> mean 36.5490196078431 32.1 34.2794117647059 #> U #> mean NA NA NA #> UNDIFFERENTIATED #> mean NA NA NA lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"SEX\") %>% analyze(\"AGE\", afun = mean) %>% append_varlabels(DM, c(\"SEX\", \"AGE\")) build_table(lyt, DM) #> SEX / Age A: Drug X B: Placebo C: Combination #> ————————————————————————————————————————————————————————————————————————— #> F #> mean 33.7142857142857 33.8392857142857 34.8852459016393 #> M #> mean 36.5490196078431 32.1 34.2794117647059 #> U #> mean NA NA NA #> UNDIFFERENTIATED #> mean NA NA NA"},{"path":"https://insightsengineering.github.io/tern/reference/apply_auto_formatting.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply automatic formatting — apply_auto_formatting","title":"Apply automatic formatting — apply_auto_formatting","text":"Checks listed formats .formats \"auto\", replaces \"auto\" correct implementation format_auto given statistics, data, variable.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/apply_auto_formatting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply automatic formatting — apply_auto_formatting","text":"","code":"apply_auto_formatting(.formats, x_stats, .df_row, .var)"},{"path":"https://insightsengineering.github.io/tern/reference/apply_auto_formatting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply automatic formatting — apply_auto_formatting","text":".formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. x_stats (named list) named list statistics element corresponds element .formats, matching names. .df_row (data.frame) data frame across columns given row split. .var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/argument_convention.html","id":null,"dir":"Reference","previous_headings":"","what":"Standard arguments — argument_convention","title":"Standard arguments — argument_convention","text":"documentation function lists arguments tern used repeatedly express analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/argument_convention.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Standard arguments — argument_convention","text":"... additional arguments lower level functions. .aligns (character NULL) alignment table contents (including labels). NULL, \"center\" applied. See formatters::list_valid_aligns() list currently supported alignments. .all_col_counts (integer) vector value represents global count column. Values taken alt_counts_df specified (see rtables::build_table()). .df_row (data.frame) data frame across columns given row split. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. .labels (named character) labels statistics (without indent). .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .ref_group (data.frame vector) data corresponding reference group. .spl_context (data.frame) gives information ancestor split states passed rtables. .stats (character) statistics select table. .var (string) single variable name passed rtables requested statistics function. add_total_level (flag) adds \"total\" level others includes levels constitute split. custom label can set level via custom_label argument. col_by (factor) defining column groups. conf_level (proportion) confidence level interval. data (data.frame) dataset containing variables summarize. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. df (data.frame) data set containing analysis variables. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. id (string) subject variable name. is_event (flag)TRUE event, FALSE time event censored. label_all (string) label total population analysis. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. lyt (PreDataTableLayouts) layout analyses added . method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed. na.rm (flag) whether NA values removed x prior analysis. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. prune_zero_rows (flag) whether prune zero rows. riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. rsp (logical) vector indicating whether subject responder . show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. tte (numeric) vector time--event duration values. var_labels (character) variable labels. variables (named list string) list additional analysis variables. vars (character) variable names primary analysis variable iterated . var (string) single variable name primary analysis variable. x (numeric) vector numbers want analyze. xlim (numeric(2)) vector containing lower upper limits x-axis, respectively. NULL (default), default scale range used. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/argument_convention.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Standard arguments — argument_convention","text":"Although function just returns NULL two uses, tern users provides documentation arguments commonly consistently used framework. developer adds single reference point import roxygen argument description : @inheritParams argument_convention","code":""},{"path":"https://insightsengineering.github.io/tern/reference/arrange_grobs.html","id":null,"dir":"Reference","previous_headings":"","what":"Arrange multiple grobs — arrange_grobs","title":"Arrange multiple grobs — arrange_grobs","text":"Arrange grobs new grob n * m (rows * cols) layout.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/arrange_grobs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Arrange multiple grobs — arrange_grobs","text":"","code":"arrange_grobs( ..., grobs = list(...), ncol = NULL, nrow = NULL, padding_ht = grid::unit(2, \"line\"), padding_wt = grid::unit(2, \"line\"), vp = NULL, gp = NULL, name = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/arrange_grobs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Arrange multiple grobs — arrange_grobs","text":"... grobs. grobs (list grob) list grobs. ncol (integer(1)) number columns layout. nrow (integer(1)) number rows layout. padding_ht (grid::unit) unit length 1, vertical space grob. padding_wt (grid::unit) unit length 1, horizontal space grob. vp (viewport NULL) viewport() object (NULL). gp (gpar) gpar() object. name (string) character identifier grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/arrange_grobs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Arrange multiple grobs — arrange_grobs","text":"grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/arrange_grobs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Arrange multiple grobs — arrange_grobs","text":"","code":"library(grid) # \\donttest{ num <- lapply(1:9, textGrob) grid::grid.newpage() grid.draw(arrange_grobs(grobs = num, ncol = 2)) #> Warning: `arrange_grobs()` was deprecated in tern 0.9.4. #> ℹ `tern` plotting functions no longer generate `grob` objects. showViewport() g1 <- circleGrob(gp = gpar(col = \"blue\")) g2 <- circleGrob(gp = gpar(col = \"red\")) g3 <- textGrob(\"TEST TEXT\") grid::grid.newpage() grid.draw(arrange_grobs(g1, g2, g3, nrow = 2)) showViewport() grid::grid.newpage() grid.draw(arrange_grobs(g1, g2, g3, ncol = 3)) grid::grid.newpage() grid::pushViewport(grid::viewport(layout = grid::grid.layout(1, 2))) vp1 <- grid::viewport(layout.pos.row = 1, layout.pos.col = 2) grid.draw(arrange_grobs(g1, g2, g3, ncol = 2, vp = vp1)) showViewport() # }"},{"path":"https://insightsengineering.github.io/tern/reference/as.rtable.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert to rtable — as.rtable","title":"Convert to rtable — as.rtable","text":"new generic function convert objects rtable tables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/as.rtable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert to rtable — as.rtable","text":"","code":"as.rtable(x, ...) # S3 method for class 'data.frame' as.rtable(x, format = \"xx.xx\", ...)"},{"path":"https://insightsengineering.github.io/tern/reference/as.rtable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert to rtable — as.rtable","text":"x (data.frame) object converted rtable. ... additional arguments methods. format (string function) format used columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/as.rtable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert to rtable — as.rtable","text":"rtables table object. Note concrete class depend method used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/as.rtable.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Convert to rtable — as.rtable","text":".rtable(data.frame): Method converting data.frame contains numeric columns rtable.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/as.rtable.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert to rtable — as.rtable","text":"","code":"x <- data.frame( a = 1:10, b = rnorm(10) ) as.rtable(x) #> a b #> —————————————————— #> 1 1.00 0.07 #> 2 2.00 -0.64 #> 3 3.00 -0.05 #> 4 4.00 -0.25 #> 5 5.00 0.44 #> 6 6.00 2.76 #> 7 7.00 0.05 #> 8 8.00 0.58 #> 9 9.00 0.12 #> 10 10.00 -1.91"},{"path":"https://insightsengineering.github.io/tern/reference/as_factor_keep_attributes.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion of a vector to a factor — as_factor_keep_attributes","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"Converts x factor keeps attributes. Warns appropriately user can decide whether prefer converting factor manually (e.g. full control factor levels).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/as_factor_keep_attributes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"","code":"as_factor_keep_attributes( x, x_name = deparse(substitute(x)), na_level = \"\", verbose = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/as_factor_keep_attributes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"x (vector) object convert. x_name (string) name x. na_level (string) explicit missing level used converting character vector. verbose (flag) defaults TRUE. prints warnings messages.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/as_factor_keep_attributes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"factor attributes (except class) x. modify x already factor.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/assertions.html","id":null,"dir":"Reference","previous_headings":"","what":"Additional assertions to use with checkmate — assertions","title":"Additional assertions to use with checkmate — assertions","text":"Additional assertion functions can used together checkmate package.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/assertions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Additional assertions to use with checkmate — assertions","text":"","code":"assert_list_of_variables(x, .var.name = checkmate::vname(x), add = NULL) assert_df_with_variables( df, variables, na_level = NULL, .var.name = checkmate::vname(df), add = NULL ) assert_valid_factor( x, min.levels = 1, max.levels = NULL, null.ok = TRUE, any.missing = TRUE, n.levels = NULL, len = NULL, .var.name = checkmate::vname(x), add = NULL ) assert_df_with_factors( df, variables, min.levels = 1, max.levels = NULL, any.missing = TRUE, na_level = NULL, .var.name = checkmate::vname(df), add = NULL ) assert_proportion_value(x, include_boundaries = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/assertions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Additional assertions to use with checkmate — assertions","text":"x () object test. .var.name [character(1)] Name checked object print assertions. Defaults heuristic implemented vname. add [AssertCollection] Collection store assertion messages. See AssertCollection. df (data.frame) data set test. variables (named list character) list variables test. na_level (string) string using represent NA missing data. NA values please consider using directly .na() similar approaches. min.levels [integer(1)] Minimum number factor levels. Default NULL (check). max.levels [integer(1)] Maximum number factor levels. Default NULL (check). null.ok [logical(1)] set TRUE, x may also NULL. case type check x performed, additional checks disabled. .missing [logical(1)] vectors missing values allowed? Default TRUE. n.levels [integer(1)] Exact number factor levels. Default NULL (check). len [integer(1)] Exact expected length x. include_boundaries (flag) whether include boundaries testing proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/assertions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Additional assertions to use with checkmate — assertions","text":"Nothing assertion passes, otherwise prints error message.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/assertions.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Additional assertions to use with checkmate — assertions","text":"assert_list_of_variables(): Checks whether x valid list variable names. NULL elements list x dropped Filter(Negate(.null), x). assert_df_with_variables(): Check whether df data frame analysis variables. Please notice produces error variables present data.frame opposite required. assert_valid_factor(): Check whether x valid factor (.e. levels empty string levels). Note NULL NA elements allowed. assert_df_with_factors(): Check whether df data frame analysis variables factors. Note creation NA direct call factor() trim NA levels vector list . assert_proportion_value(): Check whether x proportion: number 0 1.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/bins_percent_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels for bins in percent — bins_percent_labels","title":"Labels for bins in percent — bins_percent_labels","text":"creates labels quantile based bins percent. assumes right-closed intervals produced cut_quantile_bins().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/bins_percent_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for bins in percent — bins_percent_labels","text":"","code":"bins_percent_labels(probs, digits = 0)"},{"path":"https://insightsengineering.github.io/tern/reference/bins_percent_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for bins in percent — bins_percent_labels","text":"probs (numeric) probabilities identifying quantiles. sorted vector unique proportion values, .e. 0 1, boundaries 0 1 must included. digits (integer(1)) number decimal places round percent numbers.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/bins_percent_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for bins in percent — bins_percent_labels","text":"character vector labels format [0%,20%], (20%,50%], etc.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Content row function to add row total to labels — c_label_n","title":"Content row function to add row total to labels — c_label_n","text":"takes label latest row split level adds row total df parentheses. function differs c_label_n_alt() taking row counts df rather alt_counts_df, used add_rowcounts() alt_counts set FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Content row function to add row total to labels — c_label_n","text":"","code":"c_label_n(df, labelstr, .N_row)"},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Content row function to add row total to labels — c_label_n","text":"df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Content row function to add row total to labels — c_label_n","text":"list formatted rtables::CellValue() row count value correct label.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Content row function to add row total to labels — c_label_n","text":"important use df rather .N_row implementation, former already split columns refer first column data .","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n_alt.html","id":null,"dir":"Reference","previous_headings":"","what":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"takes label latest row split level adds row total alt_counts_df parentheses. function differs c_label_n() taking row counts alt_counts_df rather df, used add_rowcounts() alt_counts set TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n_alt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"","code":"c_label_n_alt(df, labelstr, .alt_df_row)"},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n_alt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/c_label_n_alt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"list formatted rtables::CellValue() row count value correct label.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/cfun_by_flag.html","id":null,"dir":"Reference","previous_headings":"","what":"Constructor for content functions given a data frame with flag input — cfun_by_flag","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"can useful tabulating model results.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cfun_by_flag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"","code":"cfun_by_flag(analysis_var, flag_var, format = \"xx\", .indent_mods = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/cfun_by_flag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"analysis_var (string) variable name column containing values returned content function. flag_var (string) variable name logical column identifying row returned. format (string)rtables format use.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cfun_by_flag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"content function gives df$analysis_var row identified .df_row$flag given format.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/check_diff_prop_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Check proportion difference arguments — check_diff_prop_ci","title":"Check proportion difference arguments — check_diff_prop_ci","text":"Verifies /convert arguments valid values used estimation difference responder proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/check_diff_prop_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check proportion difference arguments — check_diff_prop_ci","text":"","code":"check_diff_prop_ci(rsp, grp, strata = NULL, conf_level, correct = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/check_diff_prop_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check proportion difference arguments — check_diff_prop_ci","text":"rsp (logical) vector indicating whether subject responder . grp (factor) vector assigning observations one two groups (e.g. reference treatment group). strata (factor) variable one level per stratum length rsp. conf_level (proportion) confidence level interval. correct (flag) whether include continuity correction. information, see stats::prop.test().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/check_same_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Check element dimension — check_same_n","title":"Check element dimension — check_same_n","text":"Checks elements ... dimension.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/check_same_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check element dimension — check_same_n","text":"","code":"check_same_n(..., omit_null = TRUE)"},{"path":"https://insightsengineering.github.io/tern/reference/check_same_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check element dimension — check_same_n","text":"... (data.frame vector) data frames vectors. omit_null (flag) whether NULL elements ... omitted check.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/check_same_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check element dimension — check_same_n","text":"logical value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combination_function.html","id":null,"dir":"Reference","previous_headings":"","what":"Class for CombinationFunction — combination_function","title":"Class for CombinationFunction — combination_function","text":"CombinationFunction S4 class extends standard functions. special functions can combined negated logical operators.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combination_function.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Class for CombinationFunction — combination_function","text":"","code":"# S4 method for class 'CombinationFunction,CombinationFunction' e1 & e2 # S4 method for class 'CombinationFunction,CombinationFunction' e1 | e2 # S4 method for class 'CombinationFunction' !x"},{"path":"https://insightsengineering.github.io/tern/reference/combination_function.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Class for CombinationFunction — combination_function","text":"e1 (CombinationFunction) left hand side logical operator. e2 (CombinationFunction) right hand side logical operator. x (CombinationFunction) function negated.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combination_function.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Class for CombinationFunction — combination_function","text":"logical value indicating whether left hand side equation equals right hand side.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combination_function.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Class for CombinationFunction — combination_function","text":"e1 & e2: Logical \"\" combination CombinationFunction functions. resulting object class, evaluates two argument functions. result \"\" two individual results. e1 | e2: Logical \"\" combination CombinationFunction functions. resulting object class, evaluates two argument functions. result \"\" two individual results. `!`(CombinationFunction): Logical negation CombinationFunction functions. resulting object class, evaluates original function. result opposite results.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combination_function.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Class for CombinationFunction — combination_function","text":"","code":"higher <- function(a) { force(a) CombinationFunction( function(x) { x > a } ) } lower <- function(b) { force(b) CombinationFunction( function(x) { x < b } ) } c1 <- higher(5) c2 <- lower(10) c3 <- higher(5) & lower(10) c3(7) #> [1] TRUE"},{"path":"https://insightsengineering.github.io/tern/reference/combine_counts.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine counts — combine_counts","title":"Combine counts — combine_counts","text":"Simplifies estimation column counts, especially group combination required.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_counts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine counts — combine_counts","text":"","code":"combine_counts(fct, groups_list = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/combine_counts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine counts — combine_counts","text":"fct (factor) variable levels needs grouped. groups_list (named list character) specifies new group levels via names levels belong character vectors elements list.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_counts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine counts — combine_counts","text":"vector column counts.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/combine_counts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine counts — combine_counts","text":"","code":"ref <- c(\"A: Drug X\", \"B: Placebo\") groups <- combine_groups(fct = DM$ARM, ref = ref) col_counts <- combine_counts( fct = DM$ARM, groups_list = groups ) basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze_vars(\"AGE\") %>% build_table(DM, col_counts = col_counts) #> A: Drug X/B: Placebo C: Combination #> (N=227) (N=129) #> ————————————————————————————————————————————————— #> n 227 129 #> Mean (SD) 34.0 (7.2) 34.6 (6.5) #> Median 33.0 33.0 #> Min - Max 20.0 - 60.0 22.0 - 53.0 ref <- \"A: Drug X\" groups <- combine_groups(fct = DM$ARM, ref = ref) col_counts <- combine_counts( fct = DM$ARM, groups_list = groups ) basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze_vars(\"AGE\") %>% build_table(DM, col_counts = col_counts) #> A: Drug X B: Placebo/C: Combination #> (N=121) (N=235) #> ——————————————————————————————————————————————————— #> n 121 235 #> Mean (SD) 34.9 (7.8) 33.9 (6.5) #> Median 33.0 33.0 #> Min - Max 20.0 - 60.0 21.0 - 55.0"},{"path":"https://insightsengineering.github.io/tern/reference/combine_groups.html","id":null,"dir":"Reference","previous_headings":"","what":"Reference and treatment group combination — combine_groups","title":"Reference and treatment group combination — combine_groups","text":"Facilitate re-combination groups divided reference treatment groups; helps arranging groups columns rtables framework teal modules.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_groups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reference and treatment group combination — combine_groups","text":"","code":"combine_groups(fct, ref = NULL, collapse = \"/\")"},{"path":"https://insightsengineering.github.io/tern/reference/combine_groups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reference and treatment group combination — combine_groups","text":"fct (factor) variable levels needs grouped. ref (character) reference level(s). collapse (string) character string separate fct ref.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_groups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reference and treatment group combination — combine_groups","text":"list first item ref (reference) second item trt (treatment).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_groups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reference and treatment group combination — combine_groups","text":"","code":"groups <- combine_groups( fct = DM$ARM, ref = c(\"B: Placebo\") ) basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze_vars(\"AGE\") %>% build_table(DM) #> B: Placebo A: Drug X/C: Combination #> (N=106) (N=250) #> —————————————————————————————————————————————————— #> n 106 250 #> Mean (SD) 33.0 (6.3) 34.7 (7.1) #> Median 32.0 33.0 #> Min - Max 21.0 - 55.0 20.0 - 60.0"},{"path":"https://insightsengineering.github.io/tern/reference/combine_levels.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine factor levels — combine_levels","title":"Combine factor levels — combine_levels","text":"Combine specified old factor Levels single new level.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_levels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine factor levels — combine_levels","text":"","code":"combine_levels(x, levels, new_level = paste(levels, collapse = \"/\"))"},{"path":"https://insightsengineering.github.io/tern/reference/combine_levels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine factor levels — combine_levels","text":"x (factor) factor variable. levels (character) level names combined. new_level (string) name new level.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_levels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine factor levels — combine_levels","text":"factor new levels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_levels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine factor levels — combine_levels","text":"","code":"x <- factor(letters[1:5], levels = letters[5:1]) combine_levels(x, levels = c(\"a\", \"b\")) #> [1] a/b a/b c d e #> Levels: e d c a/b combine_levels(x, c(\"e\", \"b\")) #> [1] a e/b c d e/b #> Levels: e/b d c a"},{"path":"https://insightsengineering.github.io/tern/reference/combine_vectors.html","id":null,"dir":"Reference","previous_headings":"","what":"Element-wise combination of two vectors — combine_vectors","title":"Element-wise combination of two vectors — combine_vectors","text":"Element-wise combination two vectors","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_vectors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Element-wise combination of two vectors — combine_vectors","text":"","code":"combine_vectors(x, y)"},{"path":"https://insightsengineering.github.io/tern/reference/combine_vectors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Element-wise combination of two vectors — combine_vectors","text":"x (vector) first vector combine. y (vector) second vector combine.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_vectors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Element-wise combination of two vectors — combine_vectors","text":"list element combines corresponding elements x y.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/combine_vectors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Element-wise combination of two vectors — combine_vectors","text":"","code":"combine_vectors(1:3, 4:6) #> [[1]] #> [1] 1 4 #> #> [[2]] #> [1] 2 5 #> #> [[3]] #> [1] 3 6 #>"},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Compare variables between groups — compare_variables","title":"Compare variables between groups — compare_variables","text":"analyze function compare_vars() creates layout element summarize compare one variables, using S3 generic function s_summary() calculate list summary statistics. list available statistics numeric variables can viewed running get_stats(\"analyze_vars_numeric\", add_pval = TRUE) non-numeric variables running get_stats(\"analyze_vars_counts\", add_pval = TRUE). Use .stats parameter specify statistics include output summary table. Prior using function table layout must use rtables::split_cols_by() create column split variable used comparisons, specify reference group via ref_group parameter. Comparisons can performed group (column) specified reference group including p-value statistic.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compare variables between groups — compare_variables","text":"","code":"compare_vars( lyt, vars, var_labels = vars, na_str = default_na_str(), nested = TRUE, ..., na.rm = TRUE, show_labels = \"default\", table_names = vars, section_div = NA_character_, .stats = c(\"n\", \"mean_sd\", \"count_fraction\", \"pval\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_compare(x, .ref_group, .in_ref_col, ...) # S3 method for class 'numeric' s_compare(x, .ref_group, .in_ref_col, ...) # S3 method for class 'factor' s_compare(x, .ref_group, .in_ref_col, denom = \"n\", na.rm = TRUE, ...) # S3 method for class 'character' s_compare( x, .ref_group, .in_ref_col, denom = \"n\", na.rm = TRUE, .var, verbose = TRUE, ... ) # S3 method for class 'logical' s_compare(x, .ref_group, .in_ref_col, na.rm = TRUE, denom = \"n\", ...)"},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compare variables between groups — compare_variables","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... arguments passed s_compare(). na.rm (flag) whether NA values removed x prior analysis. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. .stats (character) statistics select table. Options numeric variables : 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d', 'pval' Options non-numeric variables : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq', 'pval_counts' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. x (numeric) vector numbers want analyze. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. denom (string) choice denominator factor proportions, can n (number values row column intersection). .var (string) single variable name passed rtables requested statistics function. verbose (flag) whether warnings messages printed. Mainly used print information factor casting. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compare variables between groups — compare_variables","text":"compare_vars() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_compare() table layout. s_compare() returns output s_summary() comparisons versus reference group form p-values.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Compare variables between groups — compare_variables","text":"compare_vars(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_compare(): S3 generic function produce comparison summary. s_compare(numeric): Method numeric class. uses standard t-test calculate p-value. s_compare(factor): Method factor class. uses chi-squared test calculate p-value. s_compare(character): Method character class. makes automatic conversion factor (warning) forwards method factors. s_compare(logical): Method logical class. chi-squared test used. missing values removed, counted FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Compare variables between groups — compare_variables","text":"factor variables, denom factor proportions can n since purpose compare proportions columns, therefore row-based proportion make sense. Proportion based N_col difficult since use counts chi-squared test statistic, therefore missing values accounted explicit factor levels. factor variables contain NA, NA values excluded default. include NA values set na.rm = FALSE missing values displayed NA level. Alternatively, explicit factor level can defined NA values pre-processing via df_explicit_na() - default na_level (\"\") also excluded na.rm set TRUE. character variables, automatic conversion factor guarantee table generated correctly. particular sparse tables likely can fail. Therefore always better manually convert character variables factors pre-processing. compare_vars(), column split must define reference group via ref_group comparison well defined.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/compare_variables.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compare variables between groups — compare_variables","text":"","code":"# `compare_vars()` in `rtables` pipelines ## Default output within a `rtables` pipeline. lyt <- basic_table() %>% split_cols_by(\"ARMCD\", ref_group = \"ARM B\") %>% compare_vars(c(\"AGE\", \"SEX\")) build_table(lyt, tern_ex_adsl) #> ARM A ARM B ARM C #> ——————————————————————————————————————————————————————————————————— #> AGE #> n 69 73 58 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) #> p-value (t-test) 0.1446 0.8212 #> SEX #> n 69 73 58 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) #> M 31 (44.9%) 33 (45.2%) 26 (44.8%) #> p-value (chi-squared test) 1.0000 1.0000 ## Select and format statistics output. lyt <- basic_table() %>% split_cols_by(\"ARMCD\", ref_group = \"ARM C\") %>% compare_vars( vars = \"AGE\", .stats = c(\"mean_sd\", \"pval\"), .formats = c(mean_sd = \"xx.x, xx.x\"), .labels = c(mean_sd = \"Mean, SD\") ) build_table(lyt, df = tern_ex_adsl) #> ARM A ARM B ARM C #> ———————————————————————————————————————————————————— #> Mean, SD 34.1, 6.8 35.8, 7.1 36.1, 7.4 #> p-value (t-test) 0.1176 0.8212 # `s_compare.numeric` ## Usual case where both this and the reference group vector have more than 1 value. s_compare(rnorm(10, 5, 1), .ref_group = rnorm(5, -5, 1), .in_ref_col = FALSE) #> $n #> n #> 10 #> #> $sum #> sum #> 51.27191 #> #> $mean #> mean #> 5.127191 #> #> $sd #> sd #> 1.226119 #> #> $se #> se #> 0.387733 #> #> $mean_sd #> mean sd #> 5.127191 1.226119 #> #> $mean_se #> mean se #> 5.127191 0.387733 #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> 4.250078 6.004304 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> 4.739458 5.514924 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 3.901071 6.353310 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 5.127191 4.250078 6.004304 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> 3.353908e-07 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 5.024369 #> #> $mad #> mad #> -4.440892e-16 #> #> $median_ci #> median_ci_lwr median_ci_upr #> 4.638779 5.862086 #> attr(,\"conf_level\") #> [1] 0.9785156 #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 5.024369 4.638779 5.862086 #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 4.756763 5.549828 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 0.7930643 #> #> $range #> min max #> 2.725885 7.682557 #> #> $min #> min #> 2.725885 #> #> $max #> max #> 7.682557 #> #> $median_range #> median min max #> 5.024369 2.725885 7.682557 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> 23.91406 #> #> $geom_mean #> geom_mean #> 4.985435 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 4.144463 5.997052 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> 26.26258 #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 4.985435 4.144463 5.997052 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> $pval #> [1] 2.25779e-08 #> ## If one group has not more than 1 value, then p-value is not calculated. s_compare(rnorm(10, 5, 1), .ref_group = 1, .in_ref_col = FALSE) #> $n #> n #> 10 #> #> $sum #> sum #> 50.71578 #> #> $mean #> mean #> 5.071578 #> #> $sd #> sd #> 1.105832 #> #> $se #> se #> 0.3496948 #> #> $mean_sd #> mean sd #> 5.071578 1.105832 #> #> $mean_se #> mean se #> 5.0715780 0.3496948 #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> 4.280513 5.862643 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> 4.721883 5.421273 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 3.965746 6.177410 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 5.071578 4.280513 5.862643 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> 1.511204e-07 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 5.260423 #> #> $mad #> mad #> 0 #> #> $median_ci #> median_ci_lwr median_ci_upr #> 3.529264 6.318293 #> attr(,\"conf_level\") #> [1] 0.9785156 #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 5.260423 3.529264 6.318293 #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 4.024149 6.065057 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 2.040908 #> #> $range #> min max #> 3.300549 6.337320 #> #> $min #> min #> 3.300549 #> #> $max #> max #> 6.33732 #> #> $median_range #> median min max #> 5.260423 3.300549 6.337320 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> 21.8045 #> #> $geom_mean #> geom_mean #> 4.952266 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 4.181833 5.864639 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> 23.97201 #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 4.952266 4.181833 5.864639 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> $pval #> character(0) #> ## Empty numeric does not fail, it returns NA-filled items and no p-value. s_compare(numeric(), .ref_group = numeric(), .in_ref_col = FALSE) #> $n #> n #> 0 #> #> $sum #> sum #> NA #> #> $mean #> mean #> NA #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> NA NA #> #> $mean_se #> mean se #> NA NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> NA #> #> $mad #> mad #> NA #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> NA #> #> $range #> min max #> NA NA #> #> $min #> min #> NA #> #> $max #> max #> NA #> #> $median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> NaN #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> $pval #> character(0) #> # `s_compare.factor` ## Basic usage: x <- factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")) y <- factor(c(\"a\", \"b\", \"c\")) s_compare(x = x, .ref_group = y, .in_ref_col = FALSE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> ## Management of NA values. x <- explicit_na(factor(c(\"a\", \"a\", \"b\", \"c\", \"a\", NA, NA))) y <- explicit_na(factor(c(\"a\", \"b\", \"c\", NA))) s_compare(x = x, .ref_group = y, .in_ref_col = FALSE, na.rm = TRUE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> s_compare(x = x, .ref_group = y, .in_ref_col = FALSE, na.rm = FALSE) #> $n #> [1] 7 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> $count$`` #> [1] 2 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0000000 0.4285714 #> #> $count_fraction$b #> [1] 1.0000000 0.1428571 #> #> $count_fraction$c #> [1] 1.0000000 0.1428571 #> #> $count_fraction$`` #> [1] 2.0000000 0.2857143 #> #> #> $fraction #> $fraction$a #> num denom #> 3 7 #> #> $fraction$b #> num denom #> 1 7 #> #> $fraction$c #> num denom #> 1 7 #> #> $fraction$`` #> num denom #> 2 7 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.9063036 #> # `s_compare.character` ## Basic usage: x <- c(\"a\", \"a\", \"b\", \"c\", \"a\") y <- c(\"a\", \"b\", \"c\") s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = \"x\", verbose = FALSE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> ## Note that missing values handling can make a large difference: x <- c(\"a\", \"a\", \"b\", \"c\", \"a\", NA) y <- c(\"a\", \"b\", \"c\", rep(NA, 20)) s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = \"x\", verbose = FALSE ) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = \"x\", na.rm = FALSE, verbose = FALSE ) #> $n #> [1] 6 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> $count$`` #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.5 #> #> $count_fraction$b #> [1] 1.0000000 0.1666667 #> #> $count_fraction$c #> [1] 1.0000000 0.1666667 #> #> $count_fraction$`` #> [1] 1.0000000 0.1666667 #> #> #> $fraction #> $fraction$a #> num denom #> 3 6 #> #> $fraction$b #> num denom #> 1 6 #> #> $fraction$c #> num denom #> 1 6 #> #> $fraction$`` #> num denom #> 1 6 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.005768471 #> # `s_compare.logical` ## Basic usage: x <- c(TRUE, FALSE, TRUE, TRUE) y <- c(FALSE, FALSE, TRUE) s_compare(x, .ref_group = y, .in_ref_col = FALSE) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.00 0.75 #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.2702894 #> ## Management of NA values. x <- c(NA, TRUE, FALSE) y <- c(NA, NA, NA, NA, FALSE) s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = TRUE) #> $n #> [1] 2 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0 0.5 #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.3864762 #> s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = FALSE) #> $n #> [1] 3 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0000000 0.3333333 #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.1675463 #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_analyze_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for descriptive statistics — control_analyze_vars","title":"Control function for descriptive statistics — control_analyze_vars","text":"Sets list parameters summaries descriptive statistics. Typically used internally specify details s_summary(). function family mainly used analyze_vars().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_analyze_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for descriptive statistics — control_analyze_vars","text":"","code":"control_analyze_vars( conf_level = 0.95, quantiles = c(0.25, 0.75), quantile_type = 2, test_mean = 0 )"},{"path":"https://insightsengineering.github.io/tern/reference/control_analyze_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for descriptive statistics — control_analyze_vars","text":"conf_level (proportion) confidence level interval. quantiles (numeric(2)) vector length two specify quantiles calculate. quantile_type (numeric(1)) number 1 9 selecting quantile algorithms used. Default set 2 matches default quantile algorithm SAS proc univariate set QNTLDEF=5. differs R's default. See type stats::quantile(). test_mean (numeric(1)) number test mean null hypothesis calculating p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_analyze_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for descriptive statistics — control_analyze_vars","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_annot.html","id":null,"dir":"Reference","previous_headings":"","what":"Control functions for Kaplan-Meier plot annotation tables — control_annot","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"Auxiliary functions controlling arguments formatting annotation tables can added plots generated via g_km().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_annot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"","code":"control_surv_med_annot(x = 0.8, y = 0.85, w = 0.32, h = 0.16, fill = TRUE) control_coxph_annot( x = 0.29, y = 0.51, w = 0.4, h = 0.125, fill = TRUE, ref_lbls = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/control_annot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"x (proportion) x-coordinate center annotation table. y (proportion) y-coordinate center annotation table. w (proportion) relative width annotation table. h (proportion) relative height annotation table. fill (flag character) whether annotation table background fill color. Can also color code use background fill color. TRUE, color code defaults \"#00000020\". ref_lbls (flag) whether reference group explicitly printed labels annotation table. FALSE (default), comparison groups printed table labels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_annot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_annot.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"control_surv_med_annot(): Control function formatting median survival time annotation table. annotation table can added g_km() setting annot_surv_med=TRUE, can configured using control_surv_med_annot() function setting control_annot_surv_med argument. control_coxph_annot(): Control function formatting Cox-PH annotation table. annotation table can added g_km() setting annot_coxph=TRUE, can configured using control_coxph_annot() function setting control_annot_coxph argument.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/control_annot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"","code":"control_surv_med_annot() #> $x #> [1] 0.8 #> #> $y #> [1] 0.85 #> #> $w #> [1] 0.32 #> #> $h #> [1] 0.16 #> #> $fill #> [1] TRUE #> control_coxph_annot() #> $x #> [1] 0.29 #> #> $y #> [1] 0.51 #> #> $w #> [1] 0.4 #> #> $h #> [1] 0.125 #> #> $fill #> [1] TRUE #> #> $ref_lbls #> [1] FALSE #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_coxph.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for Cox-PH model — control_coxph","title":"Control function for Cox-PH model — control_coxph","text":"auxiliary function controlling arguments Cox-PH model, typically used internally specify details Cox-PH model s_coxph_pairwise(). conf_level refers Hazard Ratio estimation.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_coxph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for Cox-PH model — control_coxph","text":"","code":"control_coxph( pval_method = c(\"log-rank\", \"wald\", \"likelihood\"), ties = c(\"efron\", \"breslow\", \"exact\"), conf_level = 0.95 )"},{"path":"https://insightsengineering.github.io/tern/reference/control_coxph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for Cox-PH model — control_coxph","text":"pval_method (string) p-value method testing hazard ratio = 1. Default method \"log-rank\", can also set \"wald\" \"likelihood\". ties (string) string specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_coxph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for Cox-PH model — control_coxph","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_coxreg.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for Cox regression — control_coxreg","title":"Control function for Cox regression — control_coxreg","text":"Sets list parameters Cox regression fit. Used internally.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_coxreg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for Cox regression — control_coxreg","text":"","code":"control_coxreg( pval_method = c(\"wald\", \"likelihood\"), ties = c(\"exact\", \"efron\", \"breslow\"), conf_level = 0.95, interaction = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/control_coxreg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for Cox regression — control_coxreg","text":"pval_method (string) method used estimation p.values; wald (default) likelihood. ties (string) among exact (equivalent DISCRETE SAS), efron breslow, see survival::coxph(). Note: equivalent SAS EXACT method R. conf_level (proportion) confidence level interval. interaction (flag) TRUE, model includes interaction studied treatment candidate covariate. Note univariate models without treatment arm, multivariate models, interaction can used needs FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_coxreg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for Cox regression — control_coxreg","text":"list items names corresponding arguments.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/control_coxreg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for Cox regression — control_coxreg","text":"","code":"control_coxreg() #> $pval_method #> [1] \"wald\" #> #> $ties #> [1] \"exact\" #> #> $conf_level #> [1] 0.95 #> #> $interaction #> [1] FALSE #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_incidence_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for incidence rate — control_incidence_rate","title":"Control function for incidence rate — control_incidence_rate","text":"auxiliary function controlling arguments incidence rate, used internally specify details s_incidence_rate().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_incidence_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for incidence rate — control_incidence_rate","text":"","code":"control_incidence_rate( conf_level = 0.95, conf_type = c(\"normal\", \"normal_log\", \"exact\", \"byar\"), input_time_unit = c(\"year\", \"day\", \"week\", \"month\"), num_pt_year = 100 )"},{"path":"https://insightsengineering.github.io/tern/reference/control_incidence_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for incidence rate — control_incidence_rate","text":"conf_level (proportion) confidence level interval. conf_type (string)normal (default), normal_log, exact, byar confidence interval type. input_time_unit (string)day, week, month, year (default) indicating time unit data input. num_pt_year (numeric(1)) number patient-years use calculating adverse event rates.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_incidence_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for incidence rate — control_incidence_rate","text":"list components names arguments.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/control_incidence_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for incidence rate — control_incidence_rate","text":"","code":"control_incidence_rate(0.9, \"exact\", \"month\", 100) #> $conf_level #> [1] 0.9 #> #> $conf_type #> [1] \"exact\" #> #> $input_time_unit #> [1] \"month\" #> #> $num_pt_year #> [1] 100 #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_lineplot_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for g_lineplot() — control_lineplot_vars","title":"Control function for g_lineplot() — control_lineplot_vars","text":"Default values variables parameter g_lineplot function. variable's default value can overwritten variable.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_lineplot_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for g_lineplot() — control_lineplot_vars","text":"","code":"control_lineplot_vars( x = \"AVISIT\", y = \"AVAL\", group_var = \"ARM\", facet_var = NA, paramcd = \"PARAMCD\", y_unit = \"AVALU\", subject_var = \"USUBJID\" )"},{"path":"https://insightsengineering.github.io/tern/reference/control_lineplot_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for g_lineplot() — control_lineplot_vars","text":"x (string) x-variable name. y (string) y-variable name. group_var (string NA) group variable name. facet_var (string NA) faceting variable name. paramcd (string NA) parameter code variable name. y_unit (string NA) y-axis unit variable name. subject_var (string NA) subject variable name.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_lineplot_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for g_lineplot() — control_lineplot_vars","text":"named character vector variable names.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_lineplot_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for g_lineplot() — control_lineplot_vars","text":"","code":"control_lineplot_vars() #> x y group_var paramcd y_unit subject_var #> \"AVISIT\" \"AVAL\" \"ARM\" \"PARAMCD\" \"AVALU\" \"USUBJID\" #> facet_var #> NA control_lineplot_vars(group_var = NA) #> x y group_var paramcd y_unit subject_var #> \"AVISIT\" \"AVAL\" NA \"PARAMCD\" \"AVALU\" \"USUBJID\" #> facet_var #> NA"},{"path":"https://insightsengineering.github.io/tern/reference/control_logistic.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for logistic regression model fitting — control_logistic","title":"Control function for logistic regression model fitting — control_logistic","text":"auxiliary function controlling arguments logistic regression models. conf_level refers confidence level used Odds Ratio CIs.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_logistic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for logistic regression model fitting — control_logistic","text":"","code":"control_logistic(response_definition = \"response\", conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/reference/control_logistic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for logistic regression model fitting — control_logistic","text":"response_definition (string) definition event terms response. used fitting logistic regression model left hand side formula. Note evaluated expression result either logical vector factor 2 levels. default just \"response\" original response variable used modified . conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_logistic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for logistic regression model fitting — control_logistic","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_logistic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for logistic regression model fitting — control_logistic","text":"","code":"# Standard options. control_logistic() #> $response_definition #> [1] \"response\" #> #> $conf_level #> [1] 0.95 #> # Modify confidence level. control_logistic(conf_level = 0.9) #> $response_definition #> [1] \"response\" #> #> $conf_level #> [1] 0.9 #> # Use a different response definition. control_logistic(response_definition = \"I(response %in% c('CR', 'PR'))\") #> $response_definition #> [1] \"I(response %in% c('CR', 'PR'))\" #> #> $conf_level #> [1] 0.95 #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_riskdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for risk difference column — control_riskdiff","title":"Control function for risk difference column — control_riskdiff","text":"Sets list parameters use generating risk (proportion) difference column. Used input riskdiff parameter tabulate_rsp_subgroups() tabulate_survival_subgroups().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_riskdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for risk difference column — control_riskdiff","text":"","code":"control_riskdiff( arm_x = NULL, arm_y = NULL, format = \"xx.x (xx.x - xx.x)\", col_label = \"Risk Difference (%) (95% CI)\", pct = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/control_riskdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for risk difference column — control_riskdiff","text":"arm_x (string) name reference arm use risk difference calculations. arm_y (character) names one arms compare reference arm risk difference calculations. new column added value arm_y. format (string function) format label (string) formatting function apply risk difference statistic. See 3d string options formatters::list_valid_format_labels() possible format strings. Defaults \"xx.x (xx.x - xx.x)\". col_label (character) labels use rendering risk difference column within table. one comparison arm specified arm_y, default labels specify two arms compared (reference arm vs. comparison arm). pct (flag) whether output returned percentages. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_riskdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for risk difference column — control_riskdiff","text":"list items names corresponding arguments.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/control_riskdiff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for risk difference column — control_riskdiff","text":"","code":"control_riskdiff() #> $arm_x #> NULL #> #> $arm_y #> NULL #> #> $format #> [1] \"xx.x (xx.x - xx.x)\" #> #> $col_label #> [1] \"Risk Difference (%) (95% CI)\" #> #> $pct #> [1] TRUE #> control_riskdiff(arm_x = \"ARM A\", arm_y = \"ARM B\") #> $arm_x #> [1] \"ARM A\" #> #> $arm_y #> [1] \"ARM B\" #> #> $format #> [1] \"xx.x (xx.x - xx.x)\" #> #> $col_label #> [1] \"Risk Difference (%) (95% CI)\" #> #> $pct #> [1] TRUE #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"auxiliary function controlling arguments STEP calculations.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"","code":"control_step( biomarker = NULL, use_percentile = TRUE, bandwidth, degree = 0L, num_points = 39L )"},{"path":"https://insightsengineering.github.io/tern/reference/control_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"biomarker (numeric NULL) optional provision numeric biomarker variable, used infer bandwidth, see . use_percentile (flag) TRUE, running windows created according quantiles rather actual values, .e. bandwidth refers percentage data covered window. Suggest TRUE biomarker variable uniformly distributed. bandwidth (numeric(1) NULL) indicating bandwidth window. Depending argument use_percentile, can either length actual-value windows real biomarker scale, percentage windows. use_percentile = TRUE, number 0 1. NULL, treat bandwidth infinity, means one global model fitted. default, 0.25 used percentage windows one quarter range biomarker variable actual-value windows. degree (integer(1)) degree polynomial function biomarker interaction term treatment arm fitted window. 0 (default), biomarker variable included model fitted biomarker window. num_points (integer(1)) number points hazard ratios estimated. smallest number 2.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"list components names arguments, except biomarker just used calculate bandwidth case actual biomarker windows requested.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"","code":"# Provide biomarker values and request actual values to be used, # so that bandwidth is chosen from range. control_step(biomarker = 1:10, use_percentile = FALSE) #> $use_percentile #> [1] FALSE #> #> $bandwidth #> [1] 2.25 #> #> $degree #> [1] 0 #> #> $num_points #> [1] 39 #> # Use a global model with quadratic biomarker interaction term. control_step(bandwidth = NULL, degree = 2) #> $use_percentile #> [1] TRUE #> #> $bandwidth #> NULL #> #> $degree #> [1] 2 #> #> $num_points #> [1] 39 #> # Reduce number of points to be used. control_step(num_points = 10) #> $use_percentile #> [1] TRUE #> #> $bandwidth #> [1] 0.25 #> #> $degree #> [1] 0 #> #> $num_points #> [1] 10 #>"},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for survfit models for survival time — control_surv_time","title":"Control function for survfit models for survival time — control_surv_time","text":"auxiliary function controlling arguments survfit model, typically used internally specify details survfit model s_surv_time(). conf_level refers survival time estimation.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for survfit models for survival time — control_surv_time","text":"","code":"control_surv_time( conf_level = 0.95, conf_type = c(\"plain\", \"log\", \"log-log\"), quantiles = c(0.25, 0.75) )"},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for survfit models for survival time — control_surv_time","text":"conf_level (proportion) confidence level interval. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" longer supported. quantiles (numeric(2)) vector length two specifying quantiles survival time.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for survfit models for survival time — control_surv_time","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_timepoint.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"auxiliary function controlling arguments survfit model, typically used internally specify details survfit model s_surv_timepoint(). conf_level refers patient risk estimation time point.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_timepoint.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"","code":"control_surv_timepoint( conf_level = 0.95, conf_type = c(\"plain\", \"log\", \"log-log\") )"},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_timepoint.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"conf_level (proportion) confidence level interval. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" longer supported.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/control_surv_timepoint.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_cumulative.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative counts of numeric variable by thresholds — count_cumulative","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"analyze function count_cumulative() creates layout element calculate cumulative counts values numeric variable less , less equal , greater , greater equal user-specified threshold values. function analyzes numeric variable vars threshold values supplied thresholds argument numeric vector. Whether counts include threshold values, whether count values lower higher threshold values can set via include_eq lower_tail parameters, respectively.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_cumulative.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"","code":"count_cumulative( lyt, vars, thresholds, lower_tail = TRUE, include_eq = TRUE, var_labels = vars, show_labels = \"visible\", na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_cumulative( x, thresholds, lower_tail = TRUE, include_eq = TRUE, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\"), ... ) a_count_cumulative( x, thresholds, lower_tail = TRUE, include_eq = TRUE, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\"), ... )"},{"path":"https://insightsengineering.github.io/tern/reference/count_cumulative.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . thresholds (numeric) vector cutoff values counts. lower_tail (flag) whether count lower tail, default TRUE. include_eq (flag) whether include value equal threshold count, default TRUE. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_cumulative.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"count_cumulative() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_cumulative() table layout. s_count_cumulative() returns named list count_fractions: list thresholds value component, component containing vector count fraction. a_count_cumulative() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_cumulative.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"count_cumulative(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_cumulative(): Statistics function produces named list given numeric vector thresholds. a_count_cumulative(): Formatted analysis function used afun count_cumulative().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/count_cumulative.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"","code":"basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_cumulative( vars = \"AGE\", thresholds = c(40, 60) ) %>% build_table(tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————— #> AGE #> <= 40 52 (75.4%) 58 (79.5%) 41 (70.7%) #> <= 60 69 (100%) 73 (100%) 58 (100%)"},{"path":"https://insightsengineering.github.io/tern/reference/count_missed_doses.html","id":null,"dir":"Reference","previous_headings":"","what":"Count number of patients with missed doses by thresholds — count_missed_doses","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"analyze function creates layout element calculate cumulative counts patients number missed doses least equal user-specified threshold values. function analyzes numeric variable vars, variable numbers missed doses, threshold values supplied thresholds argument numeric vector. function assumes every row given data frame corresponds unique patient.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_missed_doses.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"","code":"count_missed_doses( lyt, vars, thresholds, var_labels = vars, show_labels = \"visible\", na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_nonmissing(x) s_count_missed_doses( x, thresholds, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\") ) a_count_missed_doses( x, thresholds, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\") )"},{"path":"https://insightsengineering.github.io/tern/reference/count_missed_doses.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . thresholds (numeric) minimum number missed doses patients . var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_missed_doses.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"count_missed_doses() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_missed_doses() table layout. s_count_nonmissing() returns statistic n count non-missing values x. s_count_missed_doses() returns statistics n count_fraction one element threshold. a_count_missed_doses() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_missed_doses.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"count_missed_doses(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_nonmissing(): Statistics function count non-missing values. s_count_missed_doses(): Statistics function count patients missed doses. a_count_missed_doses(): Formatted analysis function used afun count_missed_doses().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/count_missed_doses.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"","code":"library(dplyr) anl <- tern_ex_adsl %>% distinct(STUDYID, USUBJID, ARM) %>% mutate( PARAMCD = \"TNDOSMIS\", PARAM = \"Total number of missed doses during study\", AVAL = sample(0:20, size = nrow(tern_ex_adsl), replace = TRUE), AVALC = \"\" ) basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_missed_doses(\"AVAL\", thresholds = c(1, 5, 10, 15), var_labels = \"Missed Doses\") %>% build_table(anl, alt_counts_df = tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————— #> Missed Doses #> n 69 73 58 #> At least 1 missed dose 69 (100%) 69 (94.5%) 55 (94.8%) #> At least 5 missed doses 57 (82.6%) 55 (75.3%) 50 (86.2%) #> At least 10 missed doses 40 (58%) 40 (54.8%) 32 (55.2%) #> At least 15 missed doses 26 (37.7%) 25 (34.2%) 13 (22.4%)"},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":null,"dir":"Reference","previous_headings":"","what":"Count occurrences — count_occurrences","title":"Count occurrences — count_occurrences","text":"analyze function count_occurrences() creates layout element calculate occurrence counts patients. function analyzes variable(s) supplied vars returns table occurrence counts unique value (level) variable(s). variable (variables) must non-numeric. id variable used indicate unique subject identifiers (defaults USUBJID). multiple occurrences value recorded patient, value counted . summarize function summarize_occurrences() performs function count_occurrences() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count occurrences — count_occurrences","text":"","code":"count_occurrences( lyt, vars, id = \"USUBJID\", drop = TRUE, var_labels = vars, show_labels = \"hidden\", riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = \"count_fraction_fixed_dp\", .formats = NULL, .labels = NULL, .indent_mods = NULL ) summarize_occurrences( lyt, var, id = \"USUBJID\", drop = TRUE, riskdiff = FALSE, na_str = default_na_str(), ..., .stats = \"count_fraction_fixed_dp\", .formats = NULL, .indent_mods = NULL, .labels = NULL ) s_count_occurrences( df, denom = c(\"N_col\", \"n\", \"N_row\"), .N_col, .N_row, .df_row, drop = TRUE, .var = \"MHDECOD\", id = \"USUBJID\" ) a_count_occurrences( df, labelstr = \"\", id = \"USUBJID\", denom = c(\"N_col\", \"n\", \"N_row\"), drop = TRUE, .N_col, .N_row, .var = NULL, .df_row = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count occurrences — count_occurrences","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . id (string) subject variable name. drop (flag) whether non-appearing occurrence levels dropped resulting table. Note case remaining occurrence levels table sorted alphabetically. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. denom (string) choice denominator proportion. Options : N_col: total number patients column across rows. n: number patients occurrences. N_row: total number patients row across columns. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .df_row (data.frame) data frame across columns given row split. .var, var (string) single variable name passed rtables requested statistics function. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count occurrences — count_occurrences","text":"count_occurrences() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_occurrences() table layout. summarize_occurrences() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows containing statistics s_count_occurrences() table layout. s_count_occurrences() returns list : count: list counts one element per occurrence. count_fraction: list counts fractions one element per occurrence. fraction: list numerators denominators one element per occurrence. a_count_occurrences() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count occurrences — count_occurrences","text":"count_occurrences(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). summarize_occurrences(): Layout-creating function can take content function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_count_occurrences(): Statistics function counts number patients report occurrence. a_count_occurrences(): Formatted analysis function used afun count_occurrences().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count occurrences — count_occurrences","text":"default, occurrences appear given row split dropped table occurrences table sorted alphabetically per row split. Therefore, corresponding layout needs use split_fun = drop_split_levels split_rows_by calls. Use drop = FALSE like show occurrences.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count occurrences — count_occurrences","text":"","code":"library(dplyr) df <- data.frame( USUBJID = as.character(c( 1, 1, 2, 4, 4, 4, 6, 6, 6, 7, 7, 8 )), MHDECOD = c( \"MH1\", \"MH2\", \"MH1\", \"MH1\", \"MH1\", \"MH3\", \"MH2\", \"MH2\", \"MH3\", \"MH1\", \"MH2\", \"MH4\" ), ARM = rep(c(\"A\", \"B\"), each = 6), SEX = c(\"F\", \"F\", \"M\", \"M\", \"M\", \"M\", \"F\", \"F\", \"F\", \"M\", \"M\", \"F\") ) df_adsl <- df %>% select(USUBJID, ARM) %>% unique() # Create table layout lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_occurrences(vars = \"MHDECOD\", .stats = c(\"count_fraction\")) # Apply table layout to data and produce `rtable` object tbl <- lyt %>% build_table(df, alt_counts_df = df_adsl) %>% prune_table() tbl #> A B #> (N=3) (N=3) #> ——————————————————————————— #> MH1 3 (100%) 1 (33.3%) #> MH2 1 (33.3%) 2 (66.7%) #> MH3 1 (33.3%) 1 (33.3%) #> MH4 0 1 (33.3%) # Layout creating function with custom format. basic_table() %>% add_colcounts() %>% split_rows_by(\"SEX\", child_labels = \"visible\") %>% summarize_occurrences( var = \"MHDECOD\", .formats = c(\"count_fraction\" = \"xx.xx (xx.xx%)\") ) %>% build_table(df, alt_counts_df = df_adsl) #> all obs #> (N=6) #> ————————————————— #> F #> MH1 1 (16.7%) #> MH2 2 (33.3%) #> MH3 1 (16.7%) #> MH4 1 (16.7%) #> M #> MH1 3 (50.0%) #> MH2 1 (16.7%) #> MH3 1 (16.7%) # Count unique occurrences per subject. s_count_occurrences( df, .N_col = 4L, .N_row = 4L, .df_row = df, .var = \"MHDECOD\", id = \"USUBJID\" ) #> $count #> $count$MH1 #> [1] 4 #> #> $count$MH2 #> [1] 3 #> #> $count$MH3 #> [1] 2 #> #> $count$MH4 #> [1] 1 #> #> #> $count_fraction #> $count_fraction$MH1 #> [1] 4 1 #> #> $count_fraction$MH2 #> [1] 3.00 0.75 #> #> $count_fraction$MH3 #> [1] 2.0 0.5 #> #> $count_fraction$MH4 #> [1] 1.00 0.25 #> #> #> $fraction #> $fraction$MH1 #> num denom #> 4 4 #> #> $fraction$MH2 #> num denom #> 3 4 #> #> $fraction$MH3 #> num denom #> 2 4 #> #> $fraction$MH4 #> num denom #> 1 4 #> #> a_count_occurrences( df, .N_col = 4L, .df_row = df, .var = \"MHDECOD\", id = \"USUBJID\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 MH1 4 0 MH1 #> 2 MH2 3 0 MH2 #> 3 MH3 2 0 MH3 #> 4 MH4 1 0 MH4 #> 5 MH1 4 (100%) 0 MH1 #> 6 MH2 3 (75%) 0 MH2 #> 7 MH3 2 (50%) 0 MH3 #> 8 MH4 1 (25%) 0 MH4 #> 9 MH1 4 (100%) 0 MH1 #> 10 MH2 3 (75.0%) 0 MH2 #> 11 MH3 2 (50.0%) 0 MH3 #> 12 MH4 1 (25.0%) 0 MH4 #> 13 MH1 4/4 (100.0%) 0 MH1 #> 14 MH2 3/4 (75.0%) 0 MH2 #> 15 MH3 2/4 (50.0%) 0 MH3 #> 16 MH4 1/4 (25.0%) 0 MH4"},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences_by_grade.html","id":null,"dir":"Reference","previous_headings":"","what":"Count occurrences by grade — count_occurrences_by_grade","title":"Count occurrences by grade — count_occurrences_by_grade","text":"analyze function count_occurrences_by_grade() creates layout element calculate occurrence counts grade. function analyzes primary analysis variable var indicates toxicity grades. id variable used indicate unique subject identifiers (defaults USUBJID). user can also supply list custom groups grades analyze via grade_groups parameter. remove_single argument remove single grades analysis grade groups analyzed. multiple grades recorded one patient highest grade level counted. summarize function summarize_occurrences_by_grade() performs function count_occurrences_by_grade() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences_by_grade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count occurrences by grade — count_occurrences_by_grade","text":"","code":"count_occurrences_by_grade( lyt, var, id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, var_labels = var, show_labels = \"default\", riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = var, .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .indent_mods = NULL, .labels = NULL ) summarize_occurrences_by_grade( lyt, var, id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, riskdiff = FALSE, na_str = default_na_str(), ..., .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .indent_mods = NULL, .labels = NULL ) s_count_occurrences_by_grade( df, .var, .N_row, .N_col, id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, denom = c(\"N_col\", \"n\", \"N_row\"), labelstr = \"\" ) a_count_occurrences_by_grade( df, labelstr = \"\", id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, denom = c(\"N_col\", \"n\", \"N_row\"), .N_col, .N_row, .df_row, .var = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences_by_grade.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count occurrences by grade — count_occurrences_by_grade","text":"lyt (PreDataTableLayouts) layout analyses added . id (string) subject variable name. grade_groups (named list character) list containing groupings grades. remove_single (flag)TRUE include elements one-element grade groups output list; case grade groups names included output. only_grade_groups set TRUE argument ignored. only_grade_groups (flag) whether specified grade groups included, individual grade rows removed (TRUE), grades grade groups displayed (FALSE). var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. .labels (named character) labels statistics (without indent). df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. denom (string) choice denominator proportion. Options : N_col: total number patients column across rows. n: number patients occurrences. N_row: total number patients row across columns. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences_by_grade.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count occurrences by grade — count_occurrences_by_grade","text":"count_occurrences_by_grade() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_occurrences_by_grade() table layout. summarize_occurrences_by_grade() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows containing statistics s_count_occurrences_by_grade() table layout. s_count_occurrences_by_grade() returns list counts fractions one element per grade level grade level grouping. a_count_occurrences_by_grade() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences_by_grade.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count occurrences by grade — count_occurrences_by_grade","text":"count_occurrences_by_grade(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). summarize_occurrences_by_grade(): Layout-creating function can take content function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_count_occurrences_by_grade(): Statistics function counts number patients highest grade. a_count_occurrences_by_grade(): Formatted analysis function used afun count_occurrences_by_grade().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/count_occurrences_by_grade.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count occurrences by grade — count_occurrences_by_grade","text":"","code":"library(dplyr) df <- data.frame( USUBJID = as.character(c(1:6, 1)), ARM = factor(c(\"A\", \"A\", \"A\", \"B\", \"B\", \"B\", \"A\"), levels = c(\"A\", \"B\")), AETOXGR = factor(c(1, 2, 3, 4, 1, 2, 3), levels = c(1:5)), AESEV = factor( x = c(\"MILD\", \"MODERATE\", \"SEVERE\", \"MILD\", \"MILD\", \"MODERATE\", \"SEVERE\"), levels = c(\"MILD\", \"MODERATE\", \"SEVERE\") ), stringsAsFactors = FALSE ) df_adsl <- df %>% select(USUBJID, ARM) %>% unique() # Layout creating function with custom format. basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_occurrences_by_grade( var = \"AESEV\", .formats = c(\"count_fraction\" = \"xx.xx (xx.xx%)\") ) %>% build_table(df, alt_counts_df = df_adsl) #> A B #> (N=3) (N=3) #> ———————————————————————————————————————— #> MILD 0.00 (0.00%) 2.00 (66.67%) #> MODERATE 1.00 (33.33%) 1.00 (33.33%) #> SEVERE 2.00 (66.67%) 0.00 (0.00%) # Define additional grade groupings. grade_groups <- list( \"-Any-\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"), \"Grade 1-2\" = c(\"1\", \"2\"), \"Grade 3-5\" = c(\"3\", \"4\", \"5\") ) basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_occurrences_by_grade( var = \"AETOXGR\", grade_groups = grade_groups, only_grade_groups = TRUE ) %>% build_table(df, alt_counts_df = df_adsl) #> A B #> (N=3) (N=3) #> ————————————————————————————————— #> -Any- 3 (100%) 3 (100%) #> Grade 1-2 1 (33.3%) 2 (66.7%) #> Grade 3-5 2 (66.7%) 1 (33.3%) # Layout creating function with custom format. basic_table() %>% add_colcounts() %>% split_rows_by(\"ARM\", child_labels = \"visible\", nested = TRUE) %>% summarize_occurrences_by_grade( var = \"AESEV\", .formats = c(\"count_fraction\" = \"xx.xx (xx.xx%)\") ) %>% build_table(df, alt_counts_df = df_adsl) #> all obs #> (N=6) #> —————————————————————————— #> A #> MILD 0.00 (0.00%) #> MODERATE 1.00 (16.67%) #> SEVERE 2.00 (33.33%) #> B #> MILD 2.00 (33.33%) #> MODERATE 1.00 (16.67%) #> SEVERE 0.00 (0.00%) basic_table() %>% add_colcounts() %>% split_rows_by(\"ARM\", child_labels = \"visible\", nested = TRUE) %>% summarize_occurrences_by_grade( var = \"AETOXGR\", grade_groups = grade_groups ) %>% build_table(df, alt_counts_df = df_adsl) #> all obs #> (N=6) #> ——————————————————————— #> A #> -Any- 3 (50.0%) #> Grade 1-2 1 (16.7%) #> 1 0 #> 2 1 (16.7%) #> Grade 3-5 2 (33.3%) #> 3 2 (33.3%) #> 4 0 #> 5 0 #> B #> -Any- 3 (50.0%) #> Grade 1-2 2 (33.3%) #> 1 1 (16.7%) #> 2 1 (16.7%) #> Grade 3-5 1 (16.7%) #> 3 0 #> 4 1 (16.7%) #> 5 0 s_count_occurrences_by_grade( df, .N_col = 10L, .var = \"AETOXGR\", id = \"USUBJID\", grade_groups = list(\"ANY\" = levels(df$AETOXGR)) ) #> $count_fraction #> $count_fraction$ANY #> [1] 6.0 0.6 #> #> $count_fraction$`1` #> [1] 1.0 0.1 #> #> $count_fraction$`2` #> [1] 2.0 0.2 #> #> $count_fraction$`3` #> [1] 2.0 0.2 #> #> $count_fraction$`4` #> [1] 1.0 0.1 #> #> $count_fraction$`5` #> [1] 0 0 #> #> a_count_occurrences_by_grade( df, .N_col = 10L, .N_row = 10L, .var = \"AETOXGR\", id = \"USUBJID\", grade_groups = list(\"ANY\" = levels(df$AETOXGR)) ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 ANY 6 (60%) 0 ANY #> 2 1 1 (10%) 0 1 #> 3 2 2 (20%) 0 2 #> 4 3 2 (20%) 0 3 #> 5 4 1 (10%) 0 4 #> 6 5 0 0 5 #> 7 ANY 6 (60.0%) 0 ANY #> 8 1 1 (10.0%) 0 1 #> 9 2 2 (20.0%) 0 2 #> 10 3 2 (20.0%) 0 3 #> 11 4 1 (10.0%) 0 4 #> 12 5 0 0 5"},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_events_in_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patient events in columns — count_patients_events_in_cols","title":"Count patient events in columns — count_patients_events_in_cols","text":"summarize function summarize_patients_events_in_cols() creates layout element summarize patient event counts columns. function analyzes elements (events) supplied via filters_list parameter returns row counts number patients event well total numbers patients events. id variable used indicate unique subject identifiers (defaults USUBJID). multiple occurrences event recorded patient, event counted .","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_events_in_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patient events in columns — count_patients_events_in_cols","text":"","code":"summarize_patients_events_in_cols( lyt, id = \"USUBJID\", filters_list = list(), empty_stats = character(), na_str = default_na_str(), ..., .stats = c(\"unique\", \"all\", names(filters_list)), .labels = c(unique = \"Patients (All)\", all = \"Events (All)\", labels_or_names(filters_list)), col_split = TRUE ) s_count_patients_and_multiple_events( df, id, filters_list, empty_stats = character(), labelstr = \"\", custom_label = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_events_in_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patient events in columns — count_patients_events_in_cols","text":"lyt (PreDataTableLayouts) layout analyses added . id (string) subject variable name. filters_list (named list character) list element list describes one type event describe filters, format s_count_patients_with_event(). label, used column title. empty_stats (character) optional names statistics returned empty corresponding table cells stay blank. na_str (string) string used replace NA empty values output. ... additional arguments lower level functions. .stats (character) statistics select table. addition statistics added using filters_list, statistic options : 'unique', '' .labels (named character) labels statistics (without indent). col_split (flag) whether columns split. Set FALSE required column split done already earlier layout pipe. df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. custom_label (string NULL) provided labelstr empty used label.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_events_in_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patient events in columns — count_patients_events_in_cols","text":"summarize_patients_events_in_cols() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows containing statistics s_count_patients_and_multiple_events() table layout. s_count_patients_and_multiple_events() returns list statistics: unique: number unique patients df. : number rows df. one element name filters_list: number rows df, .e. events, fulfilling filter condition.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_events_in_cols.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patient events in columns — count_patients_events_in_cols","text":"summarize_patients_events_in_cols(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_count_patients_and_multiple_events(): Statistics function counts numbers patients multiple events defined filters. Used analysis function afun summarize_patients_events_in_cols().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_events_in_cols.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patient events in columns — count_patients_events_in_cols","text":"","code":"df <- data.frame( USUBJID = rep(c(\"id1\", \"id2\", \"id3\", \"id4\"), c(2, 3, 1, 1)), ARM = c(\"A\", \"A\", \"B\", \"B\", \"B\", \"B\", \"A\"), AESER = rep(\"Y\", 7), AESDTH = c(\"Y\", \"Y\", \"N\", \"Y\", \"Y\", \"N\", \"N\"), AEREL = c(\"Y\", \"Y\", \"N\", \"Y\", \"Y\", \"N\", \"Y\"), AEDECOD = c(\"A\", \"A\", \"A\", \"B\", \"B\", \"C\", \"D\"), AEBODSYS = rep(c(\"SOC1\", \"SOC2\", \"SOC3\"), c(3, 3, 1)) ) # `summarize_patients_events_in_cols()` basic_table() %>% summarize_patients_events_in_cols( filters_list = list( related = formatters::with_label(c(AEREL = \"Y\"), \"Events (Related)\"), fatal = c(AESDTH = \"Y\"), fatal_related = c(AEREL = \"Y\", AESDTH = \"Y\") ), custom_label = \"%s Total number of patients and events\" ) %>% build_table(df) #> Patients (All) Events (All) Events (Related) fatal fatal_related #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> %s Total number of patients and events 4 7 5 4 4"},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_event.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the number of patients with a particular event — count_patients_with_event","title":"Count the number of patients with a particular event — count_patients_with_event","text":"analyze function count_patients_with_event() creates layout element calculate patient counts user-specified set events. function analyzes primary analysis variable vars indicates unique subject identifiers. Events defined user named vector via filters argument, name corresponds variable value value(s) variable takes event. multiple records event recorded patient, one occurrence counted.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_event.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the number of patients with a particular event — count_patients_with_event","text":"","code":"count_patients_with_event( lyt, vars, filters, riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .labels = NULL, .indent_mods = NULL ) s_count_patients_with_event( df, .var, filters, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") ) a_count_patients_with_event( df, labelstr = \"\", filters, denom = c(\"n\", \"N_col\", \"N_row\"), .N_col, .N_row, .df_row, .var = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_event.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the number of patients with a particular event — count_patients_with_event","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . filters (character) character vector specifying column names flag variables used counting number unique identifiers satisfying conditions. Multiple column names flags accepted format c(\"column_name1\" = \"flag1\", \"column_name2\" = \"flag2\"). Note equality accepted condition. riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) name column contains unique identifier. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_event.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count the number of patients with a particular event — count_patients_with_event","text":"count_patients_with_event() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_patients_with_event() table layout. s_count_patients_with_event() returns count fraction unique identifiers defined event. a_count_patients_with_event() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_event.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count the number of patients with a particular event — count_patients_with_event","text":"count_patients_with_event(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_patients_with_event(): Statistics function counts number patients defined event occurred. a_count_patients_with_event(): Formatted analysis function used afun count_patients_with_event().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_event.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the number of patients with a particular event — count_patients_with_event","text":"","code":"lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_values( \"STUDYID\", values = \"AB12345\", .stats = \"count\", .labels = c(count = \"Total AEs\") ) %>% count_patients_with_event( \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\"), .labels = c(count_fraction = \"Total number of patients with at least one adverse event\"), table_names = \"tbl_all\" ) %>% count_patients_with_event( \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\"), .labels = c(count_fraction = \"Total number of patients with fatal AEs\"), table_names = \"tbl_fatal\" ) %>% count_patients_with_event( \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\", \"AEREL\" = \"Y\"), .labels = c(count_fraction = \"Total number of patients with related fatal AEs\"), .indent_mods = c(count_fraction = 2L), table_names = \"tbl_rel_fatal\" ) build_table(lyt, tern_ex_adae, alt_counts_df = tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————————————————————————— #> Total AEs 202 177 162 #> Total number of patients with at least one adverse event 59 (100%) 57 (100%) 48 (100%) #> Total number of patients with fatal AEs 28 (47.5%) 31 (54.4%) 20 (41.7%) #> Total number of patients with related fatal AEs 28 (47.5%) 31 (54.4%) 20 (41.7%) s_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\") ) #> $n #> [1] 164 #> #> $count #> [1] 164 #> #> $count_fraction #> [1] 164 1 #> #> $n_blq #> [1] 0 #> s_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\") ) #> $n #> [1] 164 #> #> $count #> [1] 79 #> #> $count_fraction #> [1] 79.0000000 0.4817073 #> #> $n_blq #> [1] 0 #> s_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\"), denom = \"N_col\", .N_col = 456 ) #> $n #> [1] 164 #> #> $count #> [1] 79 #> #> $count_fraction #> [1] 79.0000000 0.1732456 #> #> $n_blq #> [1] 0 #> a_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\"), .N_col = 100, .N_row = 100 ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 164 0 n #> 2 count 164 0 count #> 3 count_fraction 164 (100%) 0 count_fraction #> 4 count_fraction_fixed_dp 164 (100%) 0 count_fraction #> 5 n_blq 0 0 n_blq"},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the number of patients with particular flags — count_patients_with_flags","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"analyze function count_patients_with_flags() creates layout element calculate counts patients user-specified flags present. function analyzes primary analysis variable var indicates unique subject identifiers. Flags variables analyze specified user via flag_variables argument, must either take value TRUE (flag present) FALSE (flag absent) record. multiple records flag present patient, one occurrence counted.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"","code":"count_patients_with_flags( lyt, var, flag_variables, flag_labels = NULL, var_labels = var, show_labels = \"hidden\", riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = paste0(\"tbl_flags_\", var), .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .indent_mods = NULL, .labels = NULL ) s_count_patients_with_flags( df, .var, flag_variables, flag_labels = NULL, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") ) a_count_patients_with_flags( df, labelstr = \"\", flag_variables, flag_labels = NULL, denom = c(\"n\", \"N_col\", \"N_row\"), .N_col, .N_row, .df_row, .var = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. flag_variables (character) vector specifying names logical variables analysis dataset used counting number unique identifiers. flag_labels (character) vector labels use flag variables. labels also specified via .labels parameter, .labels values take precedence replace labels. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. .labels (named character) labels statistics (without indent). df (data.frame) data set containing analysis variables. .var (string) name column contains unique identifier. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"count_patients_with_flags() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_patients_with_flags() table layout. s_count_patients_with_flags() returns count fraction unique identifiers particular flag list statistics n, count, count_fraction, n_blq, one element per flag. a_count_patients_with_flags() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"count_patients_with_flags(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_patients_with_flags(): Statistics function counts number patients particular flag variable TRUE. a_count_patients_with_flags(): Formatted analysis function used afun count_patients_with_flags().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"flag_labels specified, variables labels extracted df. variables labeled, variable names used instead. Alternatively, named vector can supplied flag_variables within name-value pair name corresponds variable name value label use variable.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/count_patients_with_flags.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"","code":"# Add labelled flag variables to analysis dataset. adae <- tern_ex_adae %>% dplyr::mutate( fl1 = TRUE %>% with_label(\"Total AEs\"), fl2 = (TRTEMFL == \"Y\") %>% with_label(\"Total number of patients with at least one adverse event\"), fl3 = (TRTEMFL == \"Y\" & AEOUT == \"FATAL\") %>% with_label(\"Total number of patients with fatal AEs\"), fl4 = (TRTEMFL == \"Y\" & AEOUT == \"FATAL\" & AEREL == \"Y\") %>% with_label(\"Total number of patients with related fatal AEs\") ) lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_patients_with_flags( \"SUBJID\", flag_variables = c(\"fl1\", \"fl2\", \"fl3\", \"fl4\"), denom = \"N_col\" ) build_table(lyt, adae, alt_counts_df = tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————————————————————————— #> Total AEs 59 (85.5%) 57 (78.1%) 48 (82.8%) #> Total number of patients with at least one adverse event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> Total number of patients with fatal AEs 28 (40.6%) 31 (42.5%) 20 (34.5%) #> Total number of patients with related fatal AEs 28 (40.6%) 31 (42.5%) 20 (34.5%) # `s_count_patients_with_flags()` s_count_patients_with_flags( adae, \"SUBJID\", flag_variables = c(\"fl1\", \"fl2\", \"fl3\", \"fl4\"), denom = \"N_col\", .N_col = 1000 ) #> $n #> $n$`Total AEs` #> [1] 164 #> #> $n$`Total number of patients with at least one adverse event` #> [1] 164 #> #> $n$`Total number of patients with fatal AEs` #> [1] 164 #> #> $n$`Total number of patients with related fatal AEs` #> [1] 164 #> #> #> $count #> $count$`Total AEs` #> [1] 164 #> #> $count$`Total number of patients with at least one adverse event` #> [1] 164 #> #> $count$`Total number of patients with fatal AEs` #> [1] 79 #> #> $count$`Total number of patients with related fatal AEs` #> [1] 79 #> #> #> $count_fraction #> $count_fraction$`Total AEs` #> [1] 164.000 0.164 #> #> $count_fraction$`Total number of patients with at least one adverse event` #> [1] 164.000 0.164 #> #> $count_fraction$`Total number of patients with fatal AEs` #> [1] 79.000 0.079 #> #> $count_fraction$`Total number of patients with related fatal AEs` #> [1] 79.000 0.079 #> #> #> $n_blq #> $n_blq$`Total AEs` #> [1] 0 #> #> $n_blq$`Total number of patients with at least one adverse event` #> [1] 0 #> #> $n_blq$`Total number of patients with fatal AEs` #> [1] 0 #> #> $n_blq$`Total number of patients with related fatal AEs` #> [1] 0 #> #> a_count_patients_with_flags( adae, .N_col = 10L, .N_row = 10L, .var = \"USUBJID\", flag_variables = c(\"fl1\", \"fl2\", \"fl3\", \"fl4\") ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 n.fl1 164 0 #> 2 n.fl2 164 0 #> 3 n.fl3 164 0 #> 4 n.fl4 164 0 #> 5 count.fl1 164 0 #> 6 count.fl2 164 0 #> 7 count.fl3 79 0 #> 8 count.fl4 79 0 #> 9 count_fraction.fl1 164 (100%) 0 #> 10 count_fraction.fl2 164 (100%) 0 #> 11 count_fraction.fl3 79 (48.2%) 0 #> 12 count_fraction.fl4 79 (48.2%) 0 #> 13 count_fraction_fixed_dp.fl1 164 (100%) 0 #> 14 count_fraction_fixed_dp.fl2 164 (100%) 0 #> 15 count_fraction_fixed_dp.fl3 79 (48.2%) 0 #> 16 count_fraction_fixed_dp.fl4 79 (48.2%) 0 #> 17 n_blq.fl1 0 0 #> 18 n_blq.fl2 0 0 #> 19 n_blq.fl3 0 0 #> 20 n_blq.fl4 0 0 #> row_label #> 1 Total AEs #> 2 Total number of patients with at least one adverse event #> 3 Total number of patients with fatal AEs #> 4 Total number of patients with related fatal AEs #> 5 Total AEs #> 6 Total number of patients with at least one adverse event #> 7 Total number of patients with fatal AEs #> 8 Total number of patients with related fatal AEs #> 9 Total AEs #> 10 Total number of patients with at least one adverse event #> 11 Total number of patients with fatal AEs #> 12 Total number of patients with related fatal AEs #> 13 Total AEs #> 14 Total number of patients with at least one adverse event #> 15 Total number of patients with fatal AEs #> 16 Total number of patients with related fatal AEs #> 17 Total AEs #> 18 Total number of patients with at least one adverse event #> 19 Total number of patients with fatal AEs #> 20 Total number of patients with related fatal AEs"},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":null,"dir":"Reference","previous_headings":"","what":"Count specific values — count_values","title":"Count specific values — count_values","text":"analyze function count_values() creates layout element calculate counts specific values within variable interest. function analyzes one variables interest supplied vector vars. Values count variable(s) vars can given vector via values argument. One row counts generated variable.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count specific values — count_values","text":"","code":"count_values( lyt, vars, values, na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = \"count_fraction\", .formats = NULL, .labels = c(count_fraction = paste(values, collapse = \", \")), .indent_mods = NULL ) s_count_values( x, values, na.rm = TRUE, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") ) # S3 method for class 'character' s_count_values(x, values = \"Y\", na.rm = TRUE, ...) # S3 method for class 'factor' s_count_values(x, values = \"Y\", ...) # S3 method for class 'logical' s_count_values(x, values = TRUE, ...) a_count_values( x, values, na.rm = TRUE, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") )"},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count specific values — count_values","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . values (character) specific values counted. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. na.rm (flag) whether NA values removed x prior analysis. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count specific values — count_values","text":"count_values() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_values() table layout. s_count_values() returns output s_summary() specified values non-numeric variable. a_count_values() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count specific values — count_values","text":"count_values(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_values(): S3 generic function count values. s_count_values(character): Method character class. s_count_values(factor): Method factor class. makes automatic conversion character forwards method characters. s_count_values(logical): Method logical class. a_count_values(): Formatted analysis function used afun count_values().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count specific values — count_values","text":"factor variables, s_count_values checks whether values included levels x fails otherwise. count_values(), variable labels shown one element vars, otherwise hidden.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/count_values.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count specific values — count_values","text":"","code":"# `count_values` basic_table() %>% count_values(\"Species\", values = \"setosa\") %>% build_table(iris) #> all obs #> ———————————————————— #> setosa 50 (33.33%) # `s_count_values.character` s_count_values(x = c(\"a\", \"b\", \"a\"), values = \"a\") #> $n #> [1] 3 #> #> $count #> [1] 2 #> #> $count_fraction #> [1] 2.0000000 0.6666667 #> #> $n_blq #> [1] 0 #> s_count_values(x = c(\"a\", \"b\", \"a\", NA, NA), values = \"b\", na.rm = FALSE) #> $n #> [1] 5 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0 0.2 #> #> $n_blq #> [1] 0 #> # `s_count_values.factor` s_count_values(x = factor(c(\"a\", \"b\", \"a\")), values = \"a\") #> $n #> [1] 3 #> #> $count #> [1] 2 #> #> $count_fraction #> [1] 2.0000000 0.6666667 #> #> $n_blq #> [1] 0 #> # `s_count_values.logical` s_count_values(x = c(TRUE, FALSE, TRUE)) #> $n #> [1] 3 #> #> $count #> [1] 2 #> #> $count_fraction #> [1] 2.0000000 0.6666667 #> #> $n_blq #> [1] 0 #> # `a_count_values` a_count_values(x = factor(c(\"a\", \"b\", \"a\")), values = \"a\", .N_col = 10, .N_row = 10) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 3 0 n #> 2 count 2 0 count #> 3 count_fraction 2 (66.67%) 0 count_fraction #> 4 n_blq 0 0 n_blq"},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":null,"dir":"Reference","previous_headings":"","what":"Cox proportional hazards regression — cox_regression","title":"Cox proportional hazards regression — cox_regression","text":"Fits Cox regression model estimates hazard ratio describe effect size survival analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cox proportional hazards regression — cox_regression","text":"","code":"summarize_coxreg( lyt, variables, control = control_coxreg(), at = list(), multivar = FALSE, common_var = \"STUDYID\", .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\"), .formats = c(n = \"xx\", hr = \"xx.xx\", ci = \"(xx.xx, xx.xx)\", pval = \"x.xxxx | (<0.0001)\", pval_inter = \"x.xxxx | (<0.0001)\"), varlabels = NULL, .indent_mods = NULL, na_str = \"\", .section_div = NA_character_ ) s_coxreg(model_df, .stats, .which_vars = \"all\", .var_nms = NULL) a_coxreg( df, labelstr, eff = FALSE, var_main = FALSE, multivar = FALSE, variables, at = list(), control = control_coxreg(), .spl_context, .stats, .formats, .indent_mods = NULL, na_str = \"\", cache_env = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cox proportional hazards regression — cox_regression","text":"lyt (PreDataTableLayouts) layout analyses added . variables (named list string) list additional analysis variables. control (list) list parameters returned helper function control_coxreg(). (list numeric) candidate covariate numeric, use specify value covariate effect estimated. multivar (flag) whether multivariate Cox regression run (defaults FALSE), otherwise univariate Cox regression run. common_var (string) name factor variable dataset takes value rows. created pre-processing variable currently exists. .stats (character) names statistics reported among: n: number observations (univariate ) hr: hazard ratio ci: confidence interval pval: p-value treatment effect pval_inter: p-value interaction effect treatment covariate (univariate ) .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. varlabels (list) named list corresponds names variables found data, passed named list corresponding time, event, arm, strata, covariates terms. arm missing variables, Cox model(s) including covariates fitted corresponding effect estimates tabulated later. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. na_str (string) custom string replace NA values . Defaults \"\". .section_div (string NA) string repeated section divider sections. Defaults NA section divider. vector two strings given, first used treatment covariate sections second different covariates. model_df (data.frame) contains resulting model fit fit_coxreg function tidying applied via broom::tidy(). .which_vars (character) rows statistics returned given model. Defaults \"\". options include \"var_main\" main effects, \"inter\" interaction effects, \"multi_lvl\" multivariate model covariate level rows. .which_vars \"\", specific variables can selected specifying .var_nms. .var_nms (character) term value rows df .stats returned. Typically name variable. using variable labels, var vector desired variable name variable label order see .stats related variable. .which_vars \"var_main\", .var_nms variable name. df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. eff (flag) whether treatment effect calculated. Defaults FALSE. var_main (flag) whether main effects calculated. Defaults FALSE. .spl_context (data.frame) gives information ancestor split states passed rtables. cache_env (environment) environment object used cache regression model order avoid repeatedly fitting model every row table. Defaults NULL (caching).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cox proportional hazards regression — cox_regression","text":"summarize_coxreg() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add Cox regression table containing chosen statistics table layout. s_coxreg() returns selected statistic Cox regression model selected variable(s). a_coxreg() returns formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cox proportional hazards regression — cox_regression","text":"Cox models commonly used methods estimate magnitude effect survival analysis. assumes proportional hazards: ratio hazards groups (e.g., two arms) constant time. ratio referred \"hazard ratio\" (HR) one commonly reported metrics describe effect size survival analysis (NEST Team, 2020).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cox proportional hazards regression — cox_regression","text":"summarize_coxreg(): Layout-creating function creates Cox regression summary table layout. function wrapper several rtables layouting functions. function wrapper rtables::analyze_colvars() rtables::summarize_row_groups(). s_coxreg(): Statistics function transforms results tabulated fit_coxreg_univar() fit_coxreg_multivar() list. a_coxreg(): Analysis function used afun rtables::analyze() cfun rtables::summarize_row_groups() within summarize_coxreg().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cox proportional hazards regression — cox_regression","text":"","code":"library(survival) # Testing dataset [survival::bladder]. set.seed(1, kind = \"Mersenne-Twister\") dta_bladder <- with( data = bladder[bladder$enum < 5, ], tibble::tibble( TIME = stop, STATUS = event, ARM = as.factor(rx), COVAR1 = as.factor(enum) %>% formatters::with_label(\"A Covariate Label\"), COVAR2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) %>% formatters::with_label(\"Sex (F/M)\") ) ) dta_bladder$AGE <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) dta_bladder$STUDYID <- factor(\"X\") u1_variables <- list( time = \"TIME\", event = \"STATUS\", arm = \"ARM\", covariates = c(\"COVAR1\", \"COVAR2\") ) u2_variables <- list(time = \"TIME\", event = \"STATUS\", covariates = c(\"COVAR1\", \"COVAR2\")) m1_variables <- list( time = \"TIME\", event = \"STATUS\", arm = \"ARM\", covariates = c(\"COVAR1\", \"COVAR2\") ) m2_variables <- list(time = \"TIME\", event = \"STATUS\", covariates = c(\"COVAR1\", \"COVAR2\")) # summarize_coxreg result_univar <- basic_table() %>% summarize_coxreg(variables = u1_variables) %>% build_table(dta_bladder) result_univar #> n Hazard Ratio 95% CI p-value #> ————————————————————————————————————————————————————————————————— #> Treatment: #> 2 vs control (1) 340 0.64 (0.43, 0.94) 0.0242 #> Covariate: #> A Covariate Label 340 0.61 (0.41, 0.90) 0.0126 #> Sex (F/M) 340 0.62 (0.42, 0.92) 0.0182 result_univar_covs <- basic_table() %>% summarize_coxreg( variables = u2_variables, ) %>% build_table(dta_bladder) result_univar_covs #> Hazard Ratio 95% CI p-value #> ——————————————————————————————————————————————————————————————————————————— #> Covariate: #> A Covariate Label (reference = 1) <0.0001 #> 2 0.45 (0.28, 0.71) 0.0007 #> 3 0.31 (0.19, 0.52) <0.0001 #> 4 0.18 (0.10, 0.33) <0.0001 #> Sex (F/M) (reference = F) #> M 1.33 (0.91, 1.94) 0.1414 result_multivar <- basic_table() %>% summarize_coxreg( variables = m1_variables, multivar = TRUE, ) %>% build_table(dta_bladder) result_multivar #> Hazard Ratio 95% CI p-value #> ——————————————————————————————————————————————————————————————————————————— #> Treatment: #> ARM (reference = 1) #> 2 0.61 (0.41, 0.90) 0.0123 #> Covariate: #> A Covariate Label (reference = 1) <0.0001 #> 2 0.46 (0.28, 0.73) 0.0011 #> 3 0.31 (0.18, 0.51) <0.0001 #> 4 0.18 (0.10, 0.33) <0.0001 #> Sex (F/M) (reference = F) #> M 1.29 (0.88, 1.89) 0.1911 result_multivar_covs <- basic_table() %>% summarize_coxreg( variables = m2_variables, multivar = TRUE, varlabels = c(\"Covariate 1\", \"Covariate 2\") # custom labels ) %>% build_table(dta_bladder) result_multivar_covs #> Hazard Ratio 95% CI p-value #> ————————————————————————————————————————————————————————————————————— #> Covariate: #> Covariate 1 (reference = 1) <0.0001 #> 2 0.46 (0.29, 0.74) 0.0012 #> 3 0.31 (0.19, 0.52) <0.0001 #> 4 0.19 (0.10, 0.34) <0.0001 #> Covariate 2 (reference = F) #> M 1.29 (0.88, 1.88) 0.1958 # s_coxreg # Univariate univar_model <- fit_coxreg_univar(variables = u1_variables, data = dta_bladder) df1 <- broom::tidy(univar_model) s_coxreg(model_df = df1, .stats = \"hr\") #> $hr #> $hr$`2 vs control (1)` #> [1] 0.6386426 #> #> #> $hr #> $hr$`A Covariate Label` #> [1] 0.607037 #> #> #> $hr #> $hr$`Sex (F/M)` #> [1] 0.6242738 #> #> # Univariate with interactions univar_model_inter <- fit_coxreg_univar( variables = u1_variables, control = control_coxreg(interaction = TRUE), data = dta_bladder ) df1_inter <- broom::tidy(univar_model_inter) s_coxreg(model_df = df1_inter, .stats = \"hr\", .which_vars = \"inter\", .var_nms = \"COVAR1\") #> $hr #> $hr$` 1` #> [1] 0.6284569 #> #> $hr$` 2` #> [1] 0.5806499 #> #> $hr$` 3` #> [1] 0.5486103 #> #> $hr$` 4` #> [1] 0.6910725 #> #> # Univariate without treatment arm - only \"COVAR2\" covariate effects univar_covs_model <- fit_coxreg_univar(variables = u2_variables, data = dta_bladder) df1_covs <- broom::tidy(univar_covs_model) s_coxreg(model_df = df1_covs, .stats = \"hr\", .var_nms = c(\"COVAR2\", \"Sex (F/M)\")) #> $hr #> $hr$`Sex (F/M) (reference = F)` #> numeric(0) #> #> #> $hr #> $hr$M #> [1] 1.3271 #> #> # Multivariate. multivar_model <- fit_coxreg_multivar(variables = m1_variables, data = dta_bladder) df2 <- broom::tidy(multivar_model) s_coxreg(model_df = df2, .stats = \"pval\", .which_vars = \"var_main\", .var_nms = \"COVAR1\") #> $pval #> $pval$`A Covariate Label (reference = 1)` #> [1] 7.209956e-09 #> #> s_coxreg( model_df = df2, .stats = \"pval\", .which_vars = \"multi_lvl\", .var_nms = c(\"COVAR1\", \"A Covariate Label\") ) #> $pval #> $pval$`2` #> [1] 0.001120332 #> #> $pval$`3` #> [1] 6.293725e-06 #> #> $pval$`4` #> [1] 3.013875e-08 #> #> # Multivariate without treatment arm - only \"COVAR1\" main effect multivar_covs_model <- fit_coxreg_multivar(variables = m2_variables, data = dta_bladder) df2_covs <- broom::tidy(multivar_covs_model) s_coxreg(model_df = df2_covs, .stats = \"hr\") #> $hr #> $hr$`2` #> [1] 0.4600728 #> #> $hr$`3` #> [1] 0.3100455 #> #> $hr$`4` #> [1] 0.1854177 #> #> #> $hr #> $hr$`A Covariate Label (reference = 1)` #> numeric(0) #> #> #> $hr #> $hr$`Sex (F/M) (reference = F)` #> numeric(0) #> #> #> $hr #> $hr$M #> [1] 1.285406 #> #> a_coxreg( df = dta_bladder, labelstr = \"Label 1\", variables = u1_variables, .spl_context = list(value = \"COVAR1\"), .stats = \"n\", .formats = \"xx\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Label 1 340 0 Label 1 a_coxreg( df = dta_bladder, labelstr = \"\", variables = u1_variables, .spl_context = list(value = \"COVAR2\"), .stats = \"pval\", .formats = \"xx.xxxx\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Sex (F/M) 0.0182 0 Sex (F/M)"},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":null,"dir":"Reference","previous_headings":"","what":"Cox regression helper function for interactions — cox_regression_inter","title":"Cox regression helper function for interactions — cox_regression_inter","text":"Test estimate effect treatment interaction covariate. effect estimated HR tested treatment given level covariate, comparison treatment control.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cox regression helper function for interactions — cox_regression_inter","text":"","code":"h_coxreg_inter_effect(x, effect, covar, mod, label, control, ...) # S3 method for class 'numeric' h_coxreg_inter_effect(x, effect, covar, mod, label, control, at, ...) # S3 method for class 'factor' h_coxreg_inter_effect(x, effect, covar, mod, label, control, data, ...) # S3 method for class 'character' h_coxreg_inter_effect(x, effect, covar, mod, label, control, data, ...) h_coxreg_extract_interaction(effect, covar, mod, data, at, control) h_coxreg_inter_estimations( variable, given, lvl_var, lvl_given, mod, conf_level = 0.95 )"},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cox regression helper function for interactions — cox_regression_inter","text":"x (numeric factor) values covariate tested. effect (string) name effect tested estimated. covar (string) name covariate model. mod (coxph) fitted Cox regression model (see survival::coxph()). label (string) label returned term_label. control (list) list controls returned control_coxreg(). ... see methods. (list) list items named covariate, every item vector levels interaction estimated. data (data.frame) data frame model fit. variable, given (string) name variables interaction. seek estimation levels variable given levels given. lvl_var, lvl_given (character) corresponding levels given levels(). conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cox regression helper function for interactions — cox_regression_inter","text":"h_coxreg_inter_effect() returns data.frame covariate interaction effects consisting following variables: effect, term, term_label, level, n, hr, lcl, ucl, pval, pval_inter. h_coxreg_extract_interaction() returns result interaction test estimated values. interaction, h_coxreg_univar_extract() applied instead. h_coxreg_inter_estimations() returns list matrices (one per level variable) rows corresponding combinations variable given, columns: coef_hat: Estimation coefficient. coef_se: Standard error estimation. hr: Hazard ratio. lcl, ucl: Lower/upper confidence limit hazard ratio.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cox regression helper function for interactions — cox_regression_inter","text":"Given cox regression investigating effect Arm (, B, C; reference ) Sex (F, M; reference Female) model abbreviated: y ~ Arm + Sex + Arm:Sex. cox regression estimates coefficients along variance-covariance matrix : b1 (arm b), b2 (arm c) b3 (sex m) b4 (arm b: sex m), b5 (arm c: sex m) estimation Hazard Ratio arm C/sex M given reference arm /Sex M exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5). interaction coefficient deduced b2 + b5 standard error obtained $sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cox regression helper function for interactions — cox_regression_inter","text":"h_coxreg_inter_effect(): S3 generic helper function determine interaction effect. h_coxreg_inter_effect(numeric): Method numeric class. Estimates interaction numeric covariate. h_coxreg_inter_effect(factor): Method factor class. Estimate interaction factor covariate. h_coxreg_inter_effect(character): Method character class. Estimate interaction character covariate. makes automatic conversion factor forwards method factors. h_coxreg_extract_interaction(): higher level function get results interaction test estimated values. h_coxreg_inter_estimations(): Hazard ratio estimation interactions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Cox regression helper function for interactions — cox_regression_inter","text":"Automatic conversion character factor guarantee results can generated correctly. therefore better always pre-process dataset factors manually created character variables passing dataset rtables::build_table().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cox_regression_inter.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cox regression helper function for interactions — cox_regression_inter","text":"","code":"library(survival) set.seed(1, kind = \"Mersenne-Twister\") # Testing dataset [survival::bladder]. dta_bladder <- with( data = bladder[bladder$enum < 5, ], data.frame( time = stop, status = event, armcd = as.factor(rx), covar1 = as.factor(enum), covar2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) ) ) labels <- c(\"armcd\" = \"ARM\", \"covar1\" = \"A Covariate Label\", \"covar2\" = \"Sex (F/M)\") formatters::var_labels(dta_bladder)[names(labels)] <- labels dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) plot( survfit(Surv(time, status) ~ armcd + covar1, data = dta_bladder), lty = 2:4, xlab = \"Months\", col = c(\"blue1\", \"blue2\", \"blue3\", \"blue4\", \"red1\", \"red2\", \"red3\", \"red4\") ) mod <- coxph(Surv(time, status) ~ armcd * covar1, data = dta_bladder) h_coxreg_extract_interaction( mod = mod, effect = \"armcd\", covar = \"covar1\", data = dta_bladder, control = control_coxreg() ) #> effect term term_label level n hr #> 1 Covariate: covar1 A Covariate Label 340 NA #> armcd2/covar11 Covariate: covar1 1 1 NA 0.6341111 #> armcd2/covar12 Covariate: covar1 2 2 NA 0.5845305 #> armcd2/covar13 Covariate: covar1 3 3 NA 0.5507703 #> armcd2/covar14 Covariate: covar1 4 4 NA 0.6910643 #> lcl ucl pval pval_inter #> 1 NA NA 0.1302825 0.988245 #> armcd2/covar11 0.3514676 1.144051 NA NA #> armcd2/covar12 0.2716689 1.257692 NA NA #> armcd2/covar13 0.2244668 1.351415 NA NA #> armcd2/covar14 0.2315248 2.062715 NA NA mod <- coxph(Surv(time, status) ~ armcd * covar1, data = dta_bladder) result <- h_coxreg_inter_estimations( variable = \"armcd\", given = \"covar1\", lvl_var = levels(dta_bladder$armcd), lvl_given = levels(dta_bladder$covar1), mod = mod, conf_level = .95 ) result #> $armcd2 #> coef se(coef) hr lcl ucl #> armcd2/covar11 -0.4555312 0.3010803 0.6341111 0.3514676 1.144051 #> armcd2/covar12 -0.5369464 0.3909383 0.5845305 0.2716689 1.257692 #> armcd2/covar13 -0.5964375 0.4579624 0.5507703 0.2244668 1.351415 #> armcd2/covar14 -0.3695225 0.5579418 0.6910643 0.2315248 2.062715 #> #> attr(,\"details\") #> [1] \"Estimations of armcd hazard ratio given the level of covar1 compared to armcd level 1.\""},{"path":"https://insightsengineering.github.io/tern/reference/cut_quantile_bins.html","id":null,"dir":"Reference","previous_headings":"","what":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"cuts numeric vector sample quantile bins.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cut_quantile_bins.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"","code":"cut_quantile_bins( x, probs = c(0.25, 0.5, 0.75), labels = NULL, type = 7, ordered = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/cut_quantile_bins.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"x (numeric) continuous variable values cut quantile bins. may contain NA values, used quantile calculations, included return vector. probs (numeric) probabilities identifying quantiles. sorted vector unique proportion values, .e. 0 1, boundaries 0 1 must included. labels (character) unique labels quantile bins. n probabilities probs, must n + 1 long. type (integer(1)) type quantiles use, see stats::quantile() details. ordered (flag) result ordered factor.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cut_quantile_bins.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"factor variable appropriately-labeled bins levels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cut_quantile_bins.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"Intervals closed right side. , first bin interval [-Inf, q1] q1 first quantile, second bin (q1, q2], etc., last bin (qn, +Inf] qn last quantile.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/cut_quantile_bins.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"","code":"# Default is to cut into quartile bins. cut_quantile_bins(cars$speed) #> [1] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] #> [7] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] #> [13] [0%,25%] [0%,25%] [0%,25%] (25%,50%] (25%,50%] (25%,50%] #> [19] (25%,50%] (25%,50%] (25%,50%] (25%,50%] (25%,50%] (25%,50%] #> [25] (25%,50%] (25%,50%] (50%,75%] (50%,75%] (50%,75%] (50%,75%] #> [31] (50%,75%] (50%,75%] (50%,75%] (50%,75%] (50%,75%] (50%,75%] #> [37] (50%,75%] (50%,75%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [43] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [49] (75%,100%] (75%,100%] #> Levels: [0%,25%] < (25%,50%] < (50%,75%] < (75%,100%] # Use custom quantiles. cut_quantile_bins(cars$speed, probs = c(0.1, 0.2, 0.6, 0.88)) #> [1] [0%,10%] [0%,10%] [0%,10%] [0%,10%] [0%,10%] (10%,20%] #> [7] (10%,20%] (10%,20%] (10%,20%] (10%,20%] (10%,20%] (20%,60%] #> [13] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] #> [19] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] #> [25] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] #> [31] (20%,60%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] #> [37] (60%,88%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] #> [43] (60%,88%] (60%,88%] (88%,100%] (88%,100%] (88%,100%] (88%,100%] #> [49] (88%,100%] (88%,100%] #> Levels: [0%,10%] < (10%,20%] < (20%,60%] < (60%,88%] < (88%,100%] # Use custom labels. cut_quantile_bins(cars$speed, labels = paste0(\"Q\", 1:4)) #> [1] Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 #> [26] Q2 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 #> Levels: Q1 < Q2 < Q3 < Q4 # NAs are preserved in result factor. ozone_binned <- cut_quantile_bins(airquality$Ozone) which(is.na(ozone_binned)) #> [1] 5 10 25 26 27 32 33 34 35 36 37 39 42 43 45 46 52 53 54 #> [20] 55 56 57 58 59 60 61 65 72 75 83 84 102 103 107 115 119 150 # So you might want to make these explicit. explicit_na(ozone_binned) #> [1] (50%,75%] (50%,75%] [0%,25%] [0%,25%] (25%,50%] #> [7] (25%,50%] (25%,50%] [0%,25%] [0%,25%] [0%,25%] #> [13] [0%,25%] [0%,25%] [0%,25%] [0%,25%] (50%,75%] [0%,25%] #> [19] (25%,50%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] (50%,75%] #> [25] (25%,50%] (50%,75%] (75%,100%] #> [31] (50%,75%] #> [37] (25%,50%] (75%,100%] (50%,75%] #> [43] (25%,50%] (25%,50%] (50%,75%] #> [49] (25%,50%] [0%,25%] [0%,25%] #> [55] #> [61] (75%,100%] (50%,75%] (50%,75%] (75%,100%] #> [67] (50%,75%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [73] [0%,25%] (25%,50%] [0%,25%] (50%,75%] (50%,75%] #> [79] (50%,75%] (75%,100%] (50%,75%] [0%,25%] #> [85] (75%,100%] (75%,100%] (25%,50%] (50%,75%] (75%,100%] (50%,75%] #> [91] (75%,100%] (50%,75%] (50%,75%] [0%,25%] [0%,25%] (75%,100%] #> [97] (50%,75%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [103] (50%,75%] (25%,50%] (75%,100%] (25%,50%] #> [109] (50%,75%] (25%,50%] (25%,50%] (50%,75%] (25%,50%] [0%,25%] #> [115] (50%,75%] (75%,100%] (75%,100%] (75%,100%] #> [121] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [127] (75%,100%] (50%,75%] (50%,75%] (25%,50%] (25%,50%] (25%,50%] #> [133] (25%,50%] (50%,75%] (25%,50%] (25%,50%] [0%,25%] [0%,25%] #> [139] (50%,75%] [0%,25%] [0%,25%] (25%,50%] [0%,25%] [0%,25%] #> [145] (25%,50%] (50%,75%] [0%,25%] [0%,25%] (25%,50%] #> [151] [0%,25%] [0%,25%] (25%,50%] #> Levels: [0%,25%] < (25%,50%] < (50%,75%] < (75%,100%] < "},{"path":"https://insightsengineering.github.io/tern/reference/d_count_abnormal_by_baseline.html","id":null,"dir":"Reference","previous_headings":"","what":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"Description function produces labels s_count_abnormal_by_baseline().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_count_abnormal_by_baseline.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"","code":"d_count_abnormal_by_baseline(abnormal)"},{"path":"https://insightsengineering.github.io/tern/reference/d_count_abnormal_by_baseline.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"abnormal (character) values identifying abnormal range level(s) .var.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_count_abnormal_by_baseline.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"Abnormal category labels s_count_abnormal_by_baseline().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_count_abnormal_by_baseline.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"","code":"d_count_abnormal_by_baseline(\"LOW\") #> $not_abnormal #> [1] \"Not low\" #> #> $abnormal #> [1] \"Low\" #> #> $total #> [1] \"Total\" #>"},{"path":"https://insightsengineering.github.io/tern/reference/d_count_cumulative.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of cumulative count — d_count_cumulative","title":"Description of cumulative count — d_count_cumulative","text":"helper function describes analysis s_count_cumulative().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_count_cumulative.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of cumulative count — d_count_cumulative","text":"","code":"d_count_cumulative(threshold, lower_tail = TRUE, include_eq = TRUE)"},{"path":"https://insightsengineering.github.io/tern/reference/d_count_cumulative.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of cumulative count — d_count_cumulative","text":"threshold (numeric(1)) cutoff value threshold count values x. lower_tail (flag) whether count lower tail, default TRUE. include_eq (flag) whether include value equal threshold count, default TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_count_cumulative.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of cumulative count — d_count_cumulative","text":"Labels s_count_cumulative().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/d_count_missed_doses.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses","text":"","code":"d_count_missed_doses(thresholds)"},{"path":"https://insightsengineering.github.io/tern/reference/d_count_missed_doses.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses","text":"thresholds (numeric) minimum number missed doses patients .","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_count_missed_doses.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses","text":"d_count_missed_doses() returns named character vector labels.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/d_onco_rsp_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of standard oncology response — d_onco_rsp_label","title":"Description of standard oncology response — d_onco_rsp_label","text":"Describe oncology response standard way.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_onco_rsp_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of standard oncology response — d_onco_rsp_label","text":"","code":"d_onco_rsp_label(x)"},{"path":"https://insightsengineering.github.io/tern/reference/d_onco_rsp_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of standard oncology response — d_onco_rsp_label","text":"x (character) standard oncology codes described.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_onco_rsp_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of standard oncology response — d_onco_rsp_label","text":"Response labels.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/d_onco_rsp_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Description of standard oncology response — d_onco_rsp_label","text":"","code":"d_onco_rsp_label( c(\"CR\", \"PR\", \"SD\", \"NON CR/PD\", \"PD\", \"NE\", \"Missing\", \"\", \"NE/Missing\") ) #> CR PR #> Complete Response (CR) Partial Response (PR) #> SD NON CR/PD #> Stable Disease (SD) Non-CR or Non-PD (NON CR/PD) #> PD NE #> Progressive Disease (PD) Not Evaluable (NE) #> Missing #> Missing #> NE/Missing #> Missing or unevaluable #> 9 Levels: Complete Response (CR) Partial Response (PR) ... # Adding some values not considered in d_onco_rsp_label d_onco_rsp_label( c(\"CR\", \"PR\", \"hello\", \"hi\") ) #> CR PR hello #> Complete Response (CR) Partial Response (PR) hello #> hi #> hi #> Levels: Complete Response (CR) Partial Response (PR) hello hi"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/d_pkparam.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate PK reference dataset — d_pkparam","text":"","code":"d_pkparam()"},{"path":"https://insightsengineering.github.io/tern/reference/d_pkparam.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate PK reference dataset — d_pkparam","text":"data.frame PK parameters.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_pkparam.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate PK reference dataset — d_pkparam","text":"","code":"pk_reference_dataset <- d_pkparam()"},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of the proportion summary — d_proportion","title":"Description of the proportion summary — d_proportion","text":"helper function describes analysis s_proportion().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of the proportion summary — d_proportion","text":"","code":"d_proportion(conf_level, method, long = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of the proportion summary — d_proportion","text":"conf_level (proportion) confidence level interval. method (string) method used construct confidence interval proportion successful outcomes; one waldcc, wald, clopper-pearson, wilson, wilsonc, strat_wilson, strat_wilsonc, agresti-coull jeffreys. long (flag) whether long short (default) description required.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of the proportion summary — d_proportion","text":"String describing analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of method used for proportion comparison — d_proportion_diff","title":"Description of method used for proportion comparison — d_proportion_diff","text":"auxiliary function describes analysis s_proportion_diff().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of method used for proportion comparison — d_proportion_diff","text":"","code":"d_proportion_diff(conf_level, method, long = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of method used for proportion comparison — d_proportion_diff","text":"conf_level (proportion) confidence level interval. method (string) method used confidence interval estimation. long (flag) whether long (TRUE) short (FALSE, default) description required.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_proportion_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of method used for proportion comparison — d_proportion_diff","text":"string describing analysis.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/d_rsp_subgroups_colvars.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"Internal function check variables included tabulate_rsp_subgroups() create column labels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_rsp_subgroups_colvars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"","code":"d_rsp_subgroups_colvars(vars, conf_level = NULL, method = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/d_rsp_subgroups_colvars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"vars (character) variable names primary analysis variable iterated . conf_level (proportion) confidence level interval. method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_rsp_subgroups_colvars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"list variables tabulate labels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_survival_subgroups_colvars.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"Internal function check variables included tabulate_survival_subgroups() create column labels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_survival_subgroups_colvars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"","code":"d_survival_subgroups_colvars(vars, conf_level, method, time_unit = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/d_survival_subgroups_colvars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"vars (character) names statistics reported among: n_tot_events: Total number events per group. n_events: Number events per group. n_tot: Total number observations per group. n: Number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. conf_level (proportion) confidence level interval. method (string) p-value method testing hazard ratio = 1. time_unit (string) label unit median survival time. Default NULL skips displaying unit.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_survival_subgroups_colvars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"list variables labels tabulate.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_survival_subgroups_colvars.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"least one n_tot n_tot_events must provided vars.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_test_proportion_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of the difference test between two proportions — d_test_proportion_diff","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"auxiliary function describes analysis s_test_proportion_diff.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_test_proportion_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"","code":"d_test_proportion_diff(method)"},{"path":"https://insightsengineering.github.io/tern/reference/d_test_proportion_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"method (string) one chisq, cmh, fisher, schouten; specifies test used calculate p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/d_test_proportion_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"string describing test p-value derived.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/day2month.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion of days to months — day2month","title":"Conversion of days to months — day2month","text":"Conversion days months","code":""},{"path":"https://insightsengineering.github.io/tern/reference/day2month.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion of days to months — day2month","text":"","code":"day2month(x)"},{"path":"https://insightsengineering.github.io/tern/reference/day2month.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conversion of days to months — day2month","text":"x (numeric(1)) time days.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/day2month.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conversion of days to months — day2month","text":"numeric vector time months.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/day2month.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conversion of days to months — day2month","text":"","code":"x <- c(403, 248, 30, 86) day2month(x) #> [1] 13.2402464 8.1478439 0.9856263 2.8254620"},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"function useful label grid grobs (also ggplot2, lattice plots) title, footnote, page numbers.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"","code":"decorate_grob( grob, titles, footnotes, page = \"\", width_titles = grid::unit(1, \"npc\"), width_footnotes = grid::unit(1, \"npc\"), border = TRUE, padding = grid::unit(rep(1, 4), \"lines\"), margins = grid::unit(c(1, 0, 1, 0), \"lines\"), outer_margins = grid::unit(c(2, 1.5, 3, 1.5), \"cm\"), gp_titles = grid::gpar(), gp_footnotes = grid::gpar(fontsize = 8), name = NULL, gp = grid::gpar(), vp = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"grob (grob) grid grob object, optionally NULL grob decoration shown. titles (character) titles given vector strings separated newline wrapped according page width. footnotes (character) footnotes. Uses formatting rules titles. page (string NULL) page numeration. NULL page number displayed. width_titles (grid::unit) width titles. Usually defined available space grid::unit(1, \"npc\"), affected parameter outer_margins. Right margins (outer_margins[4]) need subtracted allowed width. width_footnotes (grid::unit) width footnotes. default margin correction width_titles. border (flag) whether border drawn around plot . padding (grid::unit) padding. unit object length 4. Innermost margin plot (grob) , possibly, border plot. Usually expressed 4 identical values (usually \"lines\"). defaults grid::unit(rep(1, 4), \"lines\"). margins (grid::unit) margins. unit object length 4. Margins plot elements list (e.g. titles, plot, footers). usually expressed 4 \"lines\", lateral ones 0s, top bottom 1s. defaults grid::unit(c(1, 0, 1, 0), \"lines\"). outer_margins (grid::unit) outer margins. unit object length 4. defines general margin plot, considering also decorations like titles, footnotes, page numbers. defaults grid::unit(c(2, 1.5, 3, 1.5), \"cm\"). gp_titles (gpar) gpar object. Mainly used set different \"fontsize\". gp_footnotes (gpar) gpar object. Mainly used set different \"fontsize\". name character identifier grob. Used find grob display list /child another grob. gp \"gpar\" object, typically output call function gpar. basically list graphical parameter settings. vp viewport object (NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"grid grob (gTree).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"titles footnotes ragged, .e. title wrapped individually.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"","code":"library(grid) titles <- c( \"Edgar Anderson's Iris Data\", paste( \"This famous (Fisher's or Anderson's) iris data set gives the measurements\", \"in centimeters of the variables sepal length and width and petal length\", \"and width, respectively, for 50 flowers from each of 3 species of iris.\" ) ) footnotes <- c( \"The species are Iris setosa, versicolor, and virginica.\", paste( \"iris is a data frame with 150 cases (rows) and 5 variables (columns) named\", \"Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, and Species.\" ) ) ## empty plot grid.newpage() grid.draw( decorate_grob( NULL, titles = titles, footnotes = footnotes, page = \"Page 4 of 10\" ) ) # grid p <- gTree( children = gList( rectGrob(), xaxisGrob(), yaxisGrob(), textGrob(\"Sepal.Length\", y = unit(-4, \"lines\")), textGrob(\"Petal.Length\", x = unit(-3.5, \"lines\"), rot = 90), pointsGrob(iris$Sepal.Length, iris$Petal.Length, gp = gpar(col = iris$Species), pch = 16) ), vp = vpStack(plotViewport(), dataViewport(xData = iris$Sepal.Length, yData = iris$Petal.Length)) ) grid.newpage() grid.draw(p) grid.newpage() grid.draw( decorate_grob( grob = p, titles = titles, footnotes = footnotes, page = \"Page 6 of 129\" ) ) ## with ggplot2 library(ggplot2) p_gg <- ggplot2::ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) + ggplot2::geom_point() p_gg p <- ggplotGrob(p_gg) grid.newpage() grid.draw( decorate_grob( grob = p, titles = titles, footnotes = footnotes, page = \"Page 6 of 129\" ) ) ## with lattice library(lattice) xyplot(Sepal.Length ~ Petal.Length, data = iris, col = iris$Species) p <- grid.grab() grid.newpage() grid.draw( decorate_grob( grob = p, titles = titles, footnotes = footnotes, page = \"Page 6 of 129\" ) ) # with gridExtra - no borders library(gridExtra) #> #> Attaching package: ‘gridExtra’ #> The following object is masked from ‘package:dplyr’: #> #> combine grid.newpage() grid.draw( decorate_grob( tableGrob( head(mtcars) ), titles = \"title\", footnotes = \"footnote\", border = FALSE ) )"},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_factory.html","id":null,"dir":"Reference","previous_headings":"","what":"Update page number — decorate_grob_factory","title":"Update page number — decorate_grob_factory","text":"Automatically updates page number.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_factory.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update page number — decorate_grob_factory","text":"","code":"decorate_grob_factory(npages, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_factory.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update page number — decorate_grob_factory","text":"npages (numeric(1)) total number pages. ... arguments passed decorate_grob().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_factory.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update page number — decorate_grob_factory","text":"Closure increments page number.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Decorate set of grobs and add page numbering — decorate_grob_set","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"Note uses decorate_grob_factory() function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"","code":"decorate_grob_set(grobs, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"grobs (list grob) list grid grobs. ... arguments passed decorate_grob().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"decorated grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/decorate_grob_set.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"","code":"library(ggplot2) library(grid) g <- with(data = iris, { list( ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Length, Sepal.Width, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Length, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Width, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Length, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Width, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Petal.Length, Petal.Width, col = Species)) + ggplot2::geom_point() ) ) }) lg <- decorate_grob_set(grobs = g, titles = \"Hello\\nOne\\nTwo\\nThree\", footnotes = \"\") draw_grob(lg[[1]]) #> Warning: `draw_grob()` was deprecated in tern 0.9.4. #> ℹ `tern` plotting functions no longer generate `grob` objects. draw_grob(lg[[2]]) draw_grob(lg[[6]])"},{"path":"https://insightsengineering.github.io/tern/reference/default_na_str.html","id":null,"dir":"Reference","previous_headings":"","what":"Default string replacement for NA values — default_na_str","title":"Default string replacement for NA values — default_na_str","text":"default string used represent NA values. value used default value na_str argument throughout tern package, printed place NA values output tables. specified tern function user via na_str argument, R environment options via set_default_na_str(), NA used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_na_str.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Default string replacement for NA values — default_na_str","text":"","code":"default_na_str() set_default_na_str(na_str)"},{"path":"https://insightsengineering.github.io/tern/reference/default_na_str.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Default string replacement for NA values — default_na_str","text":"na_str (string) single string value set R environment options default value replace NAs. Use getOption(\"tern_default_na_str\") check current value set R environment (defaults NULL set).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_na_str.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Default string replacement for NA values — default_na_str","text":"default_na_str returns current value R environment option set \"tern_default_na_str\", NA_character_ otherwise. set_default_na_str return value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_na_str.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Default string replacement for NA values — default_na_str","text":"default_na_str(): Accessor default NA value replacement string. set_default_na_str(): Setter default NA value replacement string. Sets option \"tern_default_na_str\" within R environment.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_na_str.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Default string replacement for NA values — default_na_str","text":"","code":"# Default settings default_na_str() #> [1] NA getOption(\"tern_default_na_str\") #> NULL # Set custom value set_default_na_str(\"\") # Settings after value has been set default_na_str() #> [1] \"\" getOption(\"tern_default_na_str\") #> [1] \"\""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"Utility functions get valid statistic methods different method groups (.stats) associated formats (.formats), labels (.labels), indent modifiers (.indent_mods). utility used across tern, working principles can seen analyze_vars(). See notes understand experimental.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"","code":"get_stats( method_groups = \"analyze_vars_numeric\", stats_in = NULL, add_pval = FALSE ) get_formats_from_stats(stats, formats_in = NULL) get_labels_from_stats(stats, labels_in = NULL, row_nms = NULL) get_indents_from_stats(stats, indents_in = NULL, row_nms = NULL) tern_default_stats tern_default_formats tern_default_labels summary_formats(type = \"numeric\", include_pval = FALSE) summary_labels(type = \"numeric\", include_pval = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"tern_default_stats named list available statistics, element named corresponding statistical method group. tern_default_formats named vector available default formats, element named corresponding statistic. tern_default_labels named character vector available default labels, element named corresponding statistic.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"method_groups (character) indicates statistical method group (tern analyze function) retrieve default statistics . character vector can used specify one statistical method group. stats_in (character) statistics retrieve selected method group. add_pval (flag) \"pval\" (\"pval_counts\" method_groups contains \"analyze_vars_counts\") added statistical methods? stats (character) statistical methods get defaults . formats_in (named vector) inserted formats replace defaults. can character vector formatters::list_valid_format_labels() custom format function. labels_in (named character) inserted labels replace defaults. row_nms (character) row names. Levels factor character variable, statistics .stats calculated . parameter set, variable levels used defaults, names given custom values correspond levels (format statistic.level) instead statistics. Can also variable names rows correspond different variables instead levels. Defaults NULL. indents_in (named vector) inserted indent modifiers replace defaults (default 0L). type (string)\"numeric\" \"counts\". include_pval (flag) add_pval argument get_stats().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"get_stats() returns character vector statistical methods. get_formats_from_stats() returns named vector formats (present either tern_default_formats formats_in, otherwise NULL). Values can taken formatters::list_valid_format_labels() custom function (e.g. formatting_functions). get_labels_from_stats() returns named character vector labels (present either tern_default_labels labels_in, otherwise NULL). get_indents_from_stats() returns single indent modifier value apply rows named numeric vector indent modifiers (present, otherwise NULL). summary_formats() returns named vector default statistic formats given data type. summary_labels returns named vector default statistic labels given data type.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"Current choices type counts numeric analyze_vars() affect get_stats(). summary_* quick get functions labels formats uses get_stats get_labels_from_stats get_formats_from_stats respectively retrieve relevant information.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"get_stats(): Get statistics available given method group (analyze function). check available defaults see tern::tern_default_stats list. get_formats_from_stats(): Get formats corresponding list statistics. check available defaults see tern::tern_default_formats list. get_labels_from_stats(): Get labels corresponding list statistics. check available defaults see tern::tern_default_labels list. available , statistics name used label. get_indents_from_stats(): Format indent modifiers given vector/list statistics. defaults 0L values. tern_default_stats: Named list available statistics method group tern. tern_default_formats: Named vector default formats tern. tern_default_labels: Named character vector default labels tern. summary_formats(): Quick function retrieve default formats summary statistics: analyze_vars() analyze_vars_in_cols() principally. summary_labels(): Quick function retrieve default labels summary statistics. Returns labels descriptive statistics understood rtables. Similar summary_formats.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"defaults experimental use names functions retrieve default statistics. generalized groups methods according reasonable groupings. Formats tern rtables can functions take table cell value return string. well documented vignette(\"custom_appearance\", package = \"rtables\").","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/default_stats_formats_labels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"","code":"# analyze_vars is numeric num_stats <- get_stats(\"analyze_vars_numeric\") # also the default # Other type cnt_stats <- get_stats(\"analyze_vars_counts\") # Weirdly taking the pval from count_occurrences only_pval <- get_stats(\"count_occurrences\", add_pval = TRUE, stats_in = \"pval\") # All count_occurrences all_cnt_occ <- get_stats(\"count_occurrences\") # Multiple get_stats(c(\"count_occurrences\", \"analyze_vars_counts\")) #> [1] \"count\" \"count_fraction\" #> [3] \"count_fraction_fixed_dp\" \"fraction\" #> [5] \"n\" \"n_blq\" # Defaults formats get_formats_from_stats(num_stats) #> $n #> [1] \"xx.\" #> #> $sum #> [1] \"xx.x\" #> #> $mean #> [1] \"xx.x\" #> #> $sd #> [1] \"xx.x\" #> #> $se #> [1] \"xx.x\" #> #> $mean_sd #> [1] \"xx.x (xx.x)\" #> #> $mean_se #> [1] \"xx.x (xx.x)\" #> #> $mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sei #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sdi #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_pval #> [1] \"x.xxxx | (<0.0001)\" #> #> $median #> [1] \"xx.x\" #> #> $mad #> [1] \"xx.x\" #> #> $median_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $quantiles #> [1] \"xx.x - xx.x\" #> #> $iqr #> [1] \"xx.x\" #> #> $range #> [1] \"xx.x - xx.x\" #> #> $min #> [1] \"xx.x\" #> #> $max #> [1] \"xx.x\" #> #> $median_range #> [1] \"xx.x (xx.x - xx.x)\" #> #> $cv #> [1] \"xx.x\" #> #> $geom_mean #> [1] \"xx.x\" #> #> $geom_mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $geom_cv #> [1] \"xx.x\" #> #> $median_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $geom_mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> get_formats_from_stats(cnt_stats) #> $n #> [1] \"xx.\" #> #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> checkmate::assert_vector(x) #> checkmate::assert_count(x[\"num\"]) #> checkmate::assert_count(x[\"denom\"]) #> #> result <- if (x[\"num\"] == 0) { #> paste0(x[\"num\"], \"/\", x[\"denom\"]) #> } else { #> paste0( #> x[\"num\"], \"/\", x[\"denom\"], #> \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" #> ) #> } #> return(result) #> } #> #> #> $n_blq #> [1] \"xx.\" #> get_formats_from_stats(only_pval) #> $pval #> [1] \"x.xxxx | (<0.0001)\" #> get_formats_from_stats(all_cnt_occ) #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> checkmate::assert_vector(x) #> checkmate::assert_count(x[\"num\"]) #> checkmate::assert_count(x[\"denom\"]) #> #> result <- if (x[\"num\"] == 0) { #> paste0(x[\"num\"], \"/\", x[\"denom\"]) #> } else { #> paste0( #> x[\"num\"], \"/\", x[\"denom\"], #> \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" #> ) #> } #> return(result) #> } #> #> # Addition of customs get_formats_from_stats(all_cnt_occ, formats_in = c(\"fraction\" = c(\"xx\"))) #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> [1] \"xx\" #> get_formats_from_stats(all_cnt_occ, formats_in = list(\"fraction\" = c(\"xx.xx\", \"xx\"))) #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> [1] \"xx.xx\" \"xx\" #> # Defaults labels get_labels_from_stats(num_stats) #> n sum #> \"n\" \"Sum\" #> mean sd #> \"Mean\" \"SD\" #> se mean_sd #> \"SE\" \"Mean (SD)\" #> mean_se mean_ci #> \"Mean (SE)\" \"Mean 95% CI\" #> mean_sei mean_sdi #> \"Mean -/+ 1xSE\" \"Mean -/+ 1xSD\" #> mean_pval median #> \"Mean p-value (H0: mean = 0)\" \"Median\" #> mad median_ci #> \"Median Absolute Deviation\" \"Median 95% CI\" #> quantiles iqr #> \"25% and 75%-ile\" \"IQR\" #> range min #> \"Min - Max\" \"Minimum\" #> max median_range #> \"Maximum\" \"Median (Min - Max)\" #> cv geom_mean #> \"CV (%)\" \"Geometric Mean\" #> geom_mean_ci geom_cv #> \"Geometric Mean 95% CI\" \"CV % Geometric Mean\" #> median_ci_3d mean_ci_3d #> \"Median (95% CI)\" \"Mean (95% CI)\" #> geom_mean_ci_3d #> \"Geometric Mean (95% CI)\" get_labels_from_stats(cnt_stats) #> n count count_fraction #> \"n\" \"count\" \"count_fraction\" #> count_fraction_fixed_dp fraction n_blq #> \"count_fraction\" \"fraction\" \"n_blq\" get_labels_from_stats(only_pval) #> pval #> \"p-value (t-test)\" get_labels_from_stats(all_cnt_occ) #> count count_fraction count_fraction_fixed_dp #> \"count\" \"count_fraction\" \"count_fraction\" #> fraction #> \"fraction\" # Addition of customs get_labels_from_stats(all_cnt_occ, labels_in = c(\"fraction\" = \"Fraction\")) #> count count_fraction count_fraction_fixed_dp #> \"count\" \"count_fraction\" \"count_fraction\" #> fraction #> \"Fraction\" get_labels_from_stats(all_cnt_occ, labels_in = list(\"fraction\" = c(\"Some more fractions\"))) #> $count #> [1] \"count\" #> #> $count_fraction #> [1] \"count_fraction\" #> #> $count_fraction_fixed_dp #> [1] \"count_fraction\" #> #> $fraction #> [1] \"Some more fractions\" #> get_indents_from_stats(all_cnt_occ, indents_in = 3L) #> [1] 3 3 3 3 get_indents_from_stats(all_cnt_occ, indents_in = list(count = 2L, count_fraction = 5L)) #> $count #> [1] 2 #> #> $count_fraction #> [1] 5 #> #> $count_fraction_fixed_dp #> [1] 0 #> #> $fraction #> [1] 0 #> get_indents_from_stats( all_cnt_occ, indents_in = list(a = 2L, count.a = 1L, count.b = 5L), row_nms = c(\"a\", \"b\") ) #> $count.a #> [1] 1 #> #> $count.b #> [1] 5 #> #> $count_fraction.a #> [1] 2 #> #> $count_fraction.b #> [1] 0 #> #> $count_fraction_fixed_dp.a #> [1] 2 #> #> $count_fraction_fixed_dp.b #> [1] 0 #> #> $fraction.a #> [1] 2 #> #> $fraction.b #> [1] 0 #> summary_formats() #> $n #> [1] \"xx.\" #> #> $sum #> [1] \"xx.x\" #> #> $mean #> [1] \"xx.x\" #> #> $sd #> [1] \"xx.x\" #> #> $se #> [1] \"xx.x\" #> #> $mean_sd #> [1] \"xx.x (xx.x)\" #> #> $mean_se #> [1] \"xx.x (xx.x)\" #> #> $mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sei #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sdi #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_pval #> [1] \"x.xxxx | (<0.0001)\" #> #> $median #> [1] \"xx.x\" #> #> $mad #> [1] \"xx.x\" #> #> $median_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $quantiles #> [1] \"xx.x - xx.x\" #> #> $iqr #> [1] \"xx.x\" #> #> $range #> [1] \"xx.x - xx.x\" #> #> $min #> [1] \"xx.x\" #> #> $max #> [1] \"xx.x\" #> #> $median_range #> [1] \"xx.x (xx.x - xx.x)\" #> #> $cv #> [1] \"xx.x\" #> #> $geom_mean #> [1] \"xx.x\" #> #> $geom_mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $geom_cv #> [1] \"xx.x\" #> #> $median_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $geom_mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> summary_formats(type = \"counts\", include_pval = TRUE) #> $n #> [1] \"xx.\" #> #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> checkmate::assert_vector(x) #> checkmate::assert_count(x[\"num\"]) #> checkmate::assert_count(x[\"denom\"]) #> #> result <- if (x[\"num\"] == 0) { #> paste0(x[\"num\"], \"/\", x[\"denom\"]) #> } else { #> paste0( #> x[\"num\"], \"/\", x[\"denom\"], #> \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" #> ) #> } #> return(result) #> } #> #> #> $n_blq #> [1] \"xx.\" #> #> $pval_counts #> [1] \"x.xxxx | (<0.0001)\" #> summary_labels() #> n sum #> \"n\" \"Sum\" #> mean sd #> \"Mean\" \"SD\" #> se mean_sd #> \"SE\" \"Mean (SD)\" #> mean_se mean_ci #> \"Mean (SE)\" \"Mean 95% CI\" #> mean_sei mean_sdi #> \"Mean -/+ 1xSE\" \"Mean -/+ 1xSD\" #> mean_pval median #> \"Mean p-value (H0: mean = 0)\" \"Median\" #> mad median_ci #> \"Median Absolute Deviation\" \"Median 95% CI\" #> quantiles iqr #> \"25% and 75%-ile\" \"IQR\" #> range min #> \"Min - Max\" \"Minimum\" #> max median_range #> \"Maximum\" \"Median (Min - Max)\" #> cv geom_mean #> \"CV (%)\" \"Geometric Mean\" #> geom_mean_ci geom_cv #> \"Geometric Mean 95% CI\" \"CV % Geometric Mean\" #> median_ci_3d mean_ci_3d #> \"Median (95% CI)\" \"Mean (95% CI)\" #> geom_mean_ci_3d #> \"Geometric Mean (95% CI)\" summary_labels(type = \"counts\", include_pval = TRUE) #> n count #> \"n\" \"count\" #> count_fraction count_fraction_fixed_dp #> \"count_fraction\" \"count_fraction\" #> fraction n_blq #> \"fraction\" \"n_blq\" #> pval_counts #> \"p-value (chi-squared test)\""},{"path":"https://insightsengineering.github.io/tern/reference/desctools_binom.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence intervals for a difference of binomials — desctools_binom","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"Several confidence intervals difference proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/desctools_binom.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"","code":"desctools_binom( x1, n1, x2, n2, conf.level = 0.95, sides = c(\"two.sided\", \"left\", \"right\"), method = c(\"ac\", \"wald\", \"waldcc\", \"score\", \"scorecc\", \"mn\", \"mee\", \"blj\", \"ha\", \"hal\", \"jp\") ) desctools_binomci( x, n, conf.level = 0.95, sides = c(\"two.sided\", \"left\", \"right\"), method = c(\"wilson\", \"wald\", \"waldcc\", \"agresti-coull\", \"jeffreys\", \"modified wilson\", \"wilsoncc\", \"modified jeffreys\", \"clopper-pearson\", \"arcsine\", \"logit\", \"witting\", \"pratt\", \"midp\", \"lik\", \"blaker\"), rand = 123, tol = 1e-05 )"},{"path":"https://insightsengineering.github.io/tern/reference/desctools_binom.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"conf.level (proportion) confidence level, defaults 0.95. sides (string) side confidence interval compute. Must one \"two-sided\" (default), \"left\", \"right\". method (string) method use. Can one : \"wald\", \"wilson\", \"wilsoncc\", \"agresti-coull\", \"jeffreys\", \"modified wilson\", \"modified jeffreys\", \"clopper-pearson\", \"arcsine\", \"logit\", \"witting\", \"pratt\", \"midp\", \"lik\", \"blaker\". x (integer(1)) number successes. n (integer(1)) number trials.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/desctools_binom.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"matrix 3 values: est: estimate proportion difference. lwr.ci: estimate lower end confidence interval. upr.ci: estimate upper end confidence interval. matrix 3 columns containing: est: estimate proportion difference. lwr.ci: lower end confidence interval. upr.ci: upper end confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/desctools_binom.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"desctools_binom(): Several confidence intervals difference proportions. desctools_binomci(): Compute confidence intervals binomial proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df2gg.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert data.frame object to ggplot object — df2gg","title":"Convert data.frame object to ggplot object — df2gg","text":"Given data.frame object, performs basic conversion ggplot2::ggplot() object built using functions ggplot2 package.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df2gg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert data.frame object to ggplot object — df2gg","text":"","code":"df2gg( df, colwidths = NULL, font_size = 10, col_labels = TRUE, col_lab_fontface = \"bold\", hline = TRUE, bg_fill = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/df2gg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert data.frame object to ggplot object — df2gg","text":"df (data.frame) data frame. colwidths (numeric NULL) vector column widths. element's position colwidths corresponds column df position. NULL, column widths calculated according maximum number characters per column. font_size (numeric(1)) font size. col_labels (flag) whether column names (labels) df used first row output table. col_lab_fontface (string) font face apply first row (column labels col_labels = TRUE). Defaults \"bold\". hline (flag) whether horizontal line printed first row table. bg_fill (string) table background fill color.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df2gg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert data.frame object to ggplot object — df2gg","text":"ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df2gg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert data.frame object to ggplot object — df2gg","text":"","code":"if (FALSE) { # \\dontrun{ df2gg(head(iris, 5)) df2gg(head(iris, 5), font_size = 15, colwidths = c(1, 1, 1, 1, 1)) } # }"},{"path":"https://insightsengineering.github.io/tern/reference/df_explicit_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Encode categorical missing values in a data frame — df_explicit_na","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"helper function encode missing entries across groups categorical variables data frame.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df_explicit_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"","code":"df_explicit_na( data, omit_columns = NULL, char_as_factor = TRUE, logical_as_factor = FALSE, na_level = \"\" )"},{"path":"https://insightsengineering.github.io/tern/reference/df_explicit_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"data (data.frame) data set. omit_columns (character) names variables data modified function. char_as_factor (flag) whether convert character variables data factors. logical_as_factor (flag) whether convert logical variables data factors. na_level (string) string used replace NA empty values inside non-omit_columns columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df_explicit_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"data.frame chosen modifications applied.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/df_explicit_na.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"Missing entries NA empty strings replaced specified value. factor variables include missing values, missing value inserted last level. Similarly, case character logical variables converted factors char_as_factor logical_as_factor options, missing values set last level.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/df_explicit_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"","code":"my_data <- data.frame( u = c(TRUE, FALSE, NA, TRUE), v = factor(c(\"A\", NA, NA, NA), levels = c(\"Z\", \"A\")), w = c(\"A\", \"B\", NA, \"C\"), x = c(\"D\", \"E\", \"F\", NA), y = c(\"G\", \"H\", \"I\", \"\"), z = c(1, 2, 3, 4), stringsAsFactors = FALSE ) # Example 1 # Encode missing values in all character or factor columns. df_explicit_na(my_data) #> u v w x y z #> 1 TRUE A A D G 1 #> 2 FALSE B E H 2 #> 3 NA F I 3 #> 4 TRUE C 4 # Also convert logical columns to factor columns. df_explicit_na(my_data, logical_as_factor = TRUE) #> u v w x y z #> 1 TRUE A A D G 1 #> 2 FALSE B E H 2 #> 3 F I 3 #> 4 TRUE C 4 # Encode missing values in a subset of columns. df_explicit_na(my_data, omit_columns = c(\"x\", \"y\")) #> u v w x y z #> 1 TRUE A A D G 1 #> 2 FALSE B E H 2 #> 3 NA F I 3 #> 4 TRUE C 4 # Example 2 # Here we purposefully convert all `M` values to `NA` in the `SEX` variable. # After running `df_explicit_na` the `NA` values are encoded as `` but they are not # included when generating `rtables`. adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl) # If you want the `Na` values to be displayed in the table use the `na_level` argument. adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl, na_level = \"Missing Values\") # Example 3 # Numeric variables that have missing values are not altered. This means that any `NA` value in # a numeric variable will not be included in the summary statistics, nor will they be included # in the denominator value for calculating the percent values. adsl <- tern_ex_adsl adsl$AGE[adsl$AGE < 30] <- NA adsl <- df_explicit_na(adsl)"},{"path":"https://insightsengineering.github.io/tern/reference/dot-is_equal_float.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to check if a float value is equal to another float value — .is_equal_float","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"Uses .Machine$double.eps tolerance comparison.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/dot-is_equal_float.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"","code":".is_equal_float(x, y)"},{"path":"https://insightsengineering.github.io/tern/reference/dot-is_equal_float.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"x (numeric(1)) float number. y (numeric(1)) float number.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/dot-is_equal_float.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"TRUE identical, otherwise FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/draw_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Draw grob — draw_grob","title":"Draw grob — draw_grob","text":"Draw grob device page.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/draw_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Draw grob — draw_grob","text":"","code":"draw_grob(grob, newpage = TRUE, vp = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/draw_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Draw grob — draw_grob","text":"grob (grob) grid object. newpage (flag) draw new page. vp (viewport NULL) viewport() object (NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/draw_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Draw grob — draw_grob","text":"grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/draw_grob.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Draw grob — draw_grob","text":"","code":"library(dplyr) library(grid) # \\donttest{ rect <- rectGrob(width = grid::unit(0.5, \"npc\"), height = grid::unit(0.5, \"npc\")) rect %>% draw_grob(vp = grid::viewport(angle = 45)) num <- lapply(1:10, textGrob) num %>% arrange_grobs(grobs = .) %>% draw_grob() #> Warning: `stack_grobs()` was deprecated in tern 0.9.4. #> ℹ `tern` plotting functions no longer generate `grob` objects. #> ℹ The deprecated feature was likely used in the tern package. #> Please report the issue at #> . showViewport() # }"},{"path":"https://insightsengineering.github.io/tern/reference/empty_vector_if_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Return an empty numeric if all elements are NA. — empty_vector_if_na","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"Return empty numeric elements NA.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/empty_vector_if_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"","code":"empty_vector_if_na(x)"},{"path":"https://insightsengineering.github.io/tern/reference/empty_vector_if_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"x (numeric) vector.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/empty_vector_if_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"empty numeric elements x NA, otherwise x.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/empty_vector_if_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"","code":"x <- c(NA, NA, NA) # Internal function - empty_vector_if_na"},{"path":"https://insightsengineering.github.io/tern/reference/estimate_coef.html","id":null,"dir":"Reference","previous_headings":"","what":"Hazard ratio estimation in interactions — estimate_coef","title":"Hazard ratio estimation in interactions — estimate_coef","text":"function estimates hazard ratios arms interaction variable given specific values.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_coef.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Hazard ratio estimation in interactions — estimate_coef","text":"","code":"estimate_coef( variable, given, lvl_var, lvl_given, coef, mmat, vcov, conf_level = 0.95 )"},{"path":"https://insightsengineering.github.io/tern/reference/estimate_coef.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Hazard ratio estimation in interactions — estimate_coef","text":"variable, given (character(2)) names two variables interaction. seek estimation levels variable given levels given. lvl_var, lvl_given (character) corresponding levels given levels(). coef (numeric) vector estimated coefficients. mmat (named numeric) vector filled 0s used template obtain design matrix. vcov (matrix) variance-covariance matrix underlying model. conf_level (proportion) confidence level estimate intervals.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_coef.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Hazard ratio estimation in interactions — estimate_coef","text":"list matrices (one per level variable) rows corresponding combinations variable given, columns: coef_hat: Estimation coefficient. coef_se: Standard error estimation. hr: Hazard ratio. lcl, ucl: Lower/upper confidence limit hazard ratio.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_coef.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Hazard ratio estimation in interactions — estimate_coef","text":"Given cox regression investigating effect Arm (, B, C; reference ) Sex (F, M; reference Female). model abbreviated: y ~ Arm + Sex + Arm x Sex. cox regression estimates coefficients along variance-covariance matrix : b1 (arm b), b2 (arm c) b3 (sex m) b4 (arm b: sex m), b5 (arm c: sex m) Given want estimation Hazard Ratio arm C/sex M, estimation given reference arm /Sex M exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5), therefore interaction coefficient given b2 + b5 standard error obtained $1.96 * sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$ confidence level 0.95.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/estimate_coef.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Hazard ratio estimation in interactions — estimate_coef","text":"","code":"library(dplyr) library(survival) ADSL <- tern_ex_adsl %>% filter(SEX %in% c(\"F\", \"M\")) adtte <- tern_ex_adtte %>% filter(PARAMCD == \"PFS\") adtte$ARMCD <- droplevels(adtte$ARMCD) adtte$SEX <- droplevels(adtte$SEX) mod <- coxph( formula = Surv(time = AVAL, event = 1 - CNSR) ~ (SEX + ARMCD)^2, data = adtte ) mmat <- stats::model.matrix(mod)[1, ] mmat[!mmat == 0] <- 0"},{"path":"https://insightsengineering.github.io/tern/reference/estimate_multinomial_rsp.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"analyze & summarize function estimate_multinomial_response() creates layout element estimate proportion proportion confidence interval level factor variable. primary analysis variable, var, factor variable, values used labels within output table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_multinomial_rsp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"","code":"estimate_multinomial_response( lyt, var, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"hidden\", table_names = var, .stats = \"prop_ci\", .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_length_proportion(x, .N_col, ...) a_length_proportion(x, .N_col, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/estimate_multinomial_rsp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n_prop', 'prop_ci' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_multinomial_rsp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"estimate_multinomial_response() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_length_proportion() table layout. s_length_proportion() returns statistics s_proportion(). a_length_proportion() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_multinomial_rsp.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"estimate_multinomial_response(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze() rtables::summarize_row_groups(). s_length_proportion(): Statistics function feeds length x number successes, .N_col total number successes failures s_proportion(). a_length_proportion(): Formatted analysis function used afun estimate_multinomial_response().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/estimate_multinomial_rsp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"","code":"library(dplyr) # Use of the layout creating function. dta_test <- data.frame( USUBJID = paste0(\"S\", 1:12), ARM = factor(rep(LETTERS[1:3], each = 4)), AVAL = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0)) ) %>% mutate( AVALC = factor(AVAL, levels = c(0, 1), labels = c(\"Complete Response (CR)\", \"Partial Response (PR)\") ) ) lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% estimate_multinomial_response(var = \"AVALC\") tbl <- build_table(lyt, dta_test) tbl #> A B C #> ————————————————————————————————————————————————————————————————————————————————————— #> Complete Response (CR) 0 (0.0%) 2 (50.0%) 4 (100.0%) #> 95% CI (Wald, with correction) (0.00, 12.50) (0.00, 100.00) (87.50, 100.00) #> Partial Response (PR) 4 (100.0%) 2 (50.0%) 0 (0.0%) #> 95% CI (Wald, with correction) (87.50, 100.00) (0.00, 100.00) (0.00, 12.50) s_length_proportion(rep(\"CR\", 10), .N_col = 100) #> $n_prop #> [1] 10.0 0.1 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> [1] 3.620108 16.379892 #> attr(,\"label\") #> [1] \"95% CI (Wald, with correction)\" #> s_length_proportion(factor(character(0)), .N_col = 100) #> $n_prop #> [1] 0 0 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> [1] 0.0 0.5 #> attr(,\"label\") #> [1] \"95% CI (Wald, with correction)\" #> a_length_proportion(rep(\"CR\", 10), .N_col = 100) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n_prop 10 (10.0%) 0 Responders #> 2 prop_ci (3.62, 16.38) 0 95% CI (Wald, with correction) a_length_proportion(factor(character(0)), .N_col = 100) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n_prop 0 (0.0%) 0 Responders #> 2 prop_ci (0.00, 0.50) 0 95% CI (Wald, with correction)"},{"path":"https://insightsengineering.github.io/tern/reference/estimate_proportion.html","id":null,"dir":"Reference","previous_headings":"","what":"Proportion estimation — estimate_proportion","title":"Proportion estimation — estimate_proportion","text":"analyze function estimate_proportion() creates layout element estimate proportion responders within studied population. primary analysis variable, vars, indicates whether response occurred record. See method parameter options methods use constructing confidence interval proportion. Additionally, stratification variable can supplied via strata element variables argument.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_proportion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Proportion estimation — estimate_proportion","text":"","code":"estimate_proportion( lyt, vars, conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"clopper-pearson\", \"wilson\", \"wilsonc\", \"strat_wilson\", \"strat_wilsonc\", \"agresti-coull\", \"jeffreys\"), weights = NULL, max_iterations = 50, variables = list(strata = NULL), long = FALSE, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"hidden\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_proportion( df, .var, conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"clopper-pearson\", \"wilson\", \"wilsonc\", \"strat_wilson\", \"strat_wilsonc\", \"agresti-coull\", \"jeffreys\"), weights = NULL, max_iterations = 50, variables = list(strata = NULL), long = FALSE ) a_proportion( df, .var, conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"clopper-pearson\", \"wilson\", \"wilsonc\", \"strat_wilson\", \"strat_wilsonc\", \"agresti-coull\", \"jeffreys\"), weights = NULL, max_iterations = 50, variables = list(strata = NULL), long = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/estimate_proportion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Proportion estimation — estimate_proportion","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . conf_level (proportion) confidence level interval. method (string) method used construct confidence interval proportion successful outcomes; one waldcc, wald, clopper-pearson, wilson, wilsonc, strat_wilson, strat_wilsonc, agresti-coull jeffreys. weights (numeric NULL) weights level strata. NULL, estimated using iterative algorithm proposed Yan2010-jt;textualtern minimizes weighted squared length confidence interval. max_iterations (count) maximum number iterations iterative procedure used find estimates optimal weights. variables (named list string) list additional analysis variables. long (flag) whether long description required. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n_prop', 'prop_ci' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (logical data.frame) logical vector used, indicates whether subject responder . TRUE represents successful outcome. data.frame provided, also strata variable names must provided variables list element strata strings. case data.frame, logical vector responses must indicated variable name .var. .var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_proportion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Proportion estimation — estimate_proportion","text":"estimate_proportion() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_proportion() table layout. s_proportion() returns statistics n_prop (n proportion) prop_ci (proportion CI) given variable. a_proportion() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/estimate_proportion.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Proportion estimation — estimate_proportion","text":"estimate_proportion(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_proportion(): Statistics function estimating proportion along confidence interval. a_proportion(): Formatted analysis function used afun estimate_proportion().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/estimate_proportion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Proportion estimation — estimate_proportion","text":"","code":"dta_test <- data.frame( USUBJID = paste0(\"S\", 1:12), ARM = rep(LETTERS[1:3], each = 4), AVAL = rep(LETTERS[1:3], each = 4) ) basic_table() %>% split_cols_by(\"ARM\") %>% estimate_proportion(vars = \"AVAL\") %>% build_table(df = dta_test) #> A B C #> —————————————————————————————————————————————————————————————————— #> Responders #> 95% CI (Wald, with correction) # Case with only logical vector. rsp_v <- c(1, 0, 1, 0, 1, 1, 0, 0) s_proportion(rsp_v) #> $n_prop #> [1] 4.0 0.5 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> [1] 9.102404 90.897596 #> attr(,\"label\") #> [1] \"95% CI (Wald, with correction)\" #> # Example for Stratified Wilson CI nex <- 100 # Number of example rows dta <- data.frame( \"rsp\" = sample(c(TRUE, FALSE), nex, TRUE), \"grp\" = sample(c(\"A\", \"B\"), nex, TRUE), \"f1\" = sample(c(\"a1\", \"a2\"), nex, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), nex, TRUE), stringsAsFactors = TRUE ) s_proportion( df = dta, .var = \"rsp\", variables = list(strata = c(\"f1\", \"f2\")), conf_level = 0.90, method = \"strat_wilson\" ) #> $n_prop #> [1] 49.00 0.49 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> lower upper #> 40.80675 56.65017 #> attr(,\"label\") #> [1] \"90% CI (Stratified Wilson, without correction)\" #>"},{"path":"https://insightsengineering.github.io/tern/reference/ex_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulated CDISC data for examples — ex_data","title":"Simulated CDISC data for examples — ex_data","text":"Simulated CDISC data examples","code":""},{"path":"https://insightsengineering.github.io/tern/reference/ex_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulated CDISC data for examples — ex_data","text":"","code":"tern_ex_adsl tern_ex_adae tern_ex_adlb tern_ex_adpp tern_ex_adrs tern_ex_adtte"},{"path":"https://insightsengineering.github.io/tern/reference/ex_data.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Simulated CDISC data for examples — ex_data","text":"rds (data.frame) object class tbl_df (inherits tbl, data.frame) 200 rows 21 columns. object class tbl_df (inherits tbl, data.frame) 541 rows 42 columns. object class tbl_df (inherits tbl, data.frame) 4200 rows 50 columns. object class tbl_df (inherits tbl, data.frame) 522 rows 25 columns. object class tbl_df (inherits tbl, data.frame) 1600 rows 29 columns. object class tbl_df (inherits tbl, data.frame) 1000 rows 28 columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/ex_data.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Simulated CDISC data for examples — ex_data","text":"tern_ex_adsl: ADSL data tern_ex_adae: ADAE data tern_ex_adlb: ADLB data tern_ex_adpp: ADPP data tern_ex_adrs: ADRS data tern_ex_adtte: ADTTE data","code":""},{"path":"https://insightsengineering.github.io/tern/reference/explicit_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Missing data — explicit_na","title":"Missing data — explicit_na","text":"Substitute missing data string factor level.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/explicit_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Missing data — explicit_na","text":"","code":"explicit_na(x, label = \"\")"},{"path":"https://insightsengineering.github.io/tern/reference/explicit_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Missing data — explicit_na","text":"x (factor character) values missing values substituted. label (string) string missing data replaced .","code":""},{"path":"https://insightsengineering.github.io/tern/reference/explicit_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Missing data — explicit_na","text":"x NA values substituted label.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/explicit_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Missing data — explicit_na","text":"","code":"explicit_na(c(NA, \"a\", \"b\")) #> [1] \"\" \"a\" \"b\" is.na(explicit_na(c(NA, \"a\", \"b\"))) #> [1] FALSE FALSE FALSE explicit_na(factor(c(NA, \"a\", \"b\"))) #> [1] a b #> Levels: a b is.na(explicit_na(factor(c(NA, \"a\", \"b\")))) #> [1] FALSE FALSE FALSE explicit_na(sas_na(c(\"a\", \"\"))) #> [1] \"a\" \"\""},{"path":"https://insightsengineering.github.io/tern/reference/extract_by_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract elements by name — extract_by_name","title":"Extract elements by name — extract_by_name","text":"utility function extracts elements vector x names. Differences standard [ function :","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_by_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract elements by name — extract_by_name","text":"","code":"extract_by_name(x, names)"},{"path":"https://insightsengineering.github.io/tern/reference/extract_by_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract elements by name — extract_by_name","text":"x (named vector) extract named elements . names (character) vector names extract.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_by_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract elements by name — extract_by_name","text":"NULL x NULL, otherwise extracted elements x.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_by_name.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract elements by name — extract_by_name","text":"x NULL, still always NULL returned (base function). x NULL, intersection names made names elements returned. , names appear x returned NAs.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_biomarkers.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"Prepares estimates number responses, patients overall response rate, well odds ratio estimates, confidence intervals p-values, multiple biomarkers across population subgroups single data frame. variables corresponds names variables found data, passed named list requires elements rsp biomarkers (vector continuous biomarker variables) optionally covariates, subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_biomarkers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"","code":"extract_rsp_biomarkers( variables, data, groups_lists = list(), control = control_logistic(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_biomarkers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (named list) controls response definition confidence level produced control_logistic(). label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_biomarkers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"data.frame columns biomarker, biomarker_label, n_tot, n_rsp, prop, , lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_biomarkers.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"can also specify continuous variable rsp use response_definition control convert internally logical variable reflecting binary response.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_biomarkers.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% mutate(rsp = AVALC == \"CR\") # Typical analysis of two continuous biomarkers `BMRKR1` and `AGE`, # in logistic regression models with one covariate `RACE`. The subgroups # are defined by the levels of `BMRKR2`. df <- extract_rsp_biomarkers( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", subgroups = \"BMRKR2\" ), data = adrs_f ) df #> biomarker biomarker_label n_tot n_rsp prop or #> 1 BMRKR1 Continuous Level Biomarker 1 200 164 0.8200000 0.9755036 #> 2 AGE Age 200 164 0.8200000 0.9952416 #> 3 BMRKR1 Continuous Level Biomarker 1 70 53 0.7571429 1.1524547 #> 4 AGE Age 70 53 0.7571429 0.9261012 #> 5 BMRKR1 Continuous Level Biomarker 1 68 58 0.8529412 0.8773122 #> 6 AGE Age 68 58 0.8529412 0.9867104 #> 7 BMRKR1 Continuous Level Biomarker 1 62 53 0.8548387 0.8792921 #> 8 AGE Age 62 53 0.8548387 1.0630262 #> lcl ucl conf_level pval pval_label subgroup var #> 1 0.8804862 1.080775 0.95 0.6352602 p-value (Wald) All Patients ALL #> 2 0.9462617 1.046757 0.95 0.8530389 p-value (Wald) All Patients ALL #> 3 0.9462127 1.403650 0.95 0.1584187 p-value (Wald) LOW BMRKR2 #> 4 0.8487519 1.010500 0.95 0.0844837 p-value (Wald) LOW BMRKR2 #> 5 0.7277189 1.057657 0.95 0.1699778 p-value (Wald) MEDIUM BMRKR2 #> 6 0.8798911 1.106498 0.95 0.8189816 p-value (Wald) MEDIUM BMRKR2 #> 7 0.7189748 1.075357 0.95 0.2103709 p-value (Wald) HIGH BMRKR2 #> 8 0.9595973 1.177603 0.95 0.2418840 p-value (Wald) HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Continuous Level Biomarker 2 analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis # Here we group the levels of `BMRKR2` manually, and we add a stratification # variable `STRATA1`. We also here use a continuous variable `EOSDY` # which is then binarized internally (response is defined as this variable # being larger than 750). df_grouped <- extract_rsp_biomarkers( variables = list( rsp = \"EOSDY\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", subgroups = \"BMRKR2\", strata = \"STRATA1\" ), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ), control = control_logistic( response_definition = \"I(response > 750)\" ) ) df_grouped #> biomarker biomarker_label n_tot n_rsp prop or lcl ucl conf_level #> 1 BMRKR1 Continuous Level Biomarker 1 200 0 0 NA NA NA 0.95 #> 2 AGE Age 200 0 0 NA NA NA 0.95 #> 3 BMRKR1 Continuous Level Biomarker 1 70 0 0 NA NA NA 0.95 #> 4 AGE Age 70 0 0 NA NA NA 0.95 #> 5 BMRKR1 Continuous Level Biomarker 1 138 0 0 NA NA NA 0.95 #> 6 AGE Age 138 0 0 NA NA NA 0.95 #> 7 BMRKR1 Continuous Level Biomarker 1 200 0 0 NA NA NA 0.95 #> 8 AGE Age 200 0 0 NA NA NA 0.95 #> pval pval_label subgroup var var_label #> 1 NA p-value (Wald) All Patients ALL All Patients #> 2 NA p-value (Wald) All Patients ALL All Patients #> 3 NA p-value (Wald) low BMRKR2 Continuous Level Biomarker 2 #> 4 NA p-value (Wald) low BMRKR2 Continuous Level Biomarker 2 #> 5 NA p-value (Wald) low/medium BMRKR2 Continuous Level Biomarker 2 #> 6 NA p-value (Wald) low/medium BMRKR2 Continuous Level Biomarker 2 #> 7 NA p-value (Wald) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> 8 NA p-value (Wald) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 content #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis #> 7 analysis #> 8 analysis"},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"Prepares response rates odds ratios population subgroups data frames. Simple wrapper h_odds_ratio_subgroups_df() h_proportion_subgroups_df(). Result list two data.frames: prop . variables corresponds names variables found data, passed named list requires elements rsp, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"","code":"extract_rsp_subgroups( variables, data, groups_lists = list(), conf_level = 0.95, method = NULL, label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. conf_level (proportion) confidence level interval. method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed. label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_rsp_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"named list two elements: prop: data.frame containing columns arm, n, n_rsp, prop, subgroup, var, var_label, row_type. : data.frame containing columns arm, n_tot, , lcl, ucl, conf_level, subgroup, var, var_label, row_type.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_biomarkers.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"Prepares estimates number events, patients median survival times, well hazard ratio estimates, confidence intervals p-values, multiple biomarkers across population subgroups single data frame. variables corresponds names variables found data, passed named list requires elements tte, is_event, biomarkers (vector continuous biomarker variables), optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_biomarkers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"","code":"extract_survival_biomarkers( variables, data, groups_lists = list(), control = control_coxreg(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_biomarkers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (list) list parameters returned helper function control_coxreg(). label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_biomarkers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"data.frame columns biomarker, biomarker_label, n_tot, n_tot_events, median, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"Prepares estimates median survival times treatment hazard ratios population subgroups data frames. Simple wrapper h_survtime_subgroups_df() h_coxph_subgroups_df(). Result list two data.frames: survtime hr. variables corresponds names variables found data, passed named list requires elements tte, is_event, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"","code":"extract_survival_subgroups( variables, data, groups_lists = list(), control = control_coxph(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing null hypothesis hazard ratio = 1. Default method \"log-rank\" comes survival::survdiff(), can also set \"wald\" \"likelihood\" (survival::coxph()). ties (string) specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval HR. label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extract_survival_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"named list two elements: survtime: data.frame containing columns arm, n, n_events, median, subgroup, var, var_label, row_type. hr: data.frame containing columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Format extreme values — extreme_format","title":"Format extreme values — extreme_format","text":"rtables formatting functions handle extreme values.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format extreme values — extreme_format","text":"","code":"h_get_format_threshold(digits = 2L) h_format_threshold(x, digits = 2L)"},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format extreme values — extreme_format","text":"digits (integer(1)) number decimal places display. x (numeric(1)) value format.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format extreme values — extreme_format","text":"h_get_format_threshold() returns list 2 elements: threshold, low high thresholds, format_string, thresholds formatted strings. h_format_threshold() returns given value, value within digit threshold relation given value digit threshold, formatted string.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Format extreme values — extreme_format","text":"input, apply format specified number digits. value threshold, returns \"<0.01\" e.g. number digits 2. value threshold, returns \">999.99\" e.g. number digits 2. zero, returns \"0.00\".","code":""},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Format extreme values — extreme_format","text":"h_get_format_threshold(): Internal helper function calculate threshold create formatted strings used Formatting Functions. Returns list elements threshold format_string. h_format_threshold(): Internal helper function apply threshold format value. Creates formatted string used Formatting Functions.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/extreme_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format extreme values — extreme_format","text":"","code":"h_get_format_threshold(2L) #> $threshold #> low high #> 0.01 999.99 #> #> $format_string #> low high #> \"<0.01\" \">999.99\" #> h_format_threshold(0.001) #> [1] \"<0.01\" h_format_threshold(1000) #> [1] \">999.99\""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/f_conf_level.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to create label for confidence interval — f_conf_level","text":"","code":"f_conf_level(conf_level)"},{"path":"https://insightsengineering.github.io/tern/reference/f_conf_level.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to create label for confidence interval — f_conf_level","text":"conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/f_conf_level.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to create label for confidence interval — f_conf_level","text":"string.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/f_pval.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to create label for p-value — f_pval","text":"","code":"f_pval(test_mean)"},{"path":"https://insightsengineering.github.io/tern/reference/f_pval.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to create label for p-value — f_pval","text":"test_mean (numeric(1)) mean value test null hypothesis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/f_pval.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to create label for p-value — f_pval","text":"string.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_collapse_only.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse factor levels and keep only those new group levels — fct_collapse_only","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"collapses levels keeps new group levels, order provided. returned factor levels order given, possible missing level last (included missing values).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_collapse_only.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"","code":"fct_collapse_only(.f, ..., .na_level = \"\")"},{"path":"https://insightsengineering.github.io/tern/reference/fct_collapse_only.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":".f (factor character) original vector. ... (named character) levels vector provided collapsed new level given respective name. .na_level (string) level use levels, missing new factor. Note level must contained new levels specified ....","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_collapse_only.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"modified factor collapsed levels. Values levels included given character vector input set missing level .na_level.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_collapse_only.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"existing NAs input vector replaced missing level. needed, explicit_na() can called separately result.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/fct_collapse_only.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"","code":"fct_collapse_only(factor(c(\"a\", \"b\", \"c\", \"d\")), TRT = \"b\", CTRL = c(\"c\", \"d\")) #> [1] TRT CTRL CTRL #> Levels: TRT CTRL "},{"path":"https://insightsengineering.github.io/tern/reference/fct_discard.html","id":null,"dir":"Reference","previous_headings":"","what":"Discard specified levels of a factor — fct_discard","title":"Discard specified levels of a factor — fct_discard","text":"discards observations well levels specified factor.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_discard.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Discard specified levels of a factor — fct_discard","text":"","code":"fct_discard(x, discard)"},{"path":"https://insightsengineering.github.io/tern/reference/fct_discard.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Discard specified levels of a factor — fct_discard","text":"x (factor) original factor. discard (character) levels discard.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_discard.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Discard specified levels of a factor — fct_discard","text":"modified factor observations well levels discard dropped.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_discard.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Discard specified levels of a factor — fct_discard","text":"","code":"fct_discard(factor(c(\"a\", \"b\", \"c\")), \"c\") #> [1] a b #> Levels: a b"},{"path":"https://insightsengineering.github.io/tern/reference/fct_explicit_na_if.html","id":null,"dir":"Reference","previous_headings":"","what":"Insertion of explicit missing values in a factor — fct_explicit_na_if","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"inserts explicit missing values factor based condition. Additionally, existing NA values explicitly converted given na_level.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_explicit_na_if.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"","code":"fct_explicit_na_if(x, condition, na_level = \"\")"},{"path":"https://insightsengineering.github.io/tern/reference/fct_explicit_na_if.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"x (factor) original factor. condition (logical) positions insert missing values. na_level (string) level use missing values.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fct_explicit_na_if.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"modified factor inserted existing NA converted na_level.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/fct_explicit_na_if.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"","code":"fct_explicit_na_if(factor(c(\"a\", \"b\", NA)), c(TRUE, FALSE, FALSE)) #> [1] b #> Levels: a b "},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":null,"dir":"Reference","previous_headings":"","what":"Fitting functions for Cox proportional hazards regression — fit_coxreg","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"Fitting functions univariate multivariate Cox regression models.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"","code":"fit_coxreg_univar(variables, data, at = list(), control = control_coxreg()) fit_coxreg_multivar(variables, data, control = control_coxreg())"},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"variables (named list) names variables found data, passed named list corresponding time, event, arm, strata, covariates terms. arm missing variables, Cox model(s) including covariates fitted corresponding effect estimates tabulated later. data (data.frame) dataset containing variables fit models. (list numeric) candidate covariate numeric, use specify value covariate effect estimated. control (list) list parameters returned helper function control_coxreg().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"fit_coxreg_univar() returns coxreg.univar class object named list 5 elements: mod: Cox regression models fitted survival::coxph(). data: original data frame input. control: original control input. vars: variables used model. : Value covariate effect estimated. fit_coxreg_multivar() returns coxreg.multivar class object named list 4 elements: mod: Cox regression model fitted survival::coxph(). data: original data frame input. control: original control input. vars: variables used model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"fit_coxreg_univar(): Fit series univariate Cox regression models given inputs. fit_coxreg_multivar(): Fit multivariate Cox regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"using fit_coxreg_univar two study arms.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/fit_coxreg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"","code":"library(survival) set.seed(1, kind = \"Mersenne-Twister\") # Testing dataset [survival::bladder]. dta_bladder <- with( data = bladder[bladder$enum < 5, ], data.frame( time = stop, status = event, armcd = as.factor(rx), covar1 = as.factor(enum), covar2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) ) ) labels <- c(\"armcd\" = \"ARM\", \"covar1\" = \"A Covariate Label\", \"covar2\" = \"Sex (F/M)\") formatters::var_labels(dta_bladder)[names(labels)] <- labels dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) plot( survfit(Surv(time, status) ~ armcd + covar1, data = dta_bladder), lty = 2:4, xlab = \"Months\", col = c(\"blue1\", \"blue2\", \"blue3\", \"blue4\", \"red1\", \"red2\", \"red3\", \"red4\") ) # fit_coxreg_univar ## Cox regression: arm + 1 covariate. mod1 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = \"covar1\" ), data = dta_bladder, control = control_coxreg(conf_level = 0.91) ) ## Cox regression: arm + 1 covariate + interaction, 2 candidate covariates. mod2 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder, control = control_coxreg(conf_level = 0.91, interaction = TRUE) ) ## Cox regression: arm + 1 covariate, stratified analysis. mod3 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", strata = \"covar2\", covariates = c(\"covar1\") ), data = dta_bladder, control = control_coxreg(conf_level = 0.91) ) ## Cox regression: no arm, only covariates. mod4 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder ) # fit_coxreg_multivar ## Cox regression: multivariate Cox regression. multivar_model <- fit_coxreg_multivar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder ) # Example without treatment arm. multivar_covs_model <- fit_coxreg_multivar( variables = list( time = \"time\", event = \"status\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder )"},{"path":"https://insightsengineering.github.io/tern/reference/fit_logistic.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit for logistic regression — fit_logistic","title":"Fit for logistic regression — fit_logistic","text":"Fit (conditional) logistic regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_logistic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit for logistic regression — fit_logistic","text":"","code":"fit_logistic( data, variables = list(response = \"Response\", arm = \"ARMCD\", covariates = NULL, interaction = NULL, strata = NULL), response_definition = \"response\" )"},{"path":"https://insightsengineering.github.io/tern/reference/fit_logistic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit for logistic regression — fit_logistic","text":"data (data.frame) data frame model fit. variables (named list string) list additional analysis variables. response_definition (string) definition event terms response. used fitting (conditional) logistic regression model left hand side formula.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_logistic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit for logistic regression — fit_logistic","text":"fitted logistic regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_logistic.html","id":"model-specification","dir":"Reference","previous_headings":"","what":"Model Specification","title":"Fit for logistic regression — fit_logistic","text":"variables list needs include following elements: arm: Treatment arm variable name. response: response arm variable name. Usually 0/1 variable. covariates: either NULL (covariates) character vector covariate variable names. interaction: either NULL (interaction) string single covariate variable name already included covariates. interaction treatment arm included model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_logistic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fit for logistic regression — fit_logistic","text":"","code":"library(dplyr) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred"},{"path":"https://insightsengineering.github.io/tern/reference/fit_rsp_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"fits Subgroup Treatment Effect Pattern logistic regression models binary (response) outcome. treatment arm variable must exactly 2 levels, first one taken reference estimated odds ratios comparison second level vs. first one. (conditional) logistic regression model fit : response ~ arm * poly(biomarker, degree) + covariates + strata(strata) degree specified control_step().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_rsp_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"","code":"fit_rsp_step(variables, data, control = c(control_step(), control_logistic()))"},{"path":"https://insightsengineering.github.io/tern/reference/fit_rsp_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"variables (named list character) list analysis variables: needs response, arm, biomarker, optional covariates strata. data (data.frame) dataset containing variables summarize. control (named list) combined control list control_step() control_logistic().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_rsp_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"matrix class step. first part columns describe subgroup intervals used biomarker variable, including center intervals bounds. second part columns contain estimates treatment arm comparison.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_rsp_step.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"default degree 0 biomarker variable included model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/fit_rsp_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"","code":"# Testing dataset with just two treatment arms. library(survival) library(dplyr) adrs_f <- tern_ex_adrs %>% filter( PARAMCD == \"BESRSPI\", ARM %in% c(\"B: Placebo\", \"A: Drug X\") ) %>% mutate( # Reorder levels of ARM to have Placebo as reference arm for Odds Ratio calculations. ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")), RSP = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), SEX = factor(SEX) ) variables <- list( arm = \"ARM\", biomarker = \"BMRKR1\", covariates = \"AGE\", response = \"RSP\" ) # Fit default STEP models: Here a constant treatment effect is estimated in each subgroup. # We use a large enough bandwidth to avoid too small subgroups and linear separation in those. step_matrix <- fit_rsp_step( variables = variables, data = adrs_f, control = c(control_logistic(), control_step(bandwidth = 0.9)) ) dim(step_matrix) #> [1] 39 11 head(step_matrix) #> Percentile Center Percentile Lower Percentile Upper Interval Center #> [1,] 0.025 0 0.925 1.472755 #> [2,] 0.050 0 0.950 2.028546 #> [3,] 0.075 0 0.975 2.204086 #> [4,] 0.100 0 1.000 2.799776 #> [5,] 0.125 0 1.000 2.969998 #> [6,] 0.150 0 1.000 3.149068 #> Interval Lower Interval Upper n logor se ci_lower ci_upper #> [1,] 0.4459546 11.74529 131 1.835008 1.134560 -0.3886885 4.058703 #> [2,] 0.4459546 12.73387 134 1.895158 1.136248 -0.3318481 4.122163 #> [3,] 0.4459546 14.75099 138 1.947699 1.136969 -0.2807193 4.176116 #> [4,] 0.4459546 18.49236 142 1.931001 1.135866 -0.2952561 4.157258 #> [5,] 0.4459546 18.49236 142 1.931001 1.135866 -0.2952561 4.157258 #> [6,] 0.4459546 18.49236 142 1.931001 1.135866 -0.2952561 4.157258 # Specify different polynomial degree for the biomarker interaction to use more flexible local # models. Or specify different logistic regression options, including confidence level. step_matrix2 <- fit_rsp_step( variables = variables, data = adrs_f, control = c(control_logistic(conf_level = 0.9), control_step(bandwidth = NULL, degree = 1)) ) # Use a global constant model. This is helpful as a reference for the subgroup models. step_matrix3 <- fit_rsp_step( variables = variables, data = adrs_f, control = c(control_logistic(), control_step(bandwidth = NULL, num_points = 2L)) ) # It is also possible to use strata, i.e. use conditional logistic regression models. variables2 <- list( arm = \"ARM\", biomarker = \"BMRKR1\", covariates = \"AGE\", response = \"RSP\", strata = c(\"STRATA1\", \"STRATA2\") ) step_matrix4 <- fit_rsp_step( variables = variables2, data = adrs_f, control = c(control_logistic(), control_step(bandwidth = NULL)) )"},{"path":"https://insightsengineering.github.io/tern/reference/fit_survival_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"fits subgroup treatment effect pattern (STEP) models survival outcome. treatment arm variable must exactly 2 levels, first one taken reference estimated hazard ratios comparison second level vs. first one. model fit : Surv(time, event) ~ arm * poly(biomarker, degree) + covariates + strata(strata) degree specified control_step().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_survival_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"","code":"fit_survival_step( variables, data, control = c(control_step(), control_coxph()) )"},{"path":"https://insightsengineering.github.io/tern/reference/fit_survival_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"variables (named list character) list analysis variables: needs time, event, arm, biomarker, optional covariates strata. data (data.frame) dataset containing variables summarize. control (named list) combined control list control_step() control_coxph().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_survival_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"matrix class step. first part columns describe subgroup intervals used biomarker variable, including center intervals bounds. second part columns contain estimates treatment arm comparison.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/fit_survival_step.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"default degree 0 biomarker variable included model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/fit_survival_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"","code":"# Testing dataset with just two treatment arms. library(dplyr) adtte_f <- tern_ex_adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")), is_event = CNSR == 0 ) labels <- c(\"ARM\" = \"Treatment Arm\", \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels variables <- list( arm = \"ARM\", biomarker = \"BMRKR1\", covariates = c(\"AGE\", \"BMRKR2\"), event = \"is_event\", time = \"AVAL\" ) # Fit default STEP models: Here a constant treatment effect is estimated in each subgroup. step_matrix <- fit_survival_step( variables = variables, data = adtte_f ) dim(step_matrix) #> [1] 39 12 head(step_matrix) #> Percentile Center Percentile Lower Percentile Upper Interval Center #> [1,] 0.025 0 0.275 1.472755 #> [2,] 0.050 0 0.300 2.028546 #> [3,] 0.075 0 0.325 2.204086 #> [4,] 0.100 0 0.350 2.799776 #> [5,] 0.125 0 0.375 2.969998 #> [6,] 0.150 0 0.400 3.149068 #> Interval Lower Interval Upper n events loghr se ci_lower #> [1,] 0.4459546 4.182444 39 29 0.03729601 0.4243013 -0.7943192 #> [2,] 0.4459546 4.349471 43 31 0.23246622 0.3881347 -0.5282639 #> [3,] 0.4459546 4.626913 46 32 0.07952492 0.3813113 -0.6678314 #> [4,] 0.4459546 4.805767 50 35 0.09020455 0.3638368 -0.6229026 #> [5,] 0.4459546 4.929816 53 37 0.15522702 0.3477999 -0.5264483 #> [6,] 0.4459546 5.020539 57 41 0.11135760 0.3332843 -0.5418676 #> ci_upper #> [1,] 0.8689112 #> [2,] 0.9931963 #> [3,] 0.8268813 #> [4,] 0.8033117 #> [5,] 0.8369023 #> [6,] 0.7645828 # Specify different polynomial degree for the biomarker interaction to use more flexible local # models. Or specify different Cox regression options. step_matrix2 <- fit_survival_step( variables = variables, data = adtte_f, control = c(control_coxph(conf_level = 0.9), control_step(degree = 2)) ) # Use a global model with cubic interaction and only 5 points. step_matrix3 <- fit_survival_step( variables = variables, data = adtte_f, control = c(control_coxph(), control_step(bandwidth = NULL, degree = 3, num_points = 5L)) )"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/forest_viewport.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a viewport tree for the forest plot — forest_viewport","text":"","code":"forest_viewport( tbl, width_row_names = NULL, width_columns = NULL, width_forest = grid::unit(1, \"null\"), gap_column = grid::unit(1, \"lines\"), gap_header = grid::unit(1, \"lines\"), mat_form = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/forest_viewport.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a viewport tree for the forest plot — forest_viewport","text":"tbl (VTableTree)rtables table object. width_row_names (grid::unit) width row names. width_columns (grid::unit) width column spans. width_forest (grid::unit) width forest plot. gap_column (grid::unit) gap width columns. gap_header (grid::unit) gap width header. mat_form (MatrixPrintForm) matrix print form table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/forest_viewport.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a viewport tree for the forest plot — forest_viewport","text":"viewport tree.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/forest_viewport.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a viewport tree for the forest plot — forest_viewport","text":"","code":"library(grid) tbl <- rtable( header = rheader( rrow(\"\", \"E\", rcell(\"CI\", colspan = 2)), rrow(\"\", \"A\", \"B\", \"C\") ), rrow(\"row 1\", 1, 0.8, 1.1), rrow(\"row 2\", 1.4, 0.8, 1.6), rrow(\"row 3\", 1.2, 0.8, 1.2) ) # \\donttest{ v <- forest_viewport(tbl) #> Warning: `forest_viewport()` was deprecated in tern 0.9.4. #> ℹ `g_forest` now generates `ggplot` objects. This function is no longer used #> within `tern`. #> Warning: `vp_forest_table_part()` was deprecated in tern 0.9.4. #> ℹ `g_forest` now generates `ggplot` objects. This function is no longer used #> within `tern`. #> ℹ The deprecated feature was likely used in the tern package. #> Please report the issue at #> . grid::grid.newpage() showViewport(v) # }"},{"path":"https://insightsengineering.github.io/tern/reference/format_auto.html","id":null,"dir":"Reference","previous_headings":"","what":"Format automatically using data significant digits — format_auto","title":"Format automatically using data significant digits — format_auto","text":"Formatting function majority default methods used analyze_vars(). non-derived values, significant digits data used (e.g. range), derived values one digits (measure location dispersion like mean, standard deviation). function can called internally \"auto\" like, example, .formats = c(\"mean\" = \"auto\"). See details see works inner function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_auto.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format automatically using data significant digits — format_auto","text":"","code":"format_auto(dt_var, x_stat)"},{"path":"https://insightsengineering.github.io/tern/reference/format_auto.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format automatically using data significant digits — format_auto","text":"dt_var (numeric) variable data statistics calculated . Used find significant digits. analyze_vars comes .df_row (see rtables::additional_fun_params), row data row splits. column split considered. x_stat (string) string indicating current statistical method used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_auto.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format automatically using data significant digits — format_auto","text":"string rtables prints table cell.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_auto.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Format automatically using data significant digits — format_auto","text":"internal function needed work rtables default structure format functions, .e. function(x, ...), x results statistical evaluation. can one element (e.g. .stats = \"mean_sd\").","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_auto.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format automatically using data significant digits — format_auto","text":"","code":"x_todo <- c(0.001, 0.2, 0.0011000, 3, 4) res <- c(mean(x_todo[1:3]), sd(x_todo[1:3])) # x is the result coming into the formatting function -> res!! format_auto(dt_var = x_todo, x_stat = \"mean_sd\")(x = res) #> [1] \"0.06737 (0.11486)\" format_auto(x_todo, \"range\")(x = range(x_todo)) #> [1] \"0.0010 - 4.0000\" no_sc_x <- c(0.0000001, 1) format_auto(no_sc_x, \"range\")(x = no_sc_x) #> [1] \"0.0000001 - 1.0000000\""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction.html","id":null,"dir":"Reference","previous_headings":"","what":"Format count and fraction — format_count_fraction","title":"Format count and fraction — format_count_fraction","text":"Formats count together fraction special consideration count 0.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format count and fraction — format_count_fraction","text":"","code":"format_count_fraction(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format count and fraction — format_count_fraction","text":"x (numeric(2)) vector length 2 count fraction, respectively. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format count and fraction — format_count_fraction","text":"string format count (fraction %). count 0, format 0.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format count and fraction — format_count_fraction","text":"","code":"format_count_fraction(x = c(2, 0.6667)) #> [1] \"2 (66.7%)\" format_count_fraction(x = c(0, 0)) #> [1] \"0\""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_fixed_dp.html","id":null,"dir":"Reference","previous_headings":"","what":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"Formats count together fraction special consideration count 0.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_fixed_dp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"","code":"format_count_fraction_fixed_dp(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_fixed_dp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"x (numeric(2)) vector length 2 count fraction, respectively. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_fixed_dp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"string format count (fraction %). count 0, format 0.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_fixed_dp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"","code":"format_count_fraction_fixed_dp(x = c(2, 0.6667)) #> [1] \"2 (66.7%)\" format_count_fraction_fixed_dp(x = c(2, 0.5)) #> [1] \"2 (50.0%)\" format_count_fraction_fixed_dp(x = c(0, 0)) #> [1] \"0\""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_lt10.html","id":null,"dir":"Reference","previous_headings":"","what":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"Formats count together fraction special consideration count less 10.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_lt10.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"","code":"format_count_fraction_lt10(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_lt10.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"x (numeric(2)) vector length 2 count fraction, respectively. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_lt10.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"string format count (fraction %). count less 10, count printed.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_count_fraction_lt10.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"","code":"format_count_fraction_lt10(x = c(275, 0.9673)) #> [1] \"275 (96.7%)\" format_count_fraction_lt10(x = c(2, 0.6667)) #> [1] \"2\" format_count_fraction_lt10(x = c(9, 1)) #> [1] \"9\""},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values.html","id":null,"dir":"Reference","previous_headings":"","what":"Format a single extreme value — format_extreme_values","title":"Format a single extreme value — format_extreme_values","text":"Create formatting function single extreme value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format a single extreme value — format_extreme_values","text":"","code":"format_extreme_values(digits = 2L)"},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format a single extreme value — format_extreme_values","text":"digits (integer(1)) number decimal places display.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format a single extreme value — format_extreme_values","text":"rtables formatting function uses threshold digits return formatted extreme value.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format a single extreme value — format_extreme_values","text":"","code":"format_fun <- format_extreme_values(2L) format_fun(x = 0.127) #> [1] \"0.13\" format_fun(x = Inf) #> [1] \">999.99\" format_fun(x = 0) #> [1] \"0.00\" format_fun(x = 0.009) #> [1] \"<0.01\""},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Format extreme values part of a confidence interval — format_extreme_values_ci","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"Formatting Function extreme values part confidence interval. Values formatted e.g. \"(xx.xx, xx.xx)\" number digits 2.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"","code":"format_extreme_values_ci(digits = 2L)"},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"digits (integer(1)) number decimal places display.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"rtables formatting function uses threshold digits return formatted extreme values confidence interval.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_extreme_values_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"","code":"format_fun <- format_extreme_values_ci(2L) format_fun(x = c(0.127, Inf)) #> [1] \"(0.13, >999.99)\" format_fun(x = c(0, 0.009)) #> [1] \"(0.00, <0.01)\""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction.html","id":null,"dir":"Reference","previous_headings":"","what":"Format fraction and percentage — format_fraction","title":"Format fraction and percentage — format_fraction","text":"Formats fraction together ratio percent.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format fraction and percentage — format_fraction","text":"","code":"format_fraction(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format fraction and percentage — format_fraction","text":"x (named integer) vector elements num denom. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format fraction and percentage — format_fraction","text":"string format num / denom (ratio %). num 0, format num / denom.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format fraction and percentage — format_fraction","text":"","code":"format_fraction(x = c(num = 2L, denom = 3L)) #> [1] \"2/3 (66.7%)\" format_fraction(x = c(num = 0L, denom = 3L)) #> [1] \"0/3\""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_fixed_dp.html","id":null,"dir":"Reference","previous_headings":"","what":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"Formats fraction together ratio percent fixed single decimal place. Includes trailing zero case whole number percentages always keep one decimal place.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_fixed_dp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"","code":"format_fraction_fixed_dp(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_fixed_dp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"x (named integer) vector elements num denom. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_fixed_dp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"string format num / denom (ratio %). num 0, format num / denom.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_fixed_dp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"","code":"format_fraction_fixed_dp(x = c(num = 1L, denom = 2L)) #> [1] \"1/2 (50.0%)\" format_fraction_fixed_dp(x = c(num = 1L, denom = 4L)) #> [1] \"1/4 (25.0%)\" format_fraction_fixed_dp(x = c(num = 0L, denom = 3L)) #> [1] \"0/3\""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_threshold.html","id":null,"dir":"Reference","previous_headings":"","what":"Format fraction with lower threshold — format_fraction_threshold","title":"Format fraction with lower threshold — format_fraction_threshold","text":"Formats fraction second element input x fraction. applies lower threshold, just stated fraction smaller .","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_threshold.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format fraction with lower threshold — format_fraction_threshold","text":"","code":"format_fraction_threshold(threshold)"},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_threshold.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format fraction with lower threshold — format_fraction_threshold","text":"threshold (proportion) lower threshold.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_threshold.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format fraction with lower threshold — format_fraction_threshold","text":"rtables formatting function takes numeric input x second element fraction formatted. fraction equal threshold, displayed percentage. positive threshold, returns, e.g. \"<1\" threshold 0.01. zero, just \"0\" returned.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_fraction_threshold.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format fraction with lower threshold — format_fraction_threshold","text":"","code":"format_fun <- format_fraction_threshold(0.05) format_fun(x = c(20, 0.1)) #> [1] 10 format_fun(x = c(2, 0.01)) #> [1] \"<5\" format_fun(x = c(0, 0)) #> [1] \"0\""},{"path":"https://insightsengineering.github.io/tern/reference/format_sigfig.html","id":null,"dir":"Reference","previous_headings":"","what":"Format numeric values by significant figures — format_sigfig","title":"Format numeric values by significant figures — format_sigfig","text":"Format numeric values print specified number significant figures.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_sigfig.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format numeric values by significant figures — format_sigfig","text":"","code":"format_sigfig(sigfig, format = \"xx\", num_fmt = \"fg\")"},{"path":"https://insightsengineering.github.io/tern/reference/format_sigfig.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format numeric values by significant figures — format_sigfig","text":"sigfig (integer(1)) number significant figures display. format (string) format label (string) apply printing value. Decimal places string ignored favor formatting significant figures. Formats options : \"xx\", \"xx / xx\", \"(xx, xx)\", \"xx - xx\", \"xx (xx)\". num_fmt (string) numeric format modifiers apply value. Defaults \"fg\" standard significant figures formatting - fixed (non-scientific notation) format (\"f\") sigfig equal number significant figures instead decimal places (\"g\"). See formatC() format argument options.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_sigfig.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format numeric values by significant figures — format_sigfig","text":"rtables formatting function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_sigfig.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format numeric values by significant figures — format_sigfig","text":"","code":"fmt_3sf <- format_sigfig(3) fmt_3sf(1.658) #> [1] \"1.66\" fmt_3sf(1e1) #> [1] \"10.0\" fmt_5sf <- format_sigfig(5) fmt_5sf(0.57) #> [1] \"0.57000\" fmt_5sf(0.000025645) #> [1] \"0.000025645\""},{"path":"https://insightsengineering.github.io/tern/reference/format_xx.html","id":null,"dir":"Reference","previous_headings":"","what":"Format XX as a formatting function — format_xx","title":"Format XX as a formatting function — format_xx","text":"Translate string x dots interpreted number place holders, others formatting elements.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_xx.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format XX as a formatting function — format_xx","text":"","code":"format_xx(str)"},{"path":"https://insightsengineering.github.io/tern/reference/format_xx.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format XX as a formatting function — format_xx","text":"str (string) template.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/format_xx.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format XX as a formatting function — format_xx","text":"rtables formatting function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/format_xx.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format XX as a formatting function — format_xx","text":"","code":"test <- list(c(1.658, 0.5761), c(1e1, 785.6)) z <- format_xx(\"xx (xx.x)\") sapply(test, z) #> [1] \"2 (0.6)\" \"10 (785.6)\" z <- format_xx(\"xx.x - xx.x\") sapply(test, z) #> [1] \"1.7 - 0.6\" \"10 - 785.6\" z <- format_xx(\"xx.x, incl. xx.x% NE\") sapply(test, z) #> [1] \"1.7, incl. 0.6% NE\" \"10, incl. 785.6% NE\""},{"path":"https://insightsengineering.github.io/tern/reference/formatting_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Formatting functions — formatting_functions","title":"Formatting functions — formatting_functions","text":"See list formatting functions created tern work rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/formatting_functions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Formatting functions — formatting_functions","text":"available formats can listed via formatters::list_valid_format_labels(). Additional custom formats can created via formatters::sprintf_format() function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/g_bland_altman.html","id":null,"dir":"Reference","previous_headings":"","what":"Bland-Altman plot — g_bland_altman","title":"Bland-Altman plot — g_bland_altman","text":"Graphing function produces Bland-Altman plot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_bland_altman.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bland-Altman plot — g_bland_altman","text":"","code":"g_bland_altman(x, y, conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/reference/g_bland_altman.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bland-Altman plot — g_bland_altman","text":"x (numeric) vector numbers want analyze. y (numeric) vector numbers want analyze, compared x. conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_bland_altman.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bland-Altman plot — g_bland_altman","text":"ggplot Bland-Altman plot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_bland_altman.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Bland-Altman plot — g_bland_altman","text":"","code":"x <- seq(1, 60, 5) y <- seq(5, 50, 4) g_bland_altman(x = x, y = y, conf_level = 0.9)"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/g_forest.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a forest plot from an rtable — g_forest","text":"","code":"g_forest( tbl, col_x = attr(tbl, \"col_x\"), col_ci = attr(tbl, \"col_ci\"), vline = 1, forest_header = attr(tbl, \"forest_header\"), xlim = c(0.1, 10), logx = TRUE, x_at = c(0.1, 1, 10), width_row_names = lifecycle::deprecated(), width_columns = NULL, width_forest = lifecycle::deprecated(), lbl_col_padding = 0, rel_width_forest = 0.25, font_size = 12, col_symbol_size = attr(tbl, \"col_symbol_size\"), col = getOption(\"ggplot2.discrete.colour\")[1], ggtheme = NULL, as_list = FALSE, gp = lifecycle::deprecated(), draw = lifecycle::deprecated(), newpage = lifecycle::deprecated() )"},{"path":"https://insightsengineering.github.io/tern/reference/g_forest.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a forest plot from an rtable — g_forest","text":"tbl (VTableTree)rtables table least one column single value one column 2 values. col_x (integer(1) NULL) column index estimator. default tries get tbl attribute col_x, otherwise needs manually specified. NULL, points excluded forest plot. col_ci (integer(1) NULL) column index confidence intervals. default tries get tbl attribute col_ci, otherwise needs manually specified. NULL, lines excluded forest plot. vline (numeric(1) NULL) x coordinate vertical line, NULL line omitted. forest_header (character(2)) text displayed left right vline, respectively. vline = NULL forest_header printed. default tries get tbl attribute forest_header. NULL, defaults extracted table possible, set \"Comparison\\nBetter\" \"Treatment\\nBetter\" . xlim (numeric(2)) limits x axis. logx (flag) show x-values logarithm scale. x_at (numeric) x-tick locations, NULL, x_at set vline xlim values. width_row_names Please use lbl_col_padding argument instead. width_columns (numeric) vector column widths. element's position colwidths corresponds column tbl position. NULL, column widths calculated according maximum number characters per column. width_forest Please use rel_width_forest argument instead. lbl_col_padding (numeric) additional padding use calculating spacing first (label) column second column tbl. colwidths specified, width first column becomes colwidths[1] + lbl_col_padding. Defaults 0. rel_width_forest (proportion) proportion total width allocate forest plot. Relative width table 1 - rel_width_forest. as_list = TRUE, parameter ignored. font_size (numeric(1)) font size. col_symbol_size (numeric NULL) column index tbl containing data used determine relative size estimator plot symbol. Typically, symbol size proportional sample size used calculate estimator. NULL, symbol size used subgroups. default tries get tbl attribute col_symbol_size, otherwise needs manually specified. col (character) color(s). ggtheme (theme) graphical theme provided ggplot2 control styling plot. as_list (flag) whether two ggplot objects returned list. TRUE, named list two elements, table plot, returned. FALSE (default) table forest plot printed side--side via cowplot::plot_grid(). gp g_forest now generated ggplot object. argument longer used. draw g_forest now generated ggplot object. argument longer used. newpage g_forest now generated ggplot object. argument longer used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_forest.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a forest plot from an rtable — g_forest","text":"ggplot forest plot table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_forest.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a forest plot from an rtable — g_forest","text":"Given rtables::rtable() object least one column single value one column 2 values, converts table ggplot2::ggplot() object generates accompanying forest plot. table forest plot printed side--side.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_forest.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a forest plot from an rtable — g_forest","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs n_records <- 20 adrs_labels <- formatters::var_labels(adrs, fill = TRUE) adrs <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>% slice(seq_len(n_records)) %>% droplevels() %>% mutate( # Reorder levels of factor to make the placebo group the reference arm. ARM = fct_relevel(ARM, \"B: Placebo\"), rsp = AVALC == \"CR\" ) formatters::var_labels(adrs) <- c(adrs_labels, \"Response\") df <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"STRATA2\")), data = adrs ) # Full commonly used response table. tbl <- basic_table() %>% tabulate_rsp_subgroups(df) g_forest(tbl) # Odds ratio only table. tbl_or <- basic_table() %>% tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"or\", \"ci\")) g_forest( tbl_or, forest_header = c(\"Comparison\\nBetter\", \"Treatment\\nBetter\") ) # Survival forest plot example. adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte, fill = TRUE) adtte_f <- adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\"), SEX %in% c(\"M\", \"F\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(fct_relevel(ARM, \"B: Placebo\")), SEX = droplevels(SEX), AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- list( \"ARM\" = adtte_labels[\"ARM\"], \"SEX\" = adtte_labels[\"SEX\"], \"AVALU\" = adtte_labels[\"AVALU\"], \"is_event\" = \"Event Flag\" ) formatters::var_labels(adtte_f)[names(labels)] <- as.character(labels) df <- extract_survival_subgroups( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f ) table_hr <- basic_table() %>% tabulate_survival_subgroups(df, time_unit = adtte_f$AVALU[1]) g_forest(table_hr) # Works with any `rtable`. tbl <- rtable( header = c(\"E\", \"CI\", \"N\"), rrow(\"\", 1, c(.8, 1.2), 200), rrow(\"\", 1.2, c(1.1, 1.4), 50) ) g_forest( tbl = tbl, col_x = 1, col_ci = 2, xlim = c(0.5, 2), x_at = c(0.5, 1, 2), col_symbol_size = 3 ) tbl <- rtable( header = rheader( rrow(\"\", rcell(\"A\", colspan = 2)), rrow(\"\", \"c1\", \"c2\") ), rrow(\"row 1\", 1, c(.8, 1.2)), rrow(\"row 2\", 1.2, c(1.1, 1.4)) ) g_forest( tbl = tbl, col_x = 1, col_ci = 2, xlim = c(0.5, 2), x_at = c(0.5, 1, 2), vline = 1, forest_header = c(\"Hello\", \"World\") )"},{"path":"https://insightsengineering.github.io/tern/reference/g_ipp.html","id":null,"dir":"Reference","previous_headings":"","what":"Individual patient plots — g_ipp","title":"Individual patient plots — g_ipp","text":"Line plot(s) displaying trend patients' parameter values time rendered. Patients' individual baseline values can added plot(s) reference.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_ipp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Individual patient plots — g_ipp","text":"","code":"g_ipp( df, xvar, yvar, xlab, ylab, id_var = \"USUBJID\", title = \"Individual Patient Plots\", subtitle = \"\", caption = NULL, add_baseline_hline = FALSE, yvar_baseline = \"BASE\", ggtheme = nestcolor::theme_nest(), plotting_choices = c(\"all_in_one\", \"split_by_max_obs\", \"separate_by_obs\"), max_obs_per_plot = 4, col = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/g_ipp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Individual patient plots — g_ipp","text":"df (data.frame) data set containing analysis variables. xvar (string) time point variable plotted x-axis. yvar (string) continuous analysis variable plotted y-axis. xlab (string) plot label x-axis. ylab (string) plot label y-axis. id_var (string) variable used patient identifier. title (string) title plot. subtitle (string) subtitle plot. caption (string) optional caption plot. add_baseline_hline (flag) adds horizontal line baseline y-value plot TRUE. yvar_baseline (string) variable baseline values . Ignored add_baseline_hline FALSE. ggtheme (theme) optional graphical theme function provided ggplot2 control outlook plot. Use ggplot2::theme() tweak display. plotting_choices (string) specifies options displaying plots. Must one \"all_in_one\", \"split_by_max_obs\", \"separate_by_obs\". max_obs_per_plot (integer(1)) number observations plotted one plot. Ignored plotting_choices \"separate_by_obs\". col (character) line colors.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_ipp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Individual patient plots — g_ipp","text":"ggplot object list ggplot objects.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_ipp.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Individual patient plots — g_ipp","text":"g_ipp(): Plotting function individual patient plots , depending user preference, renders single graphic compiles list graphics show trends individual's parameter values time.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/g_ipp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Individual patient plots — g_ipp","text":"","code":"library(dplyr) # Select a small sample of data to plot. adlb <- tern_ex_adlb %>% filter(PARAMCD == \"ALT\", !(AVISIT %in% c(\"SCREENING\", \"BASELINE\"))) %>% slice(1:36) plot_list <- g_ipp( df = adlb, xvar = \"AVISIT\", yvar = \"AVAL\", xlab = \"Visit\", ylab = \"SGOT/ALT (U/L)\", title = \"Individual Patient Plots\", add_baseline_hline = TRUE, plotting_choices = \"split_by_max_obs\", max_obs_per_plot = 5 ) plot_list #> [[1]] #> #> [[2]] #>"},{"path":"https://insightsengineering.github.io/tern/reference/g_km.html","id":null,"dir":"Reference","previous_headings":"","what":"Kaplan-Meier plot — g_km","title":"Kaplan-Meier plot — g_km","text":"survival model, graphic rendered along tabulated annotation including number patient risk given time median survival per group.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_km.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Kaplan-Meier plot — g_km","text":"","code":"g_km( df, variables, control_surv = control_surv_timepoint(), col = NULL, lty = NULL, lwd = 0.5, censor_show = TRUE, pch = 3, size = 2, max_time = NULL, xticks = NULL, xlab = \"Days\", yval = c(\"Survival\", \"Failure\"), ylab = paste(yval, \"Probability\"), ylim = NULL, title = NULL, footnotes = NULL, font_size = 10, ci_ribbon = FALSE, annot_at_risk = TRUE, annot_at_risk_title = TRUE, annot_surv_med = TRUE, annot_coxph = FALSE, annot_stats = NULL, annot_stats_vlines = FALSE, control_coxph_pw = control_coxph(), ref_group_coxph = NULL, control_annot_surv_med = control_surv_med_annot(), control_annot_coxph = control_coxph_annot(), legend_pos = NULL, rel_height_plot = 0.75, ggtheme = NULL, as_list = FALSE, draw = lifecycle::deprecated(), newpage = lifecycle::deprecated(), gp = lifecycle::deprecated(), vp = lifecycle::deprecated(), name = lifecycle::deprecated(), annot_coxph_ref_lbls = lifecycle::deprecated(), position_coxph = lifecycle::deprecated(), position_surv_med = lifecycle::deprecated(), width_annots = lifecycle::deprecated() )"},{"path":"https://insightsengineering.github.io/tern/reference/g_km.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Kaplan-Meier plot — g_km","text":"df (data.frame) data set containing analysis variables. variables (named list) variable names. Details : tte (numeric) variable indicating time--event duration values. is_event (logical) event variable. TRUE event, FALSE time event censored. arm (factor) treatment group variable. strata (character NULL) variable names indicating stratification factors. control_surv (list) parameters comparison details, specified using helper function control_surv_timepoint(). possible parameter options : conf_level (proportion) confidence level interval survival rate. conf_type (string)\"plain\" (default), \"log\", \"log-log\" confidence interval type, see survival::survfit(). Note option \"none\" longer supported. col (character) lines colors. Length vector equal number strata survival::survfit(). lty (numeric) line type. vector given, length equal number strata survival::survfit(). lwd (numeric) line width. vector given, length equal number strata survival::survfit(). censor_show (flag) whether show censored observations. pch (string) name symbol character use point symbol indicate censored cases. size (numeric(1)) size censored point symbols. max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL). xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis. NULL (default), labeling::extended() used determine optimal tick positions x-axis. xlab (string) x-axis label. yval (string) type plot, plotted y-axis. Options Survival (default) Failure probability. ylab (string) y-axis label. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used. title (string) plot title. footnotes (string) plot footnotes. font_size (numeric(1)) font size use text. ci_ribbon (flag) whether confidence interval drawn around Kaplan-Meier curve. annot_at_risk (flag) compute add annotation table reporting number patient risk matching main grid Kaplan-Meier curve. annot_at_risk_title (flag) whether \"Patients Risk\" title added annot_at_risk table. effect annot_at_risk FALSE. Defaults TRUE. annot_surv_med (flag) compute add annotation table Kaplan-Meier curve estimating median survival time per group. annot_coxph (flag) whether add annotation table survival::coxph() model. annot_stats (string NULL) statistics annotations add plot. Options median (median survival follow-time) min (minimum survival follow-time). annot_stats_vlines (flag) add vertical lines corresponding statistics specified annot_stats. annot_stats NULL lines added. control_coxph_pw (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing hazard ratio = 1. Default method \"log-rank\", can also set \"wald\" \"likelihood\". ties (string) method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph() conf_level (proportion) confidence level interval HR. ref_group_coxph (string NULL) level arm variable use reference group calculations annot_coxph table. NULL (default), uses first level arm variable. control_annot_surv_med (list) parameters control position size annotation table added plot annot_surv_med = TRUE, specified using control_surv_med_annot() function. Parameter options : x, y, w, h, fill. See control_surv_med_annot() details. control_annot_coxph (list) parameters control position size annotation table added plot annot_coxph = TRUE, specified using control_coxph_annot() function. Parameter options : x, y, w, h, fill, ref_lbls. See control_coxph_annot() details. legend_pos (numeric(2) NULL) vector containing x- y-coordinates, respectively, legend position relative KM plot area. NULL (default), legend positioned bottom right corner plot, middle right plot needed prevent overlapping. rel_height_plot (proportion) proportion total figure height allocate Kaplan-Meier plot. Relative height patients risk table 1 - rel_height_plot. annot_at_risk = FALSE as_list = TRUE, parameter ignored. ggtheme (theme) graphical theme provided ggplot2 format Kaplan-Meier plot. as_list (flag) whether two ggplot objects returned list annot_at_risk = TRUE. TRUE, named list two elements, plot table, returned. FALSE (default) patients risk table printed plot via cowplot::plot_grid(). draw function longer generates grob objects. newpage function longer generates grob objects. gp function longer generates grob objects. vp function longer generates grob objects. name function longer generates grob objects. annot_coxph_ref_lbls Please use ref_lbls element control_annot_coxph instead. position_coxph Please use x y elements control_annot_coxph instead. position_surv_med Please use x y elements control_annot_surv_med instead. width_annots Please use w element control_annot_surv_med (surv_med) control_annot_coxph (coxph).\"","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_km.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Kaplan-Meier plot — g_km","text":"ggplot Kaplan-Meier plot (optionally) summary table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_km.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Kaplan-Meier plot — g_km","text":"","code":"library(dplyr) df <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) variables <- list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARMCD\") # Basic examples g_km(df = df, variables = variables) g_km(df = df, variables = variables, yval = \"Failure\") # Examples with customization parameters applied g_km( df = df, variables = variables, control_surv = control_surv_timepoint(conf_level = 0.9), col = c(\"grey25\", \"grey50\", \"grey75\"), annot_at_risk_title = FALSE, lty = 1:3, font_size = 8 ) g_km( df = df, variables = variables, annot_stats = c(\"min\", \"median\"), annot_stats_vlines = TRUE, max_time = 3000, ggtheme = ggplot2::theme_minimal() ) # Example with pairwise Cox-PH analysis annotation table, adjusted annotation tables g_km( df = df, variables = variables, annot_coxph = TRUE, control_coxph = control_coxph(pval_method = \"wald\", ties = \"exact\", conf_level = 0.99), control_annot_coxph = control_coxph_annot(x = 0.26, w = 0.35), control_annot_surv_med = control_surv_med_annot(x = 0.8, y = 0.9, w = 0.35) )"},{"path":"https://insightsengineering.github.io/tern/reference/g_lineplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Line plot with optional table — g_lineplot","title":"Line plot with optional table — g_lineplot","text":"Line plot optional table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_lineplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Line plot with optional table — g_lineplot","text":"","code":"g_lineplot( df, alt_counts_df = NULL, variables = control_lineplot_vars(), mid = \"mean\", interval = \"mean_ci\", whiskers = c(\"mean_ci_lwr\", \"mean_ci_upr\"), table = NULL, sfun = s_summary, ..., mid_type = \"pl\", mid_point_size = 2, position = ggplot2::position_dodge(width = 0.4), legend_title = NULL, legend_position = \"bottom\", ggtheme = nestcolor::theme_nest(), xticks = NULL, xlim = NULL, ylim = NULL, x_lab = obj_label(df[[variables[[\"x\"]]]]), y_lab = NULL, y_lab_add_paramcd = TRUE, y_lab_add_unit = TRUE, title = \"Plot of Mean and 95% Confidence Limits by Visit\", subtitle = \"\", subtitle_add_paramcd = TRUE, subtitle_add_unit = TRUE, caption = NULL, table_format = NULL, table_labels = NULL, table_font_size = 3, errorbar_width = 0.45, newpage = lifecycle::deprecated(), col = NULL, linetype = NULL, rel_height_plot = 0.5, as_list = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/g_lineplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Line plot with optional table — g_lineplot","text":"df (data.frame) data set containing analysis variables. alt_counts_df (data.frame NULL) data set used () counts objects groups stratification. variables (named character) vector variable names df include: x (string) name x-axis variable. y (string) name y-axis variable. group_var (string NULL) name grouping variable (strata), .e. treatment arm. Can NA indicate lack groups. subject_var (string NULL) name subject variable. applies group_var NULL. paramcd (string NA) name variable parameter's code. Used y-axis label plot's subtitle. Can NA paramcd added y-axis label subtitle. y_unit (string NA) name variable units y. Used y-axis label plot's subtitle. Can NA y unit added y-axis label subtitle. facet_var (string NA) name secondary grouping variable used plot faceting, .e. treatment arm. Can NA indicate lack groups. mid (character NULL) names statistics plotted midpoints. statistics indicated mid variable must present object returned sfun, double numeric type vector length one. interval (character NULL) names statistics plotted intervals. statistics indicated interval variable must present object returned sfun, double numeric type vector length two. Set interval = NULL intervals added plot. whiskers (character) names interval whiskers plotted. Names must match names list element interval returned sfun (e.g. mean_ci_lwr element sfun(x)[[\"mean_ci\"]]). possible specify one whisker , suppress whiskers setting interval = NULL. table (character NULL) names statistics displayed table plot. statistics indicated table variable must present object returned sfun. sfun (function) function compute values required statistics. must return named list atomic vectors. names list elements refer names statistics used mid, interval, table. must able accept input vector data statistics computed. ... optional arguments sfun. mid_type (string) controls type mid plot, can point (\"p\"), line (\"l\"), point line (\"pl\"). mid_point_size (numeric(1)) font size mid plot points. position (character call) geom element position adjustment, either string, result call position adjustment function. legend_title (string) legend title. legend_position (string) position plot legend (\"none\", \"left\", \"right\", \"bottom\", \"top\", two-element numeric vector). ggtheme (theme) graphical theme provided ggplot2 control styling plot. xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis, use variables$x numeric. NULL (default), labeling::extended() used determine optimal tick positions x-axis. variables$x numeric, argument ignored. xlim (numeric(2)) vector containing lower upper limits x-axis, respectively. NULL (default), default scale range used. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used. x_lab (string NULL) x-axis label. NULL label added. y_lab (string NULL) y-axis label. NULL label added. y_lab_add_paramcd (flag) whether paramcd, .e. unique(df[[variables[\"paramcd\"]]]) added y-axis label (y_lab). y_lab_add_unit (flag) whether y-axis unit, .e. unique(df[[variables[\"y_unit\"]]]) added y-axis label (y_lab). title (string) plot title. subtitle (string) plot subtitle. subtitle_add_paramcd (flag) whether paramcd, .e. unique(df[[variables[\"paramcd\"]]]) added plot's subtitle (subtitle). subtitle_add_unit (flag) whether y-axis unit, .e. unique(df[[variables[\"y_unit\"]]]) added plot's subtitle (subtitle). caption (string) optional caption plot. table_format (named character NULL) format patterns descriptive statistics used (optional) table appended plot. passed directly h_format_row function format parameter. Names table_format must match names statistics returned sfun function. table_labels (named character NULL) labels descriptive statistics used (optional) table appended plot. Names table_labels must match names statistics returned sfun function. table_font_size (numeric(1)) font size text table. errorbar_width (numeric(1)) width error bars. newpage used. col (character) color(s). See ?ggplot2::aes_colour_fill_alpha example values. linetype (character) line type(s). See ?ggplot2::aes_linetype_size_shape example values. rel_height_plot (proportion) proportion total figure height allocate line plot. Relative height annotation table 1 - rel_height_plot. table = NULL, parameter ignored. as_list (flag) whether two ggplot objects returned list table NULL. TRUE, named list two elements, plot table, returned. FALSE (default) annotation table printed plot via cowplot::plot_grid().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_lineplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Line plot with optional table — g_lineplot","text":"ggplot line plot (statistics table applicable).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_lineplot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Line plot with optional table — g_lineplot","text":"","code":"adsl <- tern_ex_adsl adlb <- tern_ex_adlb %>% dplyr::filter(ANL01FL == \"Y\", PARAMCD == \"ALT\", AVISIT != \"SCREENING\") adlb$AVISIT <- droplevels(adlb$AVISIT) adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) # Mean with CI g_lineplot(adlb, adsl, subtitle = \"Laboratory Test:\") # Mean with CI, no stratification with group_var g_lineplot(adlb, variables = control_lineplot_vars(group_var = NA)) # Mean, upper whisker of CI, no group_var(strata) counts N g_lineplot( adlb, whiskers = \"mean_ci_upr\", title = \"Plot of Mean and Upper 95% Confidence Limit by Visit\" ) # Median with CI g_lineplot( adlb, adsl, mid = \"median\", interval = \"median_ci\", whiskers = c(\"median_ci_lwr\", \"median_ci_upr\"), title = \"Plot of Median and 95% Confidence Limits by Visit\" ) # Mean, +/- SD g_lineplot(adlb, adsl, interval = \"mean_sdi\", whiskers = c(\"mean_sdi_lwr\", \"mean_sdi_upr\"), title = \"Plot of Median +/- SD by Visit\" ) # Mean with CI plot with stats table g_lineplot(adlb, adsl, table = c(\"n\", \"mean\", \"mean_ci\")) # Mean with CI, table and customized confidence level g_lineplot( adlb, adsl, table = c(\"n\", \"mean\", \"mean_ci\"), control = control_analyze_vars(conf_level = 0.80), title = \"Plot of Mean and 80% Confidence Limits by Visit\" ) # Mean with CI, table, filtered data adlb_f <- dplyr::filter(adlb, ARMCD != \"ARM A\" | AVISIT == \"BASELINE\") g_lineplot(adlb_f, table = c(\"n\", \"mean\"))"},{"path":"https://insightsengineering.github.io/tern/reference/g_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a STEP graph — g_step","title":"Create a STEP graph — g_step","text":"Based STEP results, creates ggplot graph showing estimated HR along continuous biomarker value subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a STEP graph — g_step","text":"","code":"g_step( df, use_percentile = \"Percentile Center\" %in% names(df), est = list(col = \"blue\", lty = 1), ci_ribbon = list(fill = getOption(\"ggplot2.discrete.colour\")[1], alpha = 0.5), col = getOption(\"ggplot2.discrete.colour\") )"},{"path":"https://insightsengineering.github.io/tern/reference/g_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a STEP graph — g_step","text":"df (tibble) result tidy.step(). use_percentile (flag) whether use percentiles x axis actual biomarker values. est (named list)col lty settings estimate line. ci_ribbon (named list NULL)fill alpha settings confidence interval ribbon area, NULL plot CI ribbon. col (character) color(s).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a STEP graph — g_step","text":"ggplot STEP graph.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/g_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a STEP graph — g_step","text":"","code":"library(survival) lung$sex <- factor(lung$sex) # Survival example. vars <- list( time = \"time\", event = \"status\", arm = \"sex\", biomarker = \"age\" ) step_matrix <- fit_survival_step( variables = vars, data = lung, control = c(control_coxph(), control_step(num_points = 10, degree = 2)) ) step_data <- broom::tidy(step_matrix) # Default plot. g_step(step_data) # Add the reference 1 horizontal line. library(ggplot2) g_step(step_data) + ggplot2::geom_hline(ggplot2::aes(yintercept = 1), linetype = 2) # Use actual values instead of percentiles, different color for estimate and no CI, # use log scale for y axis. g_step( step_data, use_percentile = FALSE, est = list(col = \"blue\", lty = 1), ci_ribbon = NULL ) + scale_y_log10() # Adding another curve based on additional column. step_data$extra <- exp(step_data$`Percentile Center`) g_step(step_data) + ggplot2::geom_line(ggplot2::aes(y = extra), linetype = 2, color = \"green\") # Response example. vars <- list( response = \"status\", arm = \"sex\", biomarker = \"age\" ) step_matrix <- fit_rsp_step( variables = vars, data = lung, control = c( control_logistic(response_definition = \"I(response == 2)\"), control_step() ) ) step_data <- broom::tidy(step_matrix) g_step(step_data)"},{"path":"https://insightsengineering.github.io/tern/reference/g_waterfall.html","id":null,"dir":"Reference","previous_headings":"","what":"Horizontal waterfall plot — g_waterfall","title":"Horizontal waterfall plot — g_waterfall","text":"basic waterfall plot visualizes quantity height ordered value markup.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_waterfall.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Horizontal waterfall plot — g_waterfall","text":"","code":"g_waterfall( height, id, col_var = NULL, col = getOption(\"ggplot2.discrete.colour\"), xlab = NULL, ylab = NULL, col_legend_title = NULL, title = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/g_waterfall.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Horizontal waterfall plot — g_waterfall","text":"height (numeric) vector containing values plotted waterfall bars. id (character) vector containing identifiers use x-axis label waterfall bars. col_var (factor, character, NULL) categorical variable bar coloring. NULL default. col (character) color(s). xlab (string) x label. Default \"ID\". ylab (string) y label. Default \"Value\". col_legend_title (string) text displayed legend title. title (string) text displayed plot title.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_waterfall.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Horizontal waterfall plot — g_waterfall","text":"ggplot waterfall plot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/g_waterfall.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Horizontal waterfall plot — g_waterfall","text":"","code":"library(dplyr) g_waterfall(height = c(3, 5, -1), id = letters[1:3]) g_waterfall( height = c(3, 5, -1), id = letters[1:3], col_var = letters[1:3] ) adsl_f <- tern_ex_adsl %>% select(USUBJID, STUDYID, ARM, ARMCD, SEX) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"OVRINV\") %>% mutate(pchg = rnorm(n(), 10, 50)) adrs_f <- head(adrs_f, 30) adrs_f <- adrs_f[!duplicated(adrs_f$USUBJID), ] head(adrs_f) #> # A tibble: 5 × 30 #> STUDYID COUNTRY SITEID SUBJID AGE SEX ARMCD ARM ACTARMCD ACTARM RACE #> #> 1 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug… ARM A A: Dr… ASIAN #> 2 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac… ARM B B: Pl… ASIAN #> 3 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac… ARM B B: Pl… ASIAN #> 4 AB12345 BRA BRA-1 id-23 41.3 F ARM A A: Drug… ARM A A: Dr… AMER… #> 5 AB12345 BRA BRA-1 id-59 26.7 F ARM A A: Drug… ARM A A: Dr… ASIAN #> # ℹ 19 more variables: TRTSDTM , TRTEDTM , EOSDY , #> # STRATA1 , STRATA2 , BMRKR1 , BMRKR2 , REGION1 , #> # SAFFL , USUBJID , AVISIT , PARAMCD , PARAM , #> # AVALC , AVAL , ADTM , AVISITN , DTHFL , #> # pchg g_waterfall( height = adrs_f$pchg, id = adrs_f$USUBJID, col_var = adrs_f$AVALC ) g_waterfall( height = adrs_f$pchg, id = paste(\"asdfdsfdsfsd\", adrs_f$USUBJID), col_var = adrs_f$SEX ) g_waterfall( height = adrs_f$pchg, id = paste(\"asdfdsfdsfsd\", adrs_f$USUBJID), xlab = \"ID\", ylab = \"Percentage Change\", title = \"Waterfall plot\" )"},{"path":"https://insightsengineering.github.io/tern/reference/get_covariates.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to return a named list of covariate names — get_covariates","title":"Utility function to return a named list of covariate names — get_covariates","text":"Utility function return named list covariate names","code":""},{"path":"https://insightsengineering.github.io/tern/reference/get_covariates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to return a named list of covariate names — get_covariates","text":"","code":"get_covariates(covariates)"},{"path":"https://insightsengineering.github.io/tern/reference/get_covariates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to return a named list of covariate names — get_covariates","text":"covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\".","code":""},{"path":"https://insightsengineering.github.io/tern/reference/get_covariates.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to return a named list of covariate names — get_covariates","text":"named list character vector.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/get_smooths.html","id":null,"dir":"Reference","previous_headings":"","what":"Smooth function with optional grouping — get_smooths","title":"Smooth function with optional grouping — get_smooths","text":"produces loess smoothed estimates y Student confidence intervals.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/get_smooths.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Smooth function with optional grouping — get_smooths","text":"","code":"get_smooths(df, x, y, groups = NULL, level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/reference/get_smooths.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Smooth function with optional grouping — get_smooths","text":"df (data.frame) data set containing analysis variables. x (string) x column name. y (string) y column name. groups (character NULL) vector optional grouping variables names. level (proportion) level confidence interval use (0.95 default).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/get_smooths.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Smooth function with optional grouping — get_smooths","text":"data.frame original x, smoothed y, ylow, yhigh, optional groups variables formatted factor type.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/groups_list_to_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert list of groups to a data frame — groups_list_to_df","title":"Convert list of groups to a data frame — groups_list_to_df","text":"converts list group levels data frame format expected rtables::add_combo_levels().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/groups_list_to_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert list of groups to a data frame — groups_list_to_df","text":"","code":"groups_list_to_df(groups_list)"},{"path":"https://insightsengineering.github.io/tern/reference/groups_list_to_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert list of groups to a data frame — groups_list_to_df","text":"groups_list (named list character) specifies new group levels via names levels belong character vectors elements list.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/groups_list_to_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert list of groups to a data frame — groups_list_to_df","text":"tibble required format.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/groups_list_to_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert list of groups to a data frame — groups_list_to_df","text":"","code":"grade_groups <- list( \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"), \"Grade 3-4 (%)\" = c(\"3\", \"4\"), \"Grade 5 (%)\" = \"5\" ) groups_list_to_df(grade_groups) #> # A tibble: 3 × 4 #> valname label levelcombo exargs #> #> 1 AnyGrade Any Grade (%) #> 2 Grade34 Grade 3-4 (%) #> 3 Grade5 Grade 5 (%) "},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_abnormal_by_worst_grade.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"Helper function prepare ADLB data frame used input count_abnormal_by_worst_grade(). following pre-processing steps applied: adlb filtered variable avisit include post-baseline visits. adlb filtered variables worst_flag_low worst_flag_high worst grades (either direction) included. standard lab grade variable atoxgr, following two variables derived added adlb: grade direction variable (e.g. GRADE_DIR). variable takes value \"HIGH\" atoxgr > 0, \"LOW\" atoxgr < 0, \"ZERO\" otherwise. toxicity grade variable (e.g. GRADE_ANL) negative values atoxgr replaced absolute values. Unused factor levels dropped adlb via droplevels().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_abnormal_by_worst_grade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"","code":"h_adlb_abnormal_by_worst_grade( adlb, atoxgr = \"ATOXGR\", avisit = \"AVISIT\", worst_flag_low = \"WGRLOFL\", worst_flag_high = \"WGRHIFL\" )"},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_abnormal_by_worst_grade.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"adlb (data.frame) ADLB data frame. atoxgr (string) name analysis toxicity grade variable. must factor variable. avisit (string) name analysis visit variable. worst_flag_low (string) name worst low lab grade flag variable. variable set \"Y\" indicating records worst low lab grades. worst_flag_high (string) name worst high lab grade flag variable. variable set \"Y\" indicating records worst high lab grades.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_abnormal_by_worst_grade.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"h_adlb_abnormal_by_worst_grade() returns adlb data frame two new variables: GRADE_DIR GRADE_ANL.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_abnormal_by_worst_grade.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"","code":"h_adlb_abnormal_by_worst_grade(tern_ex_adlb) %>% dplyr::select(ATOXGR, GRADE_DIR, GRADE_ANL) %>% head(10) #> # A tibble: 10 × 3 #> ATOXGR GRADE_DIR GRADE_ANL #> #> 1 -3 LOW 3 #> 2 0 ZERO 0 #> 3 0 ZERO 0 #> 4 2 HIGH 2 #> 5 0 ZERO 0 #> 6 0 ZERO 0 #> 7 -4 LOW 4 #> 8 1 HIGH 1 #> 9 -1 LOW 1 #> 10 0 ZERO 0"},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_worsen.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"Helper function prepare df generate patient count shift table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_worsen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"","code":"h_adlb_worsen( adlb, worst_flag_low = NULL, worst_flag_high = NULL, direction_var )"},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_worsen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"adlb (data.frame) ADLB data frame. worst_flag_low (named vector) worst low post-baseline lab grade flag variable. See implemented following examples. worst_flag_high (named vector) worst high post-baseline lab grade flag variable. See implemented following examples. direction_var (string) name direction variable specifying direction shift table interest. lab records flagged L, H B included shift table. L: low direction H: high direction B: low high directions","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_worsen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"h_adlb_worsen() returns adlb data.frame containing worst labs specified according worst_flag_low worst_flag_high direction specified according direction_var. instance, lab needed low direction , records flagged worst_flag_low selected. lab needed low high directions, worst low records selected low direction, worst high record selected high direction.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_adlb_worsen.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"","code":"library(dplyr) # The direction variable, GRADDR, is based on metadata adlb <- tern_ex_adlb %>% mutate( GRADDR = case_when( PARAMCD == \"ALT\" ~ \"B\", PARAMCD == \"CRP\" ~ \"L\", PARAMCD == \"IGA\" ~ \"H\" ) ) %>% filter(SAFFL == \"Y\" & ONTRTFL == \"Y\" & GRADDR != \"\") df <- h_adlb_worsen( adlb, worst_flag_low = c(\"WGRLOFL\" = \"Y\"), worst_flag_high = c(\"WGRHIFL\" = \"Y\"), direction_var = \"GRADDR\" )"},{"path":"https://insightsengineering.github.io/tern/reference/h_adsl_adlb_merge_using_worst_flag.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"Helper function merges ADSL ADLB datasets missing lab test records inserted output dataset. Remember na_level must match needed pre-processing done df_explicit_na() desired output.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"","code":"h_adsl_adlb_merge_using_worst_flag( adsl, adlb, worst_flag = c(WGRHIFL = \"Y\"), by_visit = FALSE, no_fillin_visits = c(\"SCREENING\", \"BASELINE\") )"},{"path":"https://insightsengineering.github.io/tern/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"adsl (data.frame) ADSL data frame. adlb (data.frame) ADLB data frame. worst_flag (named character) worst post-baseline lab flag variable. See implemented following examples. by_visit (flag) defaults FALSE generate worst grade per patient. worst grade per patient per visit specified worst_flag, by_visit TRUE generate worst grade patient per visit. no_fillin_visits (named character) visits considered post-baseline worst toxicity grade. Defaults c(\"SCREENING\", \"BASELINE\").","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"df containing variables shared adlb adsl along variables PARAM, PARAMCD, ATOXGR, BTOXGR relevant analysis. Optionally, AVISIT AVISITN included by_visit = TRUE no_fillin_visits = c(\"SCREENING\", \"BASELINE\").","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"result data missing records created following situations: Patients present adsl lab data adlb (baseline post-baseline). Patients post-baseline lab values. Patients without post-baseline values flagged worst.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"","code":"# `h_adsl_adlb_merge_using_worst_flag` adlb_out <- h_adsl_adlb_merge_using_worst_flag( tern_ex_adsl, tern_ex_adlb, worst_flag = c(\"WGRHIFL\" = \"Y\") ) # `h_adsl_adlb_merge_using_worst_flag` by visit example adlb_out_by_visit <- h_adsl_adlb_merge_using_worst_flag( tern_ex_adsl, tern_ex_adlb, worst_flag = c(\"WGRLOVFL\" = \"Y\"), by_visit = TRUE )"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_ancova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to return results of a linear model — h_ancova","text":"","code":"h_ancova(.var, .df_row, variables, interaction_item = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/h_ancova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to return results of a linear model — h_ancova","text":".var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) data set includes variables called .var variables. variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". interaction_item (string NULL) name variable interactions arm. interaction needed, default option NULL.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ancova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to return results of a linear model — h_ancova","text":"summary linear model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ancova.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to return results of a linear model — h_ancova","text":"","code":"h_ancova( .var = \"Sepal.Length\", .df_row = iris, variables = list(arm = \"Species\", covariates = c(\"Petal.Length * Petal.Width\", \"Sepal.Width\")) ) #> Species emmean SE df lower.CL upper.CL #> setosa 6.15 0.3370 143 5.49 6.82 #> versicolor 5.72 0.0668 143 5.59 5.85 #> virginica 5.41 0.1490 143 5.11 5.70 #> #> Confidence level used: 0.95"},{"path":"https://insightsengineering.github.io/tern/reference/h_append_grade_groups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"Helper function s_count_occurrences_by_grade() insert grade groupings list individual grade frequencies. order final result follows order grade_groups. elements -grade group (), .e. grade group equal refs moved end. Grade groups names must unique.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_append_grade_groups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"","code":"h_append_grade_groups( grade_groups, refs, remove_single = TRUE, only_grade_groups = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/h_append_grade_groups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"grade_groups (named list character) list containing groupings grades. refs (named list numeric) named list name corresponds reference grade level entry represents count. remove_single (flag)TRUE include elements one-element grade groups output list; case grade groups names included output. only_grade_groups set TRUE argument ignored. only_grade_groups (flag) whether specified grade groups included, individual grade rows removed (TRUE), grades grade groups displayed (FALSE).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_append_grade_groups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"Formatted list grade groupings.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_append_grade_groups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"","code":"h_append_grade_groups( list( \"Any Grade\" = as.character(1:5), \"Grade 1-2\" = c(\"1\", \"2\"), \"Grade 3-4\" = c(\"3\", \"4\") ), list(\"1\" = 10, \"2\" = 20, \"3\" = 30, \"4\" = 40, \"5\" = 50) ) #> $`Any Grade` #> [1] 150 #> #> $`Grade 1-2` #> [1] 30 #> #> $`1` #> [1] 10 #> #> $`2` #> [1] 20 #> #> $`Grade 3-4` #> [1] 70 #> #> $`3` #> [1] 30 #> #> $`4` #> [1] 40 #> #> $`5` #> [1] 50 #> h_append_grade_groups( list( \"Any Grade\" = as.character(5:1), \"Grade A\" = \"5\", \"Grade B\" = c(\"4\", \"3\") ), list(\"1\" = 10, \"2\" = 20, \"3\" = 30, \"4\" = 40, \"5\" = 50) ) #> $`Any Grade` #> [1] 150 #> #> $`Grade A` #> [1] 50 #> #> $`Grade B` #> [1] 70 #> #> $`4` #> [1] 40 #> #> $`3` #> [1] 30 #> #> $`2` #> [1] 20 #> #> $`1` #> [1] 10 #> h_append_grade_groups( list( \"Any Grade\" = as.character(1:5), \"Grade 1-2\" = c(\"1\", \"2\"), \"Grade 3-4\" = c(\"3\", \"4\") ), list(\"1\" = 10, \"2\" = 5, \"3\" = 0) ) #> $`Any Grade` #> [1] 15 #> #> $`Grade 1-2` #> [1] 15 #> #> $`1` #> [1] 10 #> #> $`2` #> [1] 5 #> #> $`Grade 3-4` #> [1] 0 #> #> $`3` #> [1] 0 #>"},{"path":"https://insightsengineering.github.io/tern/reference/h_col_indices.html","id":null,"dir":"Reference","previous_headings":"","what":"Obtain column indices — h_col_indices","title":"Obtain column indices — h_col_indices","text":"Helper function extract column indices VTableTree given vector column names.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_col_indices.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Obtain column indices — h_col_indices","text":"","code":"h_col_indices(table_tree, col_names)"},{"path":"https://insightsengineering.github.io/tern/reference/h_col_indices.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Obtain column indices — h_col_indices","text":"table_tree (VTableTree)rtables table object extract indices . col_names (character) vector column names.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_col_indices.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Obtain column indices — h_col_indices","text":"vector column indices.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_count_cumulative.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for s_count_cumulative() — h_count_cumulative","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"Helper function calculate count fraction x values lower upper tail given threshold.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_count_cumulative.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"","code":"h_count_cumulative( x, threshold, lower_tail = TRUE, include_eq = TRUE, na.rm = TRUE, .N_col )"},{"path":"https://insightsengineering.github.io/tern/reference/h_count_cumulative.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"x (numeric) vector numbers want analyze. threshold (numeric(1)) cutoff value threshold count values x. lower_tail (flag) whether count lower tail, default TRUE. include_eq (flag) whether include value equal threshold count, default TRUE. na.rm (flag) whether NA values removed x prior analysis. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_count_cumulative.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"named vector items: count: count values less , less equal , greater , greater equal threshold user specification. fraction: fraction count.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_count_cumulative.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"","code":"set.seed(1, kind = \"Mersenne-Twister\") x <- c(sample(1:10, 10), NA) .N_col <- length(x) h_count_cumulative(x, 5, .N_col = .N_col) #> count fraction #> 5.0000000 0.4545455 h_count_cumulative(x, 5, lower_tail = FALSE, include_eq = FALSE, na.rm = FALSE, .N_col = .N_col) #> count fraction #> 6.0000000 0.5454545 h_count_cumulative(x, 0, lower_tail = FALSE, .N_col = .N_col) #> count fraction #> 10.0000000 0.9090909 h_count_cumulative(x, 100, lower_tail = FALSE, .N_col = .N_col) #> count fraction #> 0 0"},{"path":"https://insightsengineering.github.io/tern/reference/h_cox_regression.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for Cox proportional hazards regression — h_cox_regression","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"Helper functions used fit_coxreg_univar() fit_coxreg_multivar().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_cox_regression.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"","code":"h_coxreg_univar_formulas(variables, interaction = FALSE) h_coxreg_multivar_formula(variables) h_coxreg_univar_extract(effect, covar, data, mod, control = control_coxreg()) h_coxreg_multivar_extract(var, data, mod, control = control_coxreg())"},{"path":"https://insightsengineering.github.io/tern/reference/h_cox_regression.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"variables (named list string) list additional analysis variables. interaction (flag) TRUE, model includes interaction studied treatment candidate covariate. Note univariate models without treatment arm, multivariate models, interaction can used needs FALSE. effect (string) treatment variable. covar (string) name covariate model. data (data.frame) dataset containing variables summarize. mod (coxph) Cox regression model fitted survival::coxph(). control (list) list controls returned control_coxreg(). var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_cox_regression.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"h_coxreg_univar_formulas() returns character vector coercible formulas (e.g stats::.formula()). h_coxreg_multivar_formula() returns string coercible formula (e.g stats::.formula()). h_coxreg_univar_extract() returns data.frame variables effect, term, term_label, level, n, hr, lcl, ucl, pval. h_coxreg_multivar_extract() returns data.frame variables pval, hr, lcl, ucl, level, n, term, term_label.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_cox_regression.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"h_coxreg_univar_formulas(): Helper Cox regression formula. Creates list formulas. used internally fit_coxreg_univar() comparison univariate Cox regression models. h_coxreg_multivar_formula(): Helper multivariate Cox regression formula. Creates formulas string. used internally fit_coxreg_multivar() comparison multivariate Cox regression models. Interactions included multivariate Cox regression model. h_coxreg_univar_extract(): Utility function help tabulate result univariate Cox regression model. h_coxreg_multivar_extract(): Tabulation multivariate Cox regressions. Utility function help tabulate result multivariate Cox regression model treatment/covariate variable.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_cox_regression.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"","code":"# `h_coxreg_univar_formulas` ## Simple formulas. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"X\", \"y\") ) ) #> ref #> \"survival::Surv(time, status) ~ armcd\" #> X #> \"survival::Surv(time, status) ~ armcd + X\" #> y #> \"survival::Surv(time, status) ~ armcd + y\" ## Addition of an optional strata. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"X\", \"y\"), strata = \"SITE\" ) ) #> ref #> \"survival::Surv(time, status) ~ armcd + strata(SITE)\" #> X #> \"survival::Surv(time, status) ~ armcd + X + strata(SITE)\" #> y #> \"survival::Surv(time, status) ~ armcd + y + strata(SITE)\" ## Inclusion of the interaction term. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"X\", \"y\"), strata = \"SITE\" ), interaction = TRUE ) #> ref #> \"survival::Surv(time, status) ~ armcd + strata(SITE)\" #> X #> \"survival::Surv(time, status) ~ armcd * X + strata(SITE)\" #> y #> \"survival::Surv(time, status) ~ armcd * y + strata(SITE)\" ## Only covariates fitted in separate models. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", covariates = c(\"X\", \"y\") ) ) #> X y #> \"survival::Surv(time, status) ~ 1 + X\" \"survival::Surv(time, status) ~ 1 + y\" # `h_coxreg_multivar_formula` h_coxreg_multivar_formula( variables = list( time = \"AVAL\", event = \"event\", arm = \"ARMCD\", covariates = c(\"RACE\", \"AGE\") ) ) #> [1] \"survival::Surv(AVAL, event) ~ ARMCD + RACE + AGE\" # Addition of an optional strata. h_coxreg_multivar_formula( variables = list( time = \"AVAL\", event = \"event\", arm = \"ARMCD\", covariates = c(\"RACE\", \"AGE\"), strata = \"SITE\" ) ) #> [1] \"survival::Surv(AVAL, event) ~ ARMCD + RACE + AGE + strata(SITE)\" # Example without treatment arm. h_coxreg_multivar_formula( variables = list( time = \"AVAL\", event = \"event\", covariates = c(\"RACE\", \"AGE\"), strata = \"SITE\" ) ) #> [1] \"survival::Surv(AVAL, event) ~ 1 + RACE + AGE + strata(SITE)\" library(survival) dta_simple <- data.frame( time = c(5, 5, 10, 10, 5, 5, 10, 10), status = c(0, 0, 1, 0, 0, 1, 1, 1), armcd = factor(LETTERS[c(1, 1, 1, 1, 2, 2, 2, 2)], levels = c(\"A\", \"B\")), var1 = c(45, 55, 65, 75, 55, 65, 85, 75), var2 = c(\"F\", \"M\", \"F\", \"M\", \"F\", \"M\", \"F\", \"U\") ) mod <- coxph(Surv(time, status) ~ armcd + var1, data = dta_simple) result <- h_coxreg_univar_extract( effect = \"armcd\", covar = \"armcd\", mod = mod, data = dta_simple ) result #> effect term term_label level n hr lcl ucl #> 1 Treatment: armcd B vs control (A) B 8 6.551448 0.4606904 93.16769 #> pval #> 1 0.165209 mod <- coxph(Surv(time, status) ~ armcd + var1, data = dta_simple) result <- h_coxreg_multivar_extract( var = \"var1\", mod = mod, data = dta_simple ) result #> pval hr lcl ucl level n term term_label #> 2 0.4456195 0.9423284 0.808931 1.097724 var1 8 var1 var1"},{"path":"https://insightsengineering.github.io/tern/reference/h_data_plot.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to tidy survival fit data — h_data_plot","title":"Helper function to tidy survival fit data — h_data_plot","text":"Convert survival fit data data frame designed plotting within g_km. starts broom::tidy() result, : Post-processes strata column factor. Extends stratum additional first row time 0 probability 1 downstream plot lines start coordinates. Adds censor column. Filters rows max_time.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_data_plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to tidy survival fit data — h_data_plot","text":"","code":"h_data_plot(fit_km, armval = \"All\", max_time = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/h_data_plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to tidy survival fit data — h_data_plot","text":"fit_km (survfit) result survival::survfit(). armval (string) used strata name treatment arm variable one level. Default \"\". max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_data_plot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to tidy survival fit data — h_data_plot","text":"tibble columns time, n.risk, n.event, n.censor, estimate, std.error, conf.high, conf.low, strata, censor.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_data_plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to tidy survival fit data — h_data_plot","text":"","code":"library(dplyr) library(survival) # Test with multiple arms tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_data_plot() #> # A tibble: 203 × 10 #> time n.risk n.event n.censor estimate std.error conf.high conf.low strata #> #> 1 0 70 0 0 1 0 1 1 ARM A #> 2 10.4 69 1 0 0.986 0.0146 1 0.958 ARM A #> 3 20.5 68 1 0 0.971 0.0208 1 0.932 ARM A #> 4 21.5 67 1 0 0.957 0.0257 1 0.910 ARM A #> 5 25.3 66 0 1 0.957 0.0257 1 0.910 ARM A #> 6 48.1 65 1 0 0.942 0.0300 0.999 0.888 ARM A #> 7 66.6 64 0 1 0.942 0.0300 0.999 0.888 ARM A #> 8 73.9 63 0 1 0.942 0.0300 0.999 0.888 ARM A #> 9 78.9 62 0 1 0.942 0.0300 0.999 0.888 ARM A #> 10 90.3 61 1 0 0.926 0.0342 0.991 0.866 ARM A #> # ℹ 193 more rows #> # ℹ 1 more variable: censor # Test with single arm tern_ex_adtte %>% filter(PARAMCD == \"OS\", ARMCD == \"ARM B\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_data_plot(armval = \"ARM B\") #> # A tibble: 74 × 10 #> time n.risk n.event n.censor estimate std.error conf.high conf.low strata #> #> 1 0 74 0 0 1 0 1 1 ARM B #> 2 2.17 73 1 0 0.986 0.0138 1 0.960 ARM B #> 3 16.9 72 1 0 0.973 0.0196 1 0.936 ARM B #> 4 22.6 71 1 0 0.959 0.0242 1 0.914 ARM B #> 5 26.3 70 1 0 0.945 0.0282 0.999 0.894 ARM B #> 6 57.5 69 1 0 0.932 0.0317 0.991 0.875 ARM B #> 7 80.0 68 1 0 0.918 0.0350 0.983 0.857 ARM B #> 8 81.6 67 1 0 0.904 0.0381 0.974 0.839 ARM B #> 9 88.6 66 1 0 0.890 0.0411 0.965 0.822 ARM B #> 10 102. 65 1 0 0.877 0.0439 0.955 0.804 ARM B #> # ℹ 64 more rows #> # ℹ 1 more variable: censor "},{"path":"https://insightsengineering.github.io/tern/reference/h_decompose_gg.html","id":null,"dir":"Reference","previous_headings":"","what":"ggplot decomposition — h_decompose_gg","title":"ggplot decomposition — h_decompose_gg","text":"elements composing ggplot extracted organized list.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_decompose_gg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ggplot decomposition — h_decompose_gg","text":"","code":"h_decompose_gg(gg)"},{"path":"https://insightsengineering.github.io/tern/reference/h_decompose_gg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"ggplot decomposition — h_decompose_gg","text":"gg (ggplot) graphic decompose.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_decompose_gg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"ggplot decomposition — h_decompose_gg","text":"named list elements: panel: panel. yaxis: y-axis. xaxis: x-axis. xlab: x-axis label. ylab: y-axis label. guide: legend.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_decompose_gg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"ggplot decomposition — h_decompose_gg","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, yval = \"Survival\", censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"tt\", footnotes = \"ff\" ) #> Warning: `h_ggkm()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. g_el <- h_decompose_gg(gg) #> Warning: `h_decompose_gg()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"red\", fill = \"gray85\", lwd = 5)) grid::grid.draw(g_el$panel) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"royalblue\", fill = \"gray85\", lwd = 5)) grid::grid.draw(with(g_el, cbind(ylab, yaxis))) # }"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_format_row.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"","code":"h_format_row(x, format, labels = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/h_format_row.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"x (named list) list numerical values formatted optionally labeled. Elements x must numeric vectors. format (named character NULL) format patterns x. Names format must match names x. parameter passed directly rtables::format_rcell function format parameter. labels (named character NULL) optional labels x. Names labels must match names x. label specified element x, function tries use label names (order) attribute element (depending one exists NULL NA NaN). none attributes attached given element x, label automatically generated.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_format_row.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"single row data.frame object.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_format_row.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"","code":"mean_ci <- c(48, 51) x <- list(mean = 50, mean_ci = mean_ci) format <- c(mean = \"xx.x\", mean_ci = \"(xx.xx, xx.xx)\") labels <- c(mean = \"My Mean\") h_format_row(x, format, labels) #> My Mean V1 #> 1 50.0 (48.00, 51.00) attr(mean_ci, \"label\") <- \"Mean 95% CI\" x <- list(mean = 50, mean_ci = mean_ci) h_format_row(x, format, labels) #> My Mean Mean 95% CI #> 1 50.0 (48.00, 51.00)"},{"path":"https://insightsengineering.github.io/tern/reference/h_g_ipp.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create simple line plot over time — h_g_ipp","title":"Helper function to create simple line plot over time — h_g_ipp","text":"Function generates simple line plot displaying parameter trends time.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_g_ipp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create simple line plot over time — h_g_ipp","text":"","code":"h_g_ipp( df, xvar, yvar, xlab, ylab, id_var, title = \"Individual Patient Plots\", subtitle = \"\", caption = NULL, add_baseline_hline = FALSE, yvar_baseline = \"BASE\", ggtheme = nestcolor::theme_nest(), col = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/h_g_ipp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create simple line plot over time — h_g_ipp","text":"df (data.frame) data set containing analysis variables. xvar (string) time point variable plotted x-axis. yvar (string) continuous analysis variable plotted y-axis. xlab (string) plot label x-axis. ylab (string) plot label y-axis. id_var (string) variable used patient identifier. title (string) title plot. subtitle (string) subtitle plot. caption (string) optional caption plot. add_baseline_hline (flag) adds horizontal line baseline y-value plot TRUE. yvar_baseline (string) variable baseline values . Ignored add_baseline_hline FALSE. ggtheme (theme) optional graphical theme function provided ggplot2 control outlook plot. Use ggplot2::theme() tweak display. col (character) line colors.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_g_ipp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create simple line plot over time — h_g_ipp","text":"ggplot line plot.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_g_ipp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create simple line plot over time — h_g_ipp","text":"","code":"library(dplyr) # Select a small sample of data to plot. adlb <- tern_ex_adlb %>% filter(PARAMCD == \"ALT\", !(AVISIT %in% c(\"SCREENING\", \"BASELINE\"))) %>% slice(1:36) p <- h_g_ipp( df = adlb, xvar = \"AVISIT\", yvar = \"AVAL\", xlab = \"Visit\", id_var = \"USUBJID\", ylab = \"SGOT/ALT (U/L)\", add_baseline_hline = TRUE ) p"},{"path":"https://insightsengineering.github.io/tern/reference/h_ggkm.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create a KM plot — h_ggkm","title":"Helper function to create a KM plot — h_ggkm","text":"Draw Kaplan-Meier plot using ggplot2.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ggkm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create a KM plot — h_ggkm","text":"","code":"h_ggkm( data, xticks = NULL, yval = \"Survival\", censor_show, xlab, ylab, ylim = NULL, title, footnotes = NULL, max_time = NULL, lwd = 1, lty = NULL, pch = 3, size = 2, col = NULL, ci_ribbon = FALSE, ggtheme = nestcolor::theme_nest() )"},{"path":"https://insightsengineering.github.io/tern/reference/h_ggkm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create a KM plot — h_ggkm","text":"data (data.frame) survival data pre-processed h_data_plot. xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis. NULL (default), labeling::extended() used determine optimal tick positions x-axis. yval (string) type plot, plotted y-axis. Options Survival (default) Failure probability. censor_show (flag) whether show censored observations. xlab (string) x-axis label. ylab (string) y-axis label. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used. title (string) plot title. footnotes (string) plot footnotes. max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL). lwd (numeric) line width. vector given, length equal number strata survival::survfit(). lty (numeric) line type. vector given, length equal number strata survival::survfit(). pch (string) name symbol character use point symbol indicate censored cases. size (numeric(1)) size censored point symbols. col (character) lines colors. Length vector equal number strata survival::survfit(). ci_ribbon (flag) whether confidence interval drawn around Kaplan-Meier curve. ggtheme (theme) graphical theme provided ggplot2 format Kaplan-Meier plot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ggkm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create a KM plot — h_ggkm","text":"ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ggkm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create a KM plot — h_ggkm","text":"","code":"# \\donttest{ library(dplyr) library(survival) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", yval = \"Survival\", ylab = \"Survival Probability\", title = \"Survival\" ) gg # }"},{"path":"https://insightsengineering.github.io/tern/reference/h_glm_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for Poisson models — h_glm_count","title":"Helper functions for Poisson models — h_glm_count","text":"Helper functions returns results stats::glm() Poisson Quasi-Poisson distributions needed (see family parameter), MASS::glm.nb() Negative Binomial distributions. Link function GLM log.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_glm_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for Poisson models — h_glm_count","text":"","code":"h_glm_count(.var, .df_row, variables, distribution, weights) h_glm_poisson(.var, .df_row, variables, weights) h_glm_quasipoisson(.var, .df_row, variables, weights) h_glm_negbin(.var, .df_row, variables, weights)"},{"path":"https://insightsengineering.github.io/tern/reference/h_glm_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for Poisson models — h_glm_count","text":".var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) dataset includes variables called .var variables. variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". offset (numeric) numeric vector scalar adding offset. distribution (character) character value specifying distribution used regression (Poisson, Quasi-Poisson, negative binomial). weights (character) character vector specifying weights used averaging predictions. Number weights must equal number levels included covariates. Weights option passed emmeans::emmeans().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_glm_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for Poisson models — h_glm_count","text":"h_glm_count() returns results selected model. h_glm_poisson() returns results Poisson model. h_glm_quasipoisson() returns results Quasi-Poisson model. h_glm_negbin() returns results negative binomial model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_glm_count.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for Poisson models — h_glm_count","text":"h_glm_count(): Helper function return results selected model (Poisson, Quasi-Poisson, negative binomial). h_glm_poisson(): Helper function return results Poisson model. h_glm_quasipoisson(): Helper function return results Quasi-Poisson model. h_glm_negbin(): Helper function return results negative binomial model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_coxph.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create Cox-PH grobs — h_grob_coxph","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"Grob rtable output h_tbl_coxph_pairwise()","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_coxph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"","code":"h_grob_coxph( ..., x = 0, y = 0, width = grid::unit(0.4, \"npc\"), ttheme = gridExtra::ttheme_default(padding = grid::unit(c(1, 0.5), \"lines\"), core = list(bg_params = list(fill = c(\"grey95\", \"grey90\"), alpha = 0.5))) )"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_coxph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"... arguments pass h_tbl_coxph_pairwise(). x (proportion) value 0 1 specifying x-location. y (proportion) value 0 1 specifying y-location. width (grid::unit) width (unit) use printing grob. ttheme (list) see gridExtra::ttheme_default().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_coxph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"grob table containing statistics HR, XX% CI (XX taken control_coxph_pw), p-value (log-rank).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_coxph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"pink\", fill = \"gray85\", lwd = 1)) data <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) tbl_grob <- h_grob_coxph( df = data, variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARMCD\"), control_coxph_pw = control_coxph(conf_level = 0.9), x = 0.5, y = 0.5 ) #> Warning: `h_grob_coxph()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid::grid.draw(tbl_grob) # }"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_median_surv.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create survival estimation grobs — h_grob_median_surv","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"survival fit transformed grob containing table groups rows characterized N, median 95% confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_median_surv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"","code":"h_grob_median_surv( fit_km, armval = \"All\", x = 0.9, y = 0.9, width = grid::unit(0.3, \"npc\"), ttheme = gridExtra::ttheme_default() )"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_median_surv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"fit_km (survfit) result survival::survfit(). armval (string) used strata name treatment arm variable one level. Default \"\". x (proportion) value 0 1 specifying x-location. y (proportion) value 0 1 specifying y-location. width (grid::unit) width (unit) use printing grob. ttheme (list) see gridExtra::ttheme_default().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_median_surv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"grob table containing statistics N, Median, XX% CI (XX taken fit_km).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_median_surv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"pink\", fill = \"gray85\", lwd = 1)) tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_grob_median_surv() %>% grid::grid.draw() #> Warning: `h_grob_median_surv()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. # }"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_tbl_at_risk.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"Two graphical objects obtained, one corresponding row labeling second table numbers patients risk. title = TRUE, third object corresponding table title also obtained.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_tbl_at_risk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"","code":"h_grob_tbl_at_risk(data, annot_tbl, xlim, title = TRUE)"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_tbl_at_risk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"data (data.frame) survival data pre-processed h_data_plot. annot_tbl (data.frame) annotation prepared survival::summary.survfit() includes number patients risk given time points. xlim (numeric(1)) maximum value x-axis (used ensure risk table aligns KM graph). title (flag) whether \"Patients Risk\" title added annot_at_risk table. effect annot_at_risk FALSE. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_tbl_at_risk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"named list two gTree objects title = FALSE: at_risk label, three gTree objects title = TRUE: at_risk, label, title.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_tbl_at_risk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"tt\", footnotes = \"ff\", yval = \"Survival\" ) # The annotation table reports the patient at risk for a given strata and # times (`xticks`). annot_tbl <- summary(fit_km, times = xticks) if (is.null(fit_km$strata)) { annot_tbl <- with(annot_tbl, data.frame(n.risk = n.risk, time = time, strata = \"All\")) } else { strata_lst <- strsplit(sub(\"=\", \"equals\", levels(annot_tbl$strata)), \"equals\") levels(annot_tbl$strata) <- matrix(unlist(strata_lst), ncol = 2, byrow = TRUE)[, 2] annot_tbl <- data.frame( n.risk = annot_tbl$n.risk, time = annot_tbl$time, strata = annot_tbl$strata ) } # The annotation table is transformed into a grob. tbl <- h_grob_tbl_at_risk(data = data_plot, annot_tbl = annot_tbl, xlim = max(xticks)) #> Warning: `h_grob_tbl_at_risk()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. # For the representation, the layout is estimated for which the decomposition # of the graphic element is necessary. g_el <- h_decompose_gg(gg) lyt <- h_km_layout(data = data_plot, g_el = g_el, title = \"t\", footnotes = \"f\") #> Warning: `h_km_layout()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid::grid.newpage() pushViewport(viewport(layout = lyt, height = .95, width = .95)) grid.rect(gp = grid::gpar(lty = 1, col = \"purple\", fill = \"gray85\", lwd = 1)) pushViewport(viewport(layout.pos.row = 3:4, layout.pos.col = 2)) grid.rect(gp = grid::gpar(lty = 1, col = \"orange\", fill = \"gray85\", lwd = 1)) grid::grid.draw(tbl$at_risk) popViewport() pushViewport(viewport(layout.pos.row = 3:4, layout.pos.col = 1)) grid.rect(gp = grid::gpar(lty = 1, col = \"green3\", fill = \"gray85\", lwd = 1)) grid::grid.draw(tbl$label) # }"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_y_annot.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"Build y-axis annotation decomposed ggplot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_y_annot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"","code":"h_grob_y_annot(ylab, yaxis)"},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_y_annot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"ylab (gtable) y-lab graphical object derived ggplot. yaxis (gtable) y-axis graphical object derived ggplot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_y_annot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"gTree object containing y-axis annotation ggplot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_grob_y_annot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"title\", footnotes = \"footnotes\", yval = \"Survival\" ) g_el <- h_decompose_gg(gg) grid::grid.newpage() pvp <- grid::plotViewport(margins = c(5, 4, 2, 20)) pushViewport(pvp) grid::grid.draw(h_grob_y_annot(ylab = g_el$ylab, yaxis = g_el$yaxis)) #> Warning: `h_grob_y_annot()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid.rect(gp = grid::gpar(lty = 1, col = \"gray35\", fill = NA)) # }"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_incidence_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for incidence rate — h_incidence_rate","text":"","code":"h_incidence_rate(person_years, n_events, control = control_incidence_rate()) h_incidence_rate_normal(person_years, n_events, alpha = 0.05) h_incidence_rate_normal_log(person_years, n_events, alpha = 0.05) h_incidence_rate_exact(person_years, n_events, alpha = 0.05) h_incidence_rate_byar(person_years, n_events, alpha = 0.05)"},{"path":"https://insightsengineering.github.io/tern/reference/h_incidence_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for incidence rate — h_incidence_rate","text":"person_years (numeric(1)) total person-years risk. n_events (integer(1)) number events observed. control (list) parameters estimation details, specified using helper function control_incidence_rate(). Possible parameter options : conf_level: (proportion) confidence level estimated incidence rate. conf_type: (string)normal (default), normal_log, exact, byar confidence interval type. input_time_unit: (string)day, week, month, year (default) indicating time unit data input. num_pt_year: (numeric) time unit desired output (person-years). alpha (numeric(1)) two-sided alpha-level confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_incidence_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for incidence rate — h_incidence_rate","text":"Estimated incidence rate, rate, associated confidence interval, rate_ci.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_incidence_rate.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for incidence rate — h_incidence_rate","text":"h_incidence_rate(): Helper function estimate incidence rate associated confidence interval. h_incidence_rate_normal(): Helper function estimate incidence rate associated confidence interval based normal approximation incidence rate. Unit one person-year. h_incidence_rate_normal_log(): Helper function estimate incidence rate associated confidence interval based normal approximation logarithm incidence rate. Unit one person-year. h_incidence_rate_exact(): Helper function estimate incidence rate associated exact confidence interval. Unit one person-year. h_incidence_rate_byar(): Helper function estimate incidence rate associated Byar's confidence interval. Unit one person-year.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_incidence_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for incidence rate — h_incidence_rate","text":"","code":"h_incidence_rate_normal(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] -0.003859038 0.023859038 #> h_incidence_rate_normal_log(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] 0.002500977 0.039984382 #> h_incidence_rate_exact(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] 0.001211046 0.036123438 #> h_incidence_rate_byar(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] 0.001994207 0.032054171 #>"},{"path":"https://insightsengineering.github.io/tern/reference/h_km_layout.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to prepare a KM layout — h_km_layout","title":"Helper function to prepare a KM layout — h_km_layout","text":"Prepares (5 rows) x (2 cols) layout Kaplan-Meier curve.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_km_layout.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to prepare a KM layout — h_km_layout","text":"","code":"h_km_layout( data, g_el, title, footnotes, annot_at_risk = TRUE, annot_at_risk_title = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/h_km_layout.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to prepare a KM layout — h_km_layout","text":"data (data.frame) survival data pre-processed h_data_plot. g_el (list gtable) list obtained h_decompose_gg(). title (string) plot title. footnotes (string) plot footnotes. annot_at_risk (flag) compute add annotation table reporting number patient risk matching main grid Kaplan-Meier curve. annot_at_risk_title (flag) whether \"Patients Risk\" title added annot_at_risk table. effect annot_at_risk FALSE. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_km_layout.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to prepare a KM layout — h_km_layout","text":"grid layout.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_km_layout.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function to prepare a KM layout — h_km_layout","text":"layout corresponds grid two columns five rows unequal dimensions. dimension fixed, curve flexible accommodate remaining free space. left column gets annotation ggplot (y-axis) names strata patient risk tabulation. main constraint width columns must allow writing strata name. right column receive ggplot, legend, x-axis patient risk table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_km_layout.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to prepare a KM layout — h_km_layout","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"tt\", footnotes = \"ff\", yval = \"Survival\" ) g_el <- h_decompose_gg(gg) lyt <- h_km_layout(data = data_plot, g_el = g_el, title = \"t\", footnotes = \"f\") grid.show.layout(lyt) # }"},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for multivariate logistic regression — h_logistic_regression","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"Helper functions used calculations logistic regression.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"","code":"h_get_interaction_vars(fit_glm) h_interaction_coef_name( interaction_vars, first_var_with_level, second_var_with_level ) h_or_cat_interaction( odds_ratio_var, interaction_var, fit_glm, conf_level = 0.95 ) h_or_cont_interaction( odds_ratio_var, interaction_var, fit_glm, at = NULL, conf_level = 0.95 ) h_or_interaction( odds_ratio_var, interaction_var, fit_glm, at = NULL, conf_level = 0.95 ) h_simple_term_labels(terms, table) h_interaction_term_labels(terms1, terms2, table, any = FALSE) h_glm_simple_term_extract(x, fit_glm) h_glm_interaction_extract(x, fit_glm) h_glm_inter_term_extract(odds_ratio_var, interaction_var, fit_glm, ...) h_logistic_simple_terms(x, fit_glm, conf_level = 0.95) h_logistic_inter_terms(x, fit_glm, conf_level = 0.95, at = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"fit_glm (glm) logistic regression model fitted stats::glm() \"binomial\" family. Limited functionality also available conditional logistic regression models fitted survival::clogit(), currently used extract_rsp_biomarkers(). interaction_vars (character(2)) interaction variable names. first_var_with_level (character(2)) first variable name interaction level. second_var_with_level (character(2)) second variable name interaction level. odds_ratio_var (string) odds ratio variable. interaction_var (string) interaction variable. conf_level (proportion) confidence level interval. (numeric NULL) optional values interaction variable. Otherwise median used. terms (character) simple terms. table (table) table containing numbers terms. terms1 (character) terms first dimension (rows). terms2 (character) terms second dimension (rows). (flag) whether term1 term2 can fulfilled count number patients. case can scalar (strings). x (character) variable interaction term fit_glm (depending helper function used). ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"Vector names interaction variables. Name coefficient. Odds ratio. Odds ratio. Odds ratio. Term labels containing numbers patients. Term labels containing numbers patients. Tabulated main effect results logistic regression model. Tabulated interaction term results logistic regression model. data.frame tabulated interaction term results logistic regression model. Tabulated statistics given variable(s) logistic regression model. Tabulated statistics given variable(s) logistic regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"h_get_interaction_vars(): Helper function extract interaction variable names fitted model assuming one interaction term. h_interaction_coef_name(): Helper function get right coefficient name interaction variable names given levels. main value order first second variable checked interaction_vars input. h_or_cat_interaction(): Helper function calculate odds ratio estimates case odds ratio interaction variable categorical. h_or_cont_interaction(): Helper function calculate odds ratio estimates case either odds ratio interaction variable continuous. h_or_interaction(): Helper function calculate odds ratio estimates case interaction. wrapper h_or_cont_interaction() h_or_cat_interaction(). h_simple_term_labels(): Helper function construct term labels simple terms table numbers patients. h_interaction_term_labels(): Helper function construct term labels interaction terms table numbers patients. h_glm_simple_term_extract(): Helper function tabulate main effect results (conditional) logistic regression model. h_glm_interaction_extract(): Helper function tabulate interaction term results logistic regression model. h_glm_inter_term_extract(): Helper function tabulate interaction results logistic regression model. basically wrapper h_or_interaction() h_glm_simple_term_extract() puts results right data frame format. h_logistic_simple_terms(): Helper function tabulate results including odds ratios confidence intervals simple terms. h_logistic_inter_terms(): Helper function tabulate results including odds ratios confidence intervals interaction terms.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"provide function case variables continuous arise table, treatment arm variable always involved categorical.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_logistic_regression.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"","code":"library(dplyr) library(broom) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred h_glm_simple_term_extract(\"AGE\", mod1) #> variable variable_label term term_label interaction interaction_label #> 1 AGE Age AGE Age #> reference reference_label estimate std_error df pvalue #> 1 0.1698216 0.09524116 1 0.07457501 #> is_variable_summary is_term_summary #> 1 FALSE TRUE h_glm_simple_term_extract(\"ARMCD\", mod1) #> variable variable_label term term_label interaction #> 1 ARMCD Planned Arm Code ARM A Reference ARM A, n = 64 #> 2 ARMCD Planned Arm Code ARM B ARM B, n = 68 #> 3 ARMCD Planned Arm Code ARM C ARM C, n = 52 #> interaction_label reference reference_label estimate std_error df pvalue #> 1 2 0.3004308 #> 2 -1.774769 1.144405 1 0.1209443 #> 3 17.1922 3626.588 1 0.9962176 #> is_variable_summary is_term_summary #> 1 TRUE FALSE #> 2 FALSE TRUE #> 3 FALSE TRUE h_glm_interaction_extract(\"ARMCD:AGE\", mod2) #> variable variable_label term term_label #> 1 ARMCD:AGE Interaction of Planned Arm Code * Age ARM A Reference ARM A, n = 64 #> 2 ARMCD:AGE Interaction of Planned Arm Code * Age ARM B ARM B, n = 68 #> 3 ARMCD:AGE Interaction of Planned Arm Code * Age ARM C ARM C, n = 52 #> interaction interaction_label reference reference_label estimate std_error #> 1 #> 2 0.3081205 0.2062392 #> 3 0.02948826 548.5923 #> df pvalue is_variable_summary is_term_summary #> 1 2 0.3275837 TRUE FALSE #> 2 1 0.1351767 FALSE TRUE #> 3 1 0.9999571 FALSE TRUE h_glm_inter_term_extract(\"AGE\", \"ARMCD\", mod2) #> variable variable_label term term_label interaction interaction_label #> 1 AGE Age AGE Age #> 2 AGE Age AGE Age ARMCD Planned Arm Code #> 3 AGE Age AGE Age ARMCD Planned Arm Code #> 4 AGE Age AGE Age ARMCD Planned Arm Code #> reference reference_label estimate std_error odds_ratio lcl ucl #> 1 -0.03873898 0.1514322 NA NA NA #> 2 ARM A ARM A NA NA 0.9620018 0.7149514 1.294420 #> 3 ARM B ARM B NA NA 1.3091545 1.0021802 1.710157 #> 4 ARM C ARM C NA NA 0.9907919 0.0000000 Inf #> df pvalue is_variable_summary is_term_summary is_reference_summary #> 1 1 0.798092 FALSE TRUE FALSE #> 2 NA NA FALSE FALSE TRUE #> 3 NA NA FALSE FALSE TRUE #> 4 NA NA FALSE FALSE TRUE h_logistic_simple_terms(\"AGE\", mod1) #> variable variable_label term term_label interaction interaction_label #> 1 AGE Age AGE Age #> reference reference_label estimate std_error df pvalue #> 1 0.1698216 0.09524116 1 0.07457501 #> is_variable_summary is_term_summary odds_ratio lcl ucl #> 1 FALSE TRUE 1.185093 0.9832935 1.428308 #> ci #> 1 0.9832935, 1.4283084 h_logistic_inter_terms(c(\"RACE\", \"AGE\", \"ARMCD\", \"AGE:ARMCD\"), mod2) #> variable variable_label term #> 1 RACE Race ASIAN #> 2 RACE Race BLACK OR AFRICAN AMERICAN #> 3 RACE Race WHITE #> 13 ARMCD Planned Arm Code ARM A #> 23 ARMCD Planned Arm Code ARM B #> ARM B ARMCD Planned Arm Code ARM B #> 33 ARMCD Planned Arm Code ARM C #> ARM C ARMCD Planned Arm Code ARM C #> 11 AGE Age AGE #> 21 AGE Age AGE #> 31 AGE Age AGE #> 4 AGE Age AGE #> 12 AGE:ARMCD Interaction of Planned Arm Code * Age ARM A #> 22 AGE:ARMCD Interaction of Planned Arm Code * Age ARM B #> 32 AGE:ARMCD Interaction of Planned Arm Code * Age ARM C #> term_label interaction interaction_label reference #> 1 Reference ASIAN, n = 110 #> 2 BLACK OR AFRICAN AMERICAN, n = 40 #> 3 WHITE, n = 34 #> 13 Reference ARM A, n = 64 #> 23 ARM B, n = 68 #> ARM B ARM B, n = 68 AGE Age 35 #> 33 ARM C, n = 52 #> ARM C ARM C, n = 52 AGE Age 35 #> 11 Age #> 21 Age ARMCD Planned Arm Code ARM A #> 31 Age ARMCD Planned Arm Code ARM B #> 4 Age ARMCD Planned Arm Code ARM C #> 12 Reference ARM A, n = 64 #> 22 ARM B, n = 68 #> 32 ARM C, n = 52 #> reference_label estimate std_error df pvalue odds_ratio lcl #> 1 2 0.9361139 #> 2 18.15018 3944.701 1 0.9963288 76299564 0 #> 3 -0.3727152 1.025808 1 0.7163522 0.6888614 0.09224926 #> 13 2 0.253914 NA NA #> 23 -11.52715 6.96188 1 0.09777185 NA NA #> ARM B 35 NA NA NA NA 0.4757148 0.03361147 #> 33 16.33327 20278.39 1 0.9993573 NA NA #> ARM C 35 NA NA NA NA 34808099 0 #> 11 -0.03873898 0.1514322 1 0.798092 NA NA #> 21 ARM A NA NA NA NA 0.9620018 0.7149514 #> 31 ARM B NA NA NA NA 1.309155 1.00218 #> 4 ARM C NA NA NA NA 0.9907919 0 #> 12 NA NA NA NA #> 22 0.3081205 0.2062392 1 0.1351767 NA NA #> 32 0.02948826 548.5923 1 0.9999571 NA NA #> ucl is_variable_summary is_term_summary is_reference_summary #> 1 TRUE FALSE FALSE #> 2 Inf FALSE TRUE FALSE #> 3 5.143998 FALSE TRUE FALSE #> 13 NA TRUE FALSE FALSE #> 23 NA FALSE TRUE FALSE #> ARM B 6.732956 FALSE FALSE TRUE #> 33 NA FALSE TRUE FALSE #> ARM C Inf FALSE FALSE TRUE #> 11 NA FALSE TRUE FALSE #> 21 1.29442 FALSE FALSE TRUE #> 31 1.710157 FALSE FALSE TRUE #> 4 Inf FALSE FALSE TRUE #> 12 NA TRUE FALSE FALSE #> 22 NA FALSE TRUE FALSE #> 32 NA FALSE TRUE FALSE #> ci #> 1 #> 2 0, Inf #> 3 0.09224926, 5.14399810 #> 13 NA, NA #> 23 NA, NA #> ARM B 0.03361147, 6.73295611 #> 33 NA, NA #> ARM C 0, Inf #> 11 NA, NA #> 21 0.7149514, 1.2944200 #> 31 1.002180, 1.710157 #> 4 0, Inf #> 12 NA, NA #> 22 NA, NA #> 32 NA, NA"},{"path":"https://insightsengineering.github.io/tern/reference/h_map_for_count_abnormal.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"Helper function create map data frame input dataset, can used argument trim_levels_to_map split function. Based different method, map constructed differently.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_map_for_count_abnormal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"","code":"h_map_for_count_abnormal( df, variables = list(anl = \"ANRIND\", split_rows = c(\"PARAM\"), range_low = \"ANRLO\", range_high = \"ANRHI\"), abnormal = list(low = c(\"LOW\", \"LOW LOW\"), high = c(\"HIGH\", \"HIGH HIGH\")), method = c(\"default\", \"range\"), na_str = \"\" )"},{"path":"https://insightsengineering.github.io/tern/reference/h_map_for_count_abnormal.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"df (data.frame) data set containing analysis variables. variables (named list string) list additional analysis variables. abnormal (named list) identifying abnormal range level(s) df. Based levels abnormality input dataset, can something like list(Low = \"LOW LOW\", High = \"HIGH HIGH\") abnormal = list(Low = \"LOW\", High = \"HIGH\")) method (string) indicates returned map constructed. Can \"default\" \"range\". na_str (string) string used replace NA empty values output.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_map_for_count_abnormal.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"map data.frame.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_map_for_count_abnormal.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"method \"default\", returned map abnormal directions observed df, records normal values excluded avoid error creating layout. method \"range\", returned map based rule least one observation low range > 0 low direction least one observation high range missing high direction.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_map_for_count_abnormal.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"","code":"adlb <- df_explicit_na(tern_ex_adlb) h_map_for_count_abnormal( df = adlb, variables = list(anl = \"ANRIND\", split_rows = c(\"LBCAT\", \"PARAM\")), abnormal = list(low = c(\"LOW\"), high = c(\"HIGH\")), method = \"default\", na_str = \"\" ) #> LBCAT PARAM ANRIND #> 1 CHEMISTRY Alanine Aminotransferase Measurement LOW #> 4 CHEMISTRY Alanine Aminotransferase Measurement HIGH #> 7 CHEMISTRY Alanine Aminotransferase Measurement NORMAL #> 2 CHEMISTRY C-Reactive Protein Measurement LOW #> 3 CHEMISTRY C-Reactive Protein Measurement HIGH #> 8 CHEMISTRY C-Reactive Protein Measurement NORMAL #> 5 IMMUNOLOGY Immunoglobulin A Measurement LOW #> 6 IMMUNOLOGY Immunoglobulin A Measurement HIGH #> 9 IMMUNOLOGY Immunoglobulin A Measurement NORMAL df <- data.frame( USUBJID = c(rep(\"1\", 4), rep(\"2\", 4), rep(\"3\", 4)), AVISIT = c( rep(\"WEEK 1\", 2), rep(\"WEEK 2\", 2), rep(\"WEEK 1\", 2), rep(\"WEEK 2\", 2), rep(\"WEEK 1\", 2), rep(\"WEEK 2\", 2) ), PARAM = rep(c(\"ALT\", \"CPR\"), 6), ANRIND = c( \"NORMAL\", \"NORMAL\", \"LOW\", \"HIGH\", \"LOW\", \"LOW\", \"HIGH\", \"HIGH\", rep(\"NORMAL\", 4) ), ANRLO = rep(5, 12), ANRHI = rep(20, 12) ) df$ANRIND <- factor(df$ANRIND, levels = c(\"LOW\", \"HIGH\", \"NORMAL\")) h_map_for_count_abnormal( df = df, variables = list( anl = \"ANRIND\", split_rows = c(\"PARAM\"), range_low = \"ANRLO\", range_high = \"ANRHI\" ), abnormal = list(low = c(\"LOW\"), high = c(\"HIGH\")), method = \"range\", na_str = \"\" ) #> PARAM ANRIND #> 1 ALT LOW #> 3 ALT HIGH #> 5 ALT NORMAL #> 2 CPR LOW #> 4 CPR HIGH #> 6 CPR NORMAL"},{"path":"https://insightsengineering.github.io/tern/reference/h_odds_ratio.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for odds ratio estimation — h_odds_ratio","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"Functions calculate odds ratios estimate_odds_ratio().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_odds_ratio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"","code":"or_glm(data, conf_level) or_clogit(data, conf_level, method = \"exact\")"},{"path":"https://insightsengineering.github.io/tern/reference/h_odds_ratio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"data (data.frame) data frame containing least variables rsp grp, optionally strata or_clogit(). conf_level (proportion) confidence level interval. method (string) whether use correct (\"exact\") calculation conditional likelihood one approximations. See survival::clogit() details.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_odds_ratio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"named list elements or_ci n_tot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_odds_ratio.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"or_glm(): Estimates odds ratio based stats::glm(). Note must exactly 2 groups data specified grp variable. or_clogit(): Estimates odds ratio based survival::clogit(). done whole data set including groups, since results pairwise comparisons groups.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_odds_ratio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"","code":"# Data with 2 groups. data <- data.frame( rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1)), grp = letters[c(1, 1, 1, 2, 2, 2, 1, 2)], strata = letters[c(1, 2, 1, 2, 2, 2, 1, 2)], stringsAsFactors = TRUE ) # Odds ratio based on glm. or_glm(data, conf_level = 0.95) #> $or_ci #> est lcl ucl #> 0.33333333 0.01669735 6.65441589 #> #> $n_tot #> n_tot #> 8 #> # Data with 3 groups. data <- data.frame( rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)), grp = letters[c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3)], strata = LETTERS[c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)], stringsAsFactors = TRUE ) # Odds ratio based on stratified estimation by conditional logistic regression. or_clogit(data, conf_level = 0.95) #> $or_ci #> $or_ci$b #> est lcl ucl #> 0.28814553 0.02981009 2.78522598 #> #> $or_ci$c #> est lcl ucl #> 0.5367919 0.0673365 4.2791881 #> #> #> $n_tot #> n_tot #> 20 #>"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_pkparam_sort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"","code":"h_pkparam_sort(pk_data, key_var = \"PARAMCD\")"},{"path":"https://insightsengineering.github.io/tern/reference/h_pkparam_sort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"pk_data (data.frame) pharmacokinetic data frame. key_var (string) key variable used merge pk_data metadata created d_pkparam().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_pkparam_sort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"pharmacokinetic data.frame sorted PARAM variable.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_pkparam_sort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"","code":"library(dplyr) adpp <- tern_ex_adpp %>% mutate(PKPARAM = factor(paste0(PARAM, \" (\", AVALU, \")\"))) pk_ordered_data <- h_pkparam_sort(adpp)"},{"path":"https://insightsengineering.github.io/tern/reference/h_ppmeans.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to return the estimated means using predicted probabilities — h_ppmeans","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"arm level, predicted mean rate calculated using fitted model object, newdata set result stats::model.frame, reconstructed data original data, depending object formula (coming fit). confidence interval derived using conf_level parameter.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ppmeans.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"","code":"h_ppmeans(obj, .df_row, arm, conf_level)"},{"path":"https://insightsengineering.github.io/tern/reference/h_ppmeans.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"obj (glm.fit) fitted model object used derive mean rate estimates treatment arm. .df_row (data.frame) dataset includes variables called .var variables. arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. conf_level (proportion) value used derive confidence interval rate.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_ppmeans.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"h_ppmeans() returns estimated means.","code":""},{"path":[]},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"","code":"prop_diff_wald(rsp, grp, conf_level = 0.95, correct = FALSE) prop_diff_ha(rsp, grp, conf_level) prop_diff_nc(rsp, grp, conf_level, correct = FALSE) prop_diff_cmh(rsp, grp, strata, conf_level = 0.95) prop_diff_strat_nc( rsp, grp, strata, weights_method = c(\"cmh\", \"wilson_h\"), conf_level = 0.95, correct = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"rsp (logical) vector indicating whether subject responder . grp (factor) vector assigning observations one two groups (e.g. reference treatment group). conf_level (proportion) confidence level interval. correct (flag) whether include continuity correction. information, see stats::prop.test(). strata (factor) variable one level per stratum length rsp. weights_method (string) weights method. Can either \"cmh\" \"heuristic\" directs way weights estimated.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"named list elements diff (proportion difference) diff_ci (proportion difference confidence interval).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"prop_diff_wald(): Wald interval follows usual textbook definition single proportion confidence interval using normal approximation. possible include continuity correction Wald's interval. prop_diff_ha(): Anderson-Hauck confidence interval. prop_diff_nc(): Newcombe confidence interval. based Wilson score confidence interval single binomial proportion. prop_diff_cmh(): Calculates weighted difference. defined difference response rates experimental treatment group control treatment group, adjusted stratification factors applying Cochran-Mantel-Haenszel (CMH) weights. CMH chi-squared test, use stats::mantelhaen.test(). prop_diff_strat_nc(): Calculates stratified Newcombe confidence interval difference response rates experimental treatment group control treatment group, adjusted stratification factors. implementation follows closely one proposed Yan2010-jt;textualtern. Weights can estimated heuristic proposed prop_strat_wilson() CMH-derived weights (see prop_diff_cmh()).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"Yan2010-jttern","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"","code":"# Wald confidence interval set.seed(2) rsp <- sample(c(TRUE, FALSE), replace = TRUE, size = 20) grp <- factor(c(rep(\"A\", 10), rep(\"B\", 10))) prop_diff_wald(rsp = rsp, grp = grp, conf_level = 0.95, correct = FALSE) #> $diff #> [1] 0 #> #> $diff_ci #> [1] -0.4382613 0.4382613 #> # Anderson-Hauck confidence interval ## \"Mid\" case: 3/4 respond in group A, 1/2 respond in group B. rsp <- c(TRUE, FALSE, FALSE, TRUE, TRUE, TRUE) grp <- factor(c(\"A\", \"B\", \"A\", \"B\", \"A\", \"A\"), levels = c(\"B\", \"A\")) prop_diff_ha(rsp = rsp, grp = grp, conf_level = 0.90) #> $diff #> [1] 0.25 #> #> $diff_ci #> [1] -0.9195011 1.0000000 #> ## Edge case: Same proportion of response in A and B. rsp <- c(TRUE, FALSE, TRUE, FALSE) grp <- factor(c(\"A\", \"A\", \"B\", \"B\"), levels = c(\"A\", \"B\")) prop_diff_ha(rsp = rsp, grp = grp, conf_level = 0.6) #> $diff #> [1] 0 #> #> $diff_ci #> [1] -0.8451161 0.8451161 #> # Newcombe confidence interval set.seed(1) rsp <- c( sample(c(TRUE, FALSE), size = 40, prob = c(3 / 4, 1 / 4), replace = TRUE), sample(c(TRUE, FALSE), size = 40, prob = c(1 / 2, 1 / 2), replace = TRUE) ) grp <- factor(rep(c(\"A\", \"B\"), each = 40), levels = c(\"B\", \"A\")) table(rsp, grp) #> grp #> rsp B A #> FALSE 20 10 #> TRUE 20 30 prop_diff_nc(rsp = rsp, grp = grp, conf_level = 0.9) #> $diff #> [1] 0.25 #> #> $diff_ci #> [1] 0.07193388 0.40725819 #> # Cochran-Mantel-Haenszel confidence interval set.seed(2) rsp <- sample(c(TRUE, FALSE), 100, TRUE) grp <- sample(c(\"Placebo\", \"Treatment\"), 100, TRUE) grp <- factor(grp, levels = c(\"Placebo\", \"Treatment\")) strata_data <- data.frame( \"f1\" = sample(c(\"a\", \"b\"), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), stringsAsFactors = TRUE ) prop_diff_cmh( rsp = rsp, grp = grp, strata = interaction(strata_data), conf_level = 0.90 ) #> $prop #> Placebo Treatment #> 0.5331117 0.3954251 #> #> $prop_ci #> $prop_ci$Placebo #> [1] 0.4306536 0.6355698 #> #> $prop_ci$Treatment #> [1] 0.2890735 0.5017768 #> #> #> $diff #> [1] -0.1376866 #> #> $diff_ci #> [1] -0.285363076 0.009989872 #> #> $weights #> a.x b.x a.y b.y a.z b.z #> 0.1148388 0.2131696 0.1148388 0.2131696 0.1767914 0.1671918 #> #> $n1 #> a.x b.x a.y b.y a.z b.z #> 4 11 8 11 13 11 #> #> $n2 #> a.x b.x a.y b.y a.z b.z #> 8 9 4 9 6 6 #> # Stratified Newcombe confidence interval set.seed(2) data_set <- data.frame( \"rsp\" = sample(c(TRUE, FALSE), 100, TRUE), \"f1\" = sample(c(\"a\", \"b\"), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), \"grp\" = sample(c(\"Placebo\", \"Treatment\"), 100, TRUE), stringsAsFactors = TRUE ) prop_diff_strat_nc( rsp = data_set$rsp, grp = data_set$grp, strata = interaction(data_set[2:3]), weights_method = \"cmh\", conf_level = 0.90 ) #> $diff #> [1] -0.05777672 #> #> $diff_ci #> lower upper #> -0.2236537 0.1119331 #> prop_diff_strat_nc( rsp = data_set$rsp, grp = data_set$grp, strata = interaction(data_set[2:3]), weights_method = \"wilson_h\", conf_level = 0.90 ) #> $diff #> [1] -0.07771884 #> #> $diff_ci #> lower upper #> -0.2540844 0.1027720 #>"},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions to test proportion differences — h_prop_diff_test","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"Helper functions implement various tests difference two proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"","code":"prop_chisq(tbl) prop_cmh(ary) prop_schouten(tbl) prop_fisher(tbl)"},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"tbl (matrix) matrix two groups rows binary response (TRUE/FALSE) columns. ary (array, 3 dimensions) array two groups rows, binary response (TRUE/FALSE) columns, strata third dimension.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_prop_diff_test.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"prop_chisq(): Performs Chi-Squared test. Internally calls stats::prop.test(). prop_cmh(): Performs stratified Cochran-Mantel-Haenszel test. Internally calls stats::mantelhaen.test(). Note strata less two observations automatically discarded. prop_schouten(): Performs Chi-Squared test Schouten correction. prop_fisher(): Performs Fisher's exact test. Internally calls stats::fisher.test().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for calculating proportion confidence intervals — h_proportions","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"Functions calculate different proportion confidence intervals use estimate_proportion().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"","code":"prop_wilson(rsp, conf_level, correct = FALSE) prop_strat_wilson( rsp, strata, weights = NULL, conf_level = 0.95, max_iterations = NULL, correct = FALSE ) prop_clopper_pearson(rsp, conf_level) prop_wald(rsp, conf_level, correct = FALSE) prop_agresti_coull(rsp, conf_level) prop_jeffreys(rsp, conf_level)"},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"rsp (logical) vector indicating whether subject responder . conf_level (proportion) confidence level interval. correct (flag) whether apply continuity correction. strata (factor) variable one level per stratum length rsp. weights (numeric NULL) weights level strata. NULL, estimated using iterative algorithm proposed Yan2010-jt;textualtern minimizes weighted squared length confidence interval. max_iterations (count) maximum number iterations iterative procedure used find estimates optimal weights.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"Confidence interval proportion.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"prop_wilson(): Calculates Wilson interval calling stats::prop.test(). Also referred Wilson score interval. prop_strat_wilson(): Calculates stratified Wilson confidence interval unequal proportions described Yan2010-jt;textualtern prop_clopper_pearson(): Calculates Clopper-Pearson interval calling stats::binom.test(). Also referred exact method. prop_wald(): Calculates Wald interval following usual textbook definition single proportion confidence interval using normal approximation. prop_agresti_coull(): Calculates Agresti-Coull interval. Constructed (95% CI) adding two successes two failures data using Wald formula construct CI. prop_jeffreys(): Calculates Jeffreys interval, equal-tailed interval based non-informative Jeffreys prior binomial proportion.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"Yan2010-jttern","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_proportions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"","code":"rsp <- c( TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE ) prop_wilson(rsp, conf_level = 0.9) #> [1] 0.2692718 0.7307282 # Stratified Wilson confidence interval with unequal probabilities set.seed(1) rsp <- sample(c(TRUE, FALSE), 100, TRUE) strata_data <- data.frame( \"f1\" = sample(c(\"a\", \"b\"), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), stringsAsFactors = TRUE ) strata <- interaction(strata_data) n_strata <- ncol(table(rsp, strata)) # Number of strata prop_strat_wilson( rsp = rsp, strata = strata, conf_level = 0.90 ) #> $conf_int #> lower upper #> 0.4072891 0.5647887 #> #> $weights #> a.x b.x a.y b.y a.z b.z #> 0.2074199 0.1776464 0.1915610 0.1604678 0.1351096 0.1277952 #> # Not automatic setting of weights prop_strat_wilson( rsp = rsp, strata = strata, weights = rep(1 / n_strata, n_strata), conf_level = 0.90 ) #> $conf_int #> lower upper #> 0.4190436 0.5789733 #> prop_clopper_pearson(rsp, conf_level = .95) #> [1] 0.3886442 0.5919637 prop_wald(rsp, conf_level = 0.95) #> [1] 0.3920214 0.5879786 prop_wald(rsp, conf_level = 0.95, correct = TRUE) #> [1] 0.3870214 0.5929786 prop_agresti_coull(rsp, conf_level = 0.95) #> [1] 0.3942193 0.5865206 prop_jeffreys(rsp, conf_level = 0.95) #> [1] 0.3934779 0.5870917"},{"path":"https://insightsengineering.github.io/tern/reference/h_response_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"Helper functions documented separately confuse user reading user-facing functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"","code":"h_rsp_to_logistic_variables(variables, biomarker) h_logistic_mult_cont_df(variables, data, control = control_logistic()) h_tab_rsp_one_biomarker(df, vars, na_str = default_na_str(), .indent_mods = 0L)"},{"path":"https://insightsengineering.github.io/tern/reference/h_response_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"variables (named list string) list additional analysis variables. biomarker (string) name biomarker variable. data (data.frame) dataset containing variables summarize. control (named list) controls response definition confidence level produced control_logistic(). df (data.frame) results single biomarker, part returned extract_rsp_biomarkers() (needs couple columns added high-level function relative returned h_logistic_mult_cont_df(), see example). vars (character) names statistics reported among: n_tot: Total number patients per group. n_rsp: Total number responses per group. prop: Total response proportion per group. : Odds ratio. ci: Confidence interval odds ratio. pval: p-value effect. Note, statistics n_tot, ci required. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"h_rsp_to_logistic_variables() returns named list elements response, arm, covariates, strata. h_logistic_mult_cont_df() returns data.frame containing estimates statistics selected biomarkers. h_tab_rsp_one_biomarker() returns rtables table object given statistics arranged columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_biomarkers_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"h_rsp_to_logistic_variables(): helps converting \"response\" function variable list \"logistic regression\" variable list. reason currently inconsistency variable names accepted extract_rsp_subgroups() fit_logistic(). h_logistic_mult_cont_df(): prepares estimates number responses, patients overall response rate, well odds ratio estimates, confidence intervals p-values, multiple biomarkers given single data set. variables corresponds names variables found data, passed named list requires elements rsp biomarkers (vector continuous biomarker variables) optionally covariates strata. h_tab_rsp_one_biomarker(): Prepares single sub-table given df_sub containing results single biomarker.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% mutate(rsp = AVALC == \"CR\") formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") # This is how the variable list is converted internally. h_rsp_to_logistic_variables( variables = list( rsp = \"RSP\", covariates = c(\"A\", \"B\"), strata = \"D\" ), biomarker = \"AGE\" ) #> $response #> [1] \"RSP\" #> #> $arm #> [1] \"AGE\" #> #> $covariates #> [1] \"A\" \"B\" #> #> $strata #> [1] \"D\" #> # For a single population, estimate separately the effects # of two biomarkers. df <- h_logistic_mult_cont_df( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\" ), data = adrs_f ) df #> biomarker biomarker_label n_tot n_rsp prop or lcl #> 1 BMRKR1 Continuous Level Biomarker 1 200 164 0.82 0.9755036 0.8804862 #> 2 AGE Age 200 164 0.82 0.9952416 0.9462617 #> ucl conf_level pval pval_label #> 1 1.080775 0.95 0.6352602 p-value (Wald) #> 2 1.046757 0.95 0.8530389 p-value (Wald) # If the data set is empty, still the corresponding rows with missings are returned. h_coxreg_mult_cont_df( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", strata = \"STRATA1\" ), data = adrs_f[NULL, ] ) #> biomarker biomarker_label n_tot n_tot_events median hr lcl ucl #> 1 BMRKR1 Continuous Level Biomarker 1 0 0 NA NA NA NA #> 2 AGE Age 0 0 NA NA NA NA #> conf_level pval pval_label #> 1 0.95 NA p-value (Wald) #> 2 0.95 NA p-value (Wald) # Starting from above `df`, zoom in on one biomarker and add required columns. df1 <- df[1, ] df1$subgroup <- \"All patients\" df1$row_type <- \"content\" df1$var <- \"ALL\" df1$var_label <- \"All patients\" h_tab_rsp_one_biomarker( df1, vars = c(\"n_tot\", \"n_rsp\", \"prop\", \"or\", \"ci\", \"pval\") ) #> Total n Responders Response (%) Odds Ratio 95% CI p-value (Wald) #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> All patients 200 164 82.0% 0.98 (0.88, 1.08) 0.6353"},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"Helper functions tabulate data frame statistics response rate odds ratio population subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"","code":"h_proportion_df(rsp, arm) h_proportion_subgroups_df( variables, data, groups_lists = list(), label_all = \"All Patients\" ) h_odds_ratio_df(rsp, arm, strata_data = NULL, conf_level = 0.95, method = NULL) h_odds_ratio_subgroups_df( variables, data, groups_lists = list(), conf_level = 0.95, method = NULL, label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"rsp (logical) vector indicating whether subject responder . arm (factor) treatment group variable. variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all (string) label total population analysis. strata_data (factor, data.frame, NULL) required stratified analysis performed. conf_level (proportion) confidence level interval. method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"h_proportion_df() returns data.frame columns arm, n, n_rsp, prop. h_proportion_subgroups_df() returns data.frame columns arm, n, n_rsp, prop, subgroup, var, var_label, row_type. h_odds_ratio_df() returns data.frame columns arm, n_tot, , lcl, ucl, conf_level, optionally pval pval_label. h_odds_ratio_subgroups_df() returns data.frame columns arm, n_tot, , lcl, ucl, conf_level, subgroup, var, var_label, row_type.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"Main functionality prepare data use layout-creating function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"h_proportion_df(): Helper prepare data frame binary responses arm. h_proportion_subgroups_df(): Summarizes proportion binary responses arm across subgroups data frame. variables corresponds names variables found data, passed named list requires elements rsp, arm optionally subgroups. groups_lists optionally specifies groupings subgroups variables. h_odds_ratio_df(): Helper prepare data frame estimates odds ratio treatment control arm. h_odds_ratio_subgroups_df(): Summarizes estimates odds ratio treatment control arm across subgroups data frame. variables corresponds names variables found data, passed named list requires elements rsp, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_response_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>% droplevels() %>% mutate( # Reorder levels of factor to make the placebo group the reference arm. ARM = fct_relevel(ARM, \"B: Placebo\"), rsp = AVALC == \"CR\" ) formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") h_proportion_df( c(TRUE, FALSE, FALSE), arm = factor(c(\"A\", \"A\", \"B\"), levels = c(\"A\", \"B\")) ) #> arm n n_rsp prop #> 1 A 2 1 0.5 #> 2 B 1 0 0.0 h_proportion_subgroups_df( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f ) #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2 #> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2 #> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2 #> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2 #> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2 #> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Define groupings for BMRKR2 levels. h_proportion_subgroups_df( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 low BMRKR2 #> 8 A: Drug X 26 21 0.8076923 low BMRKR2 #> 9 B: Placebo 47 30 0.6382979 low/medium BMRKR2 #> 10 A: Drug X 52 44 0.8461538 low/medium BMRKR2 #> 11 B: Placebo 73 50 0.6849315 low/medium/high BMRKR2 #> 12 A: Drug X 69 59 0.8550725 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Unstratatified analysis. h_odds_ratio_df( c(TRUE, FALSE, FALSE, TRUE), arm = factor(c(\"A\", \"A\", \"B\", \"B\"), levels = c(\"A\", \"B\")) ) #> arm n_tot or lcl ucl conf_level #> 1 4 1 0.01984252 50.39681 0.95 # Include p-value. h_odds_ratio_df(adrs_f$rsp, adrs_f$ARM, method = \"chisq\") #> arm n_tot or lcl ucl conf_level pval #> 1 142 2.714 1.180449 6.239827 0.95 0.01643036 #> pval_label #> 1 p-value (Chi-Squared Test) # Stratatified analysis. h_odds_ratio_df( rsp = adrs_f$rsp, arm = adrs_f$ARM, strata_data = adrs_f[, c(\"STRATA1\", \"STRATA2\")], method = \"cmh\" ) #> arm n_tot or lcl ucl conf_level pval #> 1 142 2.665586 1.146149 6.199324 0.95 0.02019665 #> pval_label #> 1 p-value (Cochran-Mantel-Haenszel Test) # Unstratified analysis. h_odds_ratio_subgroups_df( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f ) #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.1804488 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.2669576 51.452218 0.95 F SEX #> 3 64 0.920000 0.2966470 2.853223 0.95 M SEX #> 4 50 3.553846 1.0047370 12.570277 0.95 LOW BMRKR2 #> 5 49 2.705882 0.5911718 12.385232 0.95 MEDIUM BMRKR2 #> 6 43 2.250000 0.3970298 12.750933 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis # Stratified analysis. h_odds_ratio_subgroups_df( variables = list( rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\"), strata = c(\"STRATA1\", \"STRATA2\") ), data = adrs_f ) #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.6655860 1.1461490 6.199324 0.95 All Patients ALL #> 2 78 7.7065093 1.5817529 37.547132 0.95 F SEX #> 3 64 0.9572284 0.2990954 3.063525 0.95 M SEX #> 4 50 3.0323726 0.8833232 10.409875 0.95 LOW BMRKR2 #> 5 49 2.1264996 0.4312008 10.486995 0.95 MEDIUM BMRKR2 #> 6 43 2.5134820 0.4351747 14.517370 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis # Define groupings of BMRKR2 levels. h_odds_ratio_subgroups_df( variables = list( rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.180449 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.266958 51.452218 0.95 F SEX #> 3 64 0.920000 0.296647 2.853223 0.95 M SEX #> 4 50 3.553846 1.004737 12.570277 0.95 low BMRKR2 #> 5 99 3.116667 1.193409 8.139385 0.95 low/medium BMRKR2 #> 6 142 2.714000 1.180449 6.239827 0.95 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis"},{"path":"https://insightsengineering.github.io/tern/reference/h_split_by_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Split data frame by subgroups — h_split_by_subgroups","title":"Split data frame by subgroups — h_split_by_subgroups","text":"Split data frame non-nested list subsets.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_by_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split data frame by subgroups — h_split_by_subgroups","text":"","code":"h_split_by_subgroups(data, subgroups, groups_lists = list())"},{"path":"https://insightsengineering.github.io/tern/reference/h_split_by_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split data frame by subgroups — h_split_by_subgroups","text":"data (data.frame) dataset split. subgroups (character) names factor variables data used create subsets. Unused levels present data dropped. Note order vector determines order downstream table. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_by_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split data frame by subgroups — h_split_by_subgroups","text":"list subset data (df) metadata subset (df_labels).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_by_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Split data frame by subgroups — h_split_by_subgroups","text":"Main functionality prepare data use forest plot layouts.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_by_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split data frame by subgroups — h_split_by_subgroups","text":"","code":"df <- data.frame( x = c(1:5), y = factor(c(\"A\", \"B\", \"A\", \"B\", \"A\"), levels = c(\"A\", \"B\", \"C\")), z = factor(c(\"C\", \"C\", \"D\", \"D\", \"D\"), levels = c(\"D\", \"C\")) ) formatters::var_labels(df) <- paste(\"label for\", names(df)) h_split_by_subgroups( data = df, subgroups = c(\"y\", \"z\") ) #> $y.A #> $y.A$df #> x y z #> 1 1 A C #> 2 3 A D #> 3 5 A D #> #> $y.A$df_labels #> subgroup var var_label #> 1 A y label for y #> #> #> $y.B #> $y.B$df #> x y z #> 1 2 B C #> 2 4 B D #> #> $y.B$df_labels #> subgroup var var_label #> 1 B y label for y #> #> #> $z.D #> $z.D$df #> x y z #> 1 3 A D #> 2 4 B D #> 3 5 A D #> #> $z.D$df_labels #> subgroup var var_label #> 1 D z label for z #> #> #> $z.C #> $z.C$df #> x y z #> 1 1 A C #> 2 2 B C #> #> $z.C$df_labels #> subgroup var var_label #> 1 C z label for z #> #> h_split_by_subgroups( data = df, subgroups = c(\"y\", \"z\"), groups_lists = list( y = list(\"AB\" = c(\"A\", \"B\"), \"C\" = \"C\") ) ) #> $y.AB #> $y.AB$df #> x y z #> 1 1 A C #> 2 2 B C #> 3 3 A D #> 4 4 B D #> 5 5 A D #> #> $y.AB$df_labels #> subgroup var var_label #> 1 AB y label for y #> #> #> $z.D #> $z.D$df #> x y z #> 1 3 A D #> 2 4 B D #> 3 5 A D #> #> $z.D$df_labels #> subgroup var var_label #> 1 D z label for z #> #> #> $z.C #> $z.C$df #> x y z #> 1 1 A C #> 2 2 B C #> #> $z.C$df_labels #> subgroup var var_label #> 1 C z label for z #> #>"},{"path":"https://insightsengineering.github.io/tern/reference/h_split_param.html","id":null,"dir":"Reference","previous_headings":"","what":"Split parameters — h_split_param","title":"Split parameters — h_split_param","text":"divides data vector param groups defined f based specified values. relevant rtables layers distribute parameters .stats ' .formats lists items corresponding specific analysis function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_param.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split parameters — h_split_param","text":"","code":"h_split_param(param, value, f)"},{"path":"https://insightsengineering.github.io/tern/reference/h_split_param.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split parameters — h_split_param","text":"param (vector) parameter split. value (vector) value used split. f (list) reference make split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_param.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split parameters — h_split_param","text":"named list element names f, containing elements specified .stats.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_split_param.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split parameters — h_split_param","text":"","code":"f <- list( surv = c(\"pt_at_risk\", \"event_free_rate\", \"rate_se\", \"rate_ci\"), surv_diff = c(\"rate_diff\", \"rate_diff_ci\", \"ztest_pval\") ) .stats <- c(\"pt_at_risk\", \"rate_diff\") h_split_param(.stats, .stats, f = f) #> $surv #> [1] \"pt_at_risk\" #> #> $surv_diff #> [1] \"rate_diff\" #> # $surv # [1] \"pt_at_risk\" # # $surv_diff # [1] \"rate_diff\" .formats <- c(\"pt_at_risk\" = \"xx\", \"event_free_rate\" = \"xxx\") h_split_param(.formats, names(.formats), f = f) #> $surv #> pt_at_risk event_free_rate #> \"xx\" \"xxx\" #> #> $surv_diff #> NULL #> # $surv # pt_at_risk event_free_rate # \"xx\" \"xxx\" # # $surv_diff # NULL"},{"path":"https://insightsengineering.github.io/tern/reference/h_stack_by_baskets.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"Helper function create new SMQ variable ADAE consists adverse events belonging selected Standardized/Customized queries. new dataset contain records adverse events belonging selected baskets. Remember na_str must match needed pre-processing done df_explicit_na() desired output.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_stack_by_baskets.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"","code":"h_stack_by_baskets( df, baskets = grep(\"^(SMQ|CQ).+NAM$\", names(df), value = TRUE), smq_varlabel = \"Standardized MedDRA Query\", keys = c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"AEDECOD\", \"AESEQ\"), aag_summary = NULL, na_str = \"\" )"},{"path":"https://insightsengineering.github.io/tern/reference/h_stack_by_baskets.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"df (data.frame) data set containing analysis variables. baskets (character) variable names selected Standardized/Customized queries. smq_varlabel (string) label new variable created. keys (character) names key variables returned along new variable created. aag_summary (data.frame) containing SMQ baskets levels interest final SMQ variable. useful levels interest observed df dataset. two columns dataset named basket basket_name. na_str (string) string used replace NA empty values output.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_stack_by_baskets.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"data.frame variables keys taken df new variable SMQ containing records belonging baskets selected via baskets argument.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_stack_by_baskets.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"","code":"adae <- tern_ex_adae[1:20, ] %>% df_explicit_na() h_stack_by_baskets(df = adae) #> # A tibble: 8 × 6 #> STUDYID USUBJID ASTDTM AEDECOD AESEQ SMQ #> #> 1 AB12345 AB12345-BRA-11-id-8 2021-12-05 02:02:07 dcd D.2.1.5.3 2 D.2.1.5… #> 2 AB12345 AB12345-BRA-12-id-120 2020-02-05 01:42:29 dcd D.2.1.5.3 2 D.2.1.5… #> 3 AB12345 AB12345-BRA-1-id-171 2022-11-29 12:18:31 dcd C.1.1.1.3 2 C.1.1.1… #> 4 AB12345 AB12345-BRA-1-id-23 2020-07-10 07:32:49 dcd B.2.2.3.1 3 C.1.1.1… #> 5 AB12345 AB12345-BRA-1-id-59 2021-10-10 23:54:46 dcd C.1.1.1.3 4 C.1.1.1… #> 6 AB12345 AB12345-BRA-1-id-9 2021-06-01 14:39:09 dcd C.1.1.1.3 1 C.1.1.1… #> 7 AB12345 AB12345-BRA-11-id-8 2021-12-21 02:02:07 dcd C.1.1.1.3 3 C.1.1.1… #> 8 AB12345 AB12345-BRA-12-id-120 2020-10-01 01:42:29 dcd C.1.1.1.3 3 C.1.1.1… aag <- data.frame( NAMVAR = c(\"CQ01NAM\", \"CQ02NAM\", \"SMQ01NAM\", \"SMQ02NAM\"), REFNAME = c( \"D.2.1.5.3/A.1.1.1.1 aesi\", \"X.9.9.9.9/Y.8.8.8.8 aesi\", \"C.1.1.1.3/B.2.2.3.1 aesi\", \"C.1.1.1.3/B.3.3.3.3 aesi\" ), SCOPE = c(\"\", \"\", \"BROAD\", \"BROAD\"), stringsAsFactors = FALSE ) basket_name <- character(nrow(aag)) cq_pos <- grep(\"^(CQ).+NAM$\", aag$NAMVAR) smq_pos <- grep(\"^(SMQ).+NAM$\", aag$NAMVAR) basket_name[cq_pos] <- aag$REFNAME[cq_pos] basket_name[smq_pos] <- paste0( aag$REFNAME[smq_pos], \"(\", aag$SCOPE[smq_pos], \")\" ) aag_summary <- data.frame( basket = aag$NAMVAR, basket_name = basket_name, stringsAsFactors = TRUE ) result <- h_stack_by_baskets(df = adae, aag_summary = aag_summary) all(levels(aag_summary$basket_name) %in% levels(result$SMQ)) #> [1] TRUE h_stack_by_baskets( df = adae, aag_summary = NULL, keys = c(\"STUDYID\", \"USUBJID\", \"AEDECOD\", \"ARM\"), baskets = \"SMQ01NAM\" ) #> # A tibble: 6 × 5 #> STUDYID USUBJID AEDECOD ARM SMQ #> #> 1 AB12345 AB12345-BRA-1-id-171 dcd C.1.1.1.3 B: Placebo C.1.1.1.3/B.2.2.3.… #> 2 AB12345 AB12345-BRA-1-id-23 dcd B.2.2.3.1 A: Drug X C.1.1.1.3/B.2.2.3.… #> 3 AB12345 AB12345-BRA-1-id-59 dcd C.1.1.1.3 A: Drug X C.1.1.1.3/B.2.2.3.… #> 4 AB12345 AB12345-BRA-1-id-9 dcd C.1.1.1.3 C: Combination C.1.1.1.3/B.2.2.3.… #> 5 AB12345 AB12345-BRA-11-id-8 dcd C.1.1.1.3 A: Drug X C.1.1.1.3/B.2.2.3.… #> 6 AB12345 AB12345-BRA-12-id-120 dcd C.1.1.1.3 A: Drug X C.1.1.1.3/B.2.2.3.…"},{"path":"https://insightsengineering.github.io/tern/reference/h_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"Helper functions used internally STEP calculations.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"","code":"h_step_window(x, control = control_step()) h_step_trt_effect(data, model, variables, x) h_step_survival_formula(variables, control = control_step()) h_step_survival_est( formula, data, variables, x, subset = rep(TRUE, nrow(data)), control = control_coxph() ) h_step_rsp_formula(variables, control = c(control_step(), control_logistic())) h_step_rsp_est( formula, data, variables, x, subset = rep(TRUE, nrow(data)), control = control_logistic() )"},{"path":"https://insightsengineering.github.io/tern/reference/h_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"x (numeric) biomarker value(s) use (without NA). control (named list) output control_step(). data (data.frame) dataset containing variables summarize. model (coxph glm) regression model object. variables (named list string) list additional analysis variables. formula (formula) regression model formula. subset (logical) subset vector.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"h_step_window() returns list containing window-selection matrix sel interval information matrix interval. h_step_trt_effect() returns vector elements est se. h_step_survival_formula() returns model formula. h_step_survival_est() returns matrix number observations n, events, log hazard ratio estimates loghr, standard error se, Wald confidence interval bounds ci_lower ci_upper. One row included biomarker value x. h_step_rsp_formula() returns model formula. h_step_rsp_est() returns matrix number observations n, log odds ratio estimates logor, standard error se, Wald confidence interval bounds ci_lower ci_upper. One row included biomarker value x.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_step.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"h_step_window(): Creates windows STEP, based control settings provided. h_step_trt_effect(): Calculates estimated treatment effect estimate linear predictor scale corresponding standard error STEP model fitted data given variables specification, single biomarker value x. works coxph glm models, .e. calculating log hazard ratio log odds ratio estimates. h_step_survival_formula(): Builds model formula used survival STEP calculations. h_step_survival_est(): Estimates model formula built based variables data given subset control parameters Cox regression. h_step_rsp_formula(): Builds model formula used response STEP calculations. h_step_rsp_est(): Estimates model formula built based variables data given subset control parameters logistic regression.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"Helper functions documented separately confuse user reading user-facing functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"","code":"h_surv_to_coxreg_variables(variables, biomarker) h_coxreg_mult_cont_df(variables, data, control = control_coxreg()) h_tab_surv_one_biomarker( df, vars, time_unit, na_str = default_na_str(), .indent_mods = 0L, ... )"},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"variables (named list string) list additional analysis variables. biomarker (string) name biomarker variable. data (data.frame) dataset containing variables summarize. control (list) list parameters returned helper function control_coxreg(). df (data.frame) results single biomarker, part returned extract_survival_biomarkers() (needs couple columns added high-level function relative returned h_coxreg_mult_cont_df(), see example). vars (character) names statistics reported among: n_tot_events: Total number events per group. n_tot: Total number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. time_unit (string) label unit median survival time. Default NULL skips displaying unit. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"h_surv_to_coxreg_variables() returns named list elements time, event, arm, covariates, strata. h_coxreg_mult_cont_df() returns data.frame containing estimates statistics selected biomarkers. h_tab_surv_one_biomarker() returns rtables table object given statistics arranged columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_biomarkers_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"h_surv_to_coxreg_variables(): Helps converting \"survival\" function variable list \"Cox regression\" variable list. reason currently inconsistency variable names accepted extract_survival_subgroups() fit_coxreg_multivar(). h_coxreg_mult_cont_df(): Prepares estimates number events, patients median survival times, well hazard ratio estimates, confidence intervals p-values, multiple biomarkers given single data set. variables corresponds names variables found data, passed named list requires elements tte, is_event, biomarkers (vector continuous biomarker variables) optionally subgroups strata. h_tab_surv_one_biomarker(): Prepares single sub-table given df_sub containing results single biomarker.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"","code":"library(dplyr) library(forcats) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte, fill = FALSE) adtte_f <- adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- c(\"AVALU\" = adtte_labels[[\"AVALU\"]], \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels # This is how the variable list is converted internally. h_surv_to_coxreg_variables( variables = list( tte = \"AVAL\", is_event = \"EVNT\", covariates = c(\"A\", \"B\"), strata = \"D\" ), biomarker = \"AGE\" ) #> $time #> [1] \"AVAL\" #> #> $event #> [1] \"EVNT\" #> #> $arm #> [1] \"AGE\" #> #> $covariates #> [1] \"A\" \"B\" #> #> $strata #> [1] \"D\" #> # For a single population, estimate separately the effects # of two biomarkers. df <- h_coxreg_mult_cont_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", strata = c(\"STRATA1\", \"STRATA2\") ), data = adtte_f ) df #> biomarker biomarker_label n_tot n_tot_events median hr #> 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.000189 #> 2 AGE Age 200 141 753.5176 1.008267 #> lcl ucl conf_level pval pval_label #> 1 0.9511092 1.051802 0.95 0.9941244 p-value (Wald) #> 2 0.9845155 1.032591 0.95 0.4984743 p-value (Wald) # If the data set is empty, still the corresponding rows with missings are returned. h_coxreg_mult_cont_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"REGION1\", strata = c(\"STRATA1\", \"STRATA2\") ), data = adtte_f[NULL, ] ) #> biomarker biomarker_label n_tot n_tot_events median hr lcl ucl #> 1 BMRKR1 Continuous Level Biomarker 1 0 0 NA NA NA NA #> 2 AGE Age 0 0 NA NA NA NA #> conf_level pval pval_label #> 1 0.95 NA p-value (Wald) #> 2 0.95 NA p-value (Wald) # Starting from above `df`, zoom in on one biomarker and add required columns. df1 <- df[1, ] df1$subgroup <- \"All patients\" df1$row_type <- \"content\" df1$var <- \"ALL\" df1$var_label <- \"All patients\" h_tab_surv_one_biomarker( df1, vars = c(\"n_tot\", \"n_tot_events\", \"median\", \"hr\", \"ci\", \"pval\"), time_unit = \"days\" ) #> Total n Total Events Median (days) Hazard Ratio 95% Wald CI p-value (Wald) #> ———————————————————————————————————————————————————————————————————————————————————————————————————— #> All patients 200 141 753.5 1.00 (0.95, 1.05) 0.9941"},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"Helper functions tabulate data frame statistics median survival time hazard ratio population subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"","code":"h_survtime_df(tte, is_event, arm) h_survtime_subgroups_df( variables, data, groups_lists = list(), label_all = \"All Patients\" ) h_coxph_df(tte, is_event, arm, strata_data = NULL, control = control_coxph()) h_coxph_subgroups_df( variables, data, groups_lists = list(), control = control_coxph(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"tte (numeric) vector time--event duration values. is_event (flag)TRUE event, FALSE time event censored. arm (factor) treatment group variable. variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all (string) label total population analysis. strata_data (factor, data.frame, NULL) required stratified analysis performed. control (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing null hypothesis hazard ratio = 1. Default method \"log-rank\" comes survival::survdiff(), can also set \"wald\" \"likelihood\" (survival::coxph()). ties (string) specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval HR.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"h_survtime_df() returns data.frame columns arm, n, n_events, median. h_survtime_subgroups_df() returns data.frame columns arm, n, n_events, median, subgroup, var, var_label, row_type. h_coxph_df() returns data.frame columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval pval_label. h_coxph_subgroups_df() returns data.frame columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"Main functionality prepare data use layout-creating function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"h_survtime_df(): Helper prepare data frame median survival times arm. h_survtime_subgroups_df(): Summarizes median survival times arm across subgroups data frame. variables corresponds names variables found data, passed named list requires elements tte, is_event, arm optionally subgroups. groups_lists optionally specifies groupings subgroups variables. h_coxph_df(): Helper prepare data frame estimates treatment hazard ratio. h_coxph_subgroups_df(): Summarizes estimates treatment hazard ratio across subgroups data frame. variables corresponds names variables found data, passed named list requires elements tte, is_event, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_survival_duration_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"","code":"library(dplyr) library(forcats) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) adtte_f <- adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\"), SEX %in% c(\"M\", \"F\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(fct_relevel(ARM, \"B: Placebo\")), SEX = droplevels(SEX), is_event = CNSR == 0 ) labels <- c(\"ARM\" = adtte_labels[[\"ARM\"]], \"SEX\" = adtte_labels[[\"SEX\"]], \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels # Extract median survival time for one group. h_survtime_df( tte = adtte_f$AVAL, is_event = adtte_f$is_event, arm = adtte_f$ARM ) #> arm n n_events median #> 1 B: Placebo 73 57 727.8043 #> 2 A: Drug X 69 44 974.6402 # Extract median survival time for multiple groups. h_survtime_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f ) #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 All Patients ALL #> 2 A: Drug X 69 44 974.6402 All Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 LOW BMRKR2 #> 8 A: Drug X 26 15 974.6402 LOW BMRKR2 #> 9 B: Placebo 23 14 731.8352 MEDIUM BMRKR2 #> 10 A: Drug X 26 17 964.2197 MEDIUM BMRKR2 #> 11 B: Placebo 26 22 654.8245 HIGH BMRKR2 #> 12 A: Drug X 17 12 1016.2982 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Define groupings for BMRKR2 levels. h_survtime_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 All Patients ALL #> 2 A: Drug X 69 44 974.6402 All Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 low BMRKR2 #> 8 A: Drug X 26 15 974.6402 low BMRKR2 #> 9 B: Placebo 47 35 735.4722 low/medium BMRKR2 #> 10 A: Drug X 52 32 964.2197 low/medium BMRKR2 #> 11 B: Placebo 73 57 727.8043 low/medium/high BMRKR2 #> 12 A: Drug X 69 44 974.6402 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Extract hazard ratio for one group. h_coxph_df(adtte_f$AVAL, adtte_f$is_event, adtte_f$ARM) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.057337 0.95 0.09049511 #> pval_label #> 1 p-value (log-rank) # Extract hazard ratio for one group with stratification factor. h_coxph_df(adtte_f$AVAL, adtte_f$is_event, adtte_f$ARM, strata_data = adtte_f$STRATA1) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.6646586 0.4399495 1.00414 0.95 0.05089188 #> pval_label #> 1 p-value (log-rank) # Extract hazard ratio for multiple groups. h_coxph_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f ) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 49 31 0.7651261 0.3641277 1.6077269 0.95 0.47860004 #> 6 43 34 0.6662356 0.3257413 1.3626456 0.95 0.26285846 #> pval_label subgroup var var_label row_type #> 1 p-value (log-rank) All Patients ALL All Patients content #> 2 p-value (log-rank) F SEX Sex analysis #> 3 p-value (log-rank) M SEX Sex analysis #> 4 p-value (log-rank) LOW BMRKR2 Continuous Level Biomarker 2 analysis #> 5 p-value (log-rank) MEDIUM BMRKR2 Continuous Level Biomarker 2 analysis #> 6 p-value (log-rank) HIGH BMRKR2 Continuous Level Biomarker 2 analysis # Define groupings of BMRKR2 levels. h_coxph_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 99 67 0.7472958 0.4600419 1.2139136 0.95 0.23764314 #> 6 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> pval_label subgroup var var_label #> 1 p-value (log-rank) All Patients ALL All Patients #> 2 p-value (log-rank) F SEX Sex #> 3 p-value (log-rank) M SEX Sex #> 4 p-value (log-rank) low BMRKR2 Continuous Level Biomarker 2 #> 5 p-value (log-rank) low/medium BMRKR2 Continuous Level Biomarker 2 #> 6 p-value (log-rank) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 analysis #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis # Extract hazard ratio for multiple groups with stratification factors. h_coxph_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\"), strata = c(\"STRATA1\", \"STRATA2\") ), data = adtte_f ) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.6126133 0.3913507 0.9589739 0.95 0.03086774 #> 2 78 55 0.3934024 0.2027682 0.7632630 0.95 0.00469167 #> 3 64 46 0.9501768 0.4730073 1.9087145 0.95 0.88580522 #> 4 50 36 0.7378635 0.3140465 1.7336363 0.95 0.48408079 #> 5 49 31 0.9408062 0.4172095 2.1215148 0.95 0.88305965 #> 6 43 34 0.5125617 0.2125140 1.2362459 0.95 0.13124382 #> pval_label subgroup var var_label row_type #> 1 p-value (log-rank) All Patients ALL All Patients content #> 2 p-value (log-rank) F SEX Sex analysis #> 3 p-value (log-rank) M SEX Sex analysis #> 4 p-value (log-rank) LOW BMRKR2 Continuous Level Biomarker 2 analysis #> 5 p-value (log-rank) MEDIUM BMRKR2 Continuous Level Biomarker 2 analysis #> 6 p-value (log-rank) HIGH BMRKR2 Continuous Level Biomarker 2 analysis"},{"path":"https://insightsengineering.github.io/tern/reference/h_tab_one_biomarker.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"Please see h_tab_surv_one_biomarker() h_tab_rsp_one_biomarker(), use function examples. function wrapper rtables::summarize_row_groups().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tab_one_biomarker.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"","code":"h_tab_one_biomarker( df, afuns, colvars, na_str = default_na_str(), .indent_mods = 0L, ... )"},{"path":"https://insightsengineering.github.io/tern/reference/h_tab_one_biomarker.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"df (data.frame) results single biomarker. afuns (named list function) analysis functions. colvars (named list) named list elements vars (variables tabulate) labels (labels). na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tab_one_biomarker.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"rtables table object statistics columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_coxph_pairwise.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"Create data.frame pairwise stratified unstratified Cox-PH analysis results.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_coxph_pairwise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"","code":"h_tbl_coxph_pairwise( df, variables, ref_group_coxph = NULL, control_coxph_pw = control_coxph(), annot_coxph_ref_lbls = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_coxph_pairwise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"df (data.frame) data set containing analysis variables. variables (named list) variable names. Details : tte (numeric) variable indicating time--event duration values. is_event (logical) event variable. TRUE event, FALSE time event censored. arm (factor) treatment group variable. strata (character NULL) variable names indicating stratification factors. ref_group_coxph (string NULL) level arm variable use reference group calculations annot_coxph table. NULL (default), uses first level arm variable. control_coxph_pw (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing hazard ratio = 1. Default method \"log-rank\", can also set \"wald\" \"likelihood\". ties (string) method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph() conf_level (proportion) confidence level interval HR. annot_coxph_ref_lbls (flag) whether reference group explicitly printed labels annot_coxph table. FALSE (default), comparison groups printed annot_coxph table labels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_coxph_pairwise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"data.frame containing statistics HR, XX% CI (XX taken control_coxph_pw), p-value (log-rank).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_coxph_pairwise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"","code":"library(dplyr) adtte <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) h_tbl_coxph_pairwise( df = adtte, variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\"), control_coxph_pw = control_coxph(conf_level = 0.9) ) #> HR 90% CI p-value (log-rank) #> B: Placebo 1.41 (1.01, 1.96) 0.0905 #> C: Combination 1.81 (1.24, 2.64) 0.0086"},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_median_surv.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for survival estimations — h_tbl_median_surv","title":"Helper function for survival estimations — h_tbl_median_surv","text":"Transform survival fit table groups rows characterized N, median confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_median_surv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for survival estimations — h_tbl_median_surv","text":"","code":"h_tbl_median_surv(fit_km, armval = \"All\")"},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_median_surv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for survival estimations — h_tbl_median_surv","text":"fit_km (survfit) result survival::survfit(). armval (string) used strata name treatment arm variable one level. Default \"\".","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_median_surv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for survival estimations — h_tbl_median_surv","text":"summary table statistics N, Median, XX% CI (XX taken fit_km).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_tbl_median_surv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for survival estimations — h_tbl_median_surv","text":"","code":"library(dplyr) library(survival) adtte <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") fit <- survfit( formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = adtte ) h_tbl_median_surv(fit_km = fit) #> N Median 95% CI #> ARM A 69 974.6 (687, 1625) #> ARM B 73 727.8 (555.8, 1156) #> ARM C 58 632.3 (393, 1001)"},{"path":"https://insightsengineering.github.io/tern/reference/h_worsen_counter.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"Helper function count number patients fraction patients according highest post-baseline lab grade variable .var, baseline lab grade variable baseline_var, direction interest specified direction_var.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_worsen_counter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"","code":"h_worsen_counter(df, id, .var, baseline_var, direction_var)"},{"path":"https://insightsengineering.github.io/tern/reference/h_worsen_counter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"df (data.frame) data set containing analysis variables. id (string) subject variable name. .var (string) single variable name passed rtables requested statistics function. baseline_var (string) name baseline lab grade variable. direction_var (string) name direction variable specifying direction shift table interest. lab records flagged L, H B included shift table. L: low direction H: high direction B: low high directions","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_worsen_counter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"counts fraction patients whose worst post-baseline lab grades worse baseline grades, post-baseline worst grades \"1\", \"2\", \"3\", \"4\" \"\".","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/h_worsen_counter.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"","code":"library(dplyr) # The direction variable, GRADDR, is based on metadata adlb <- tern_ex_adlb %>% mutate( GRADDR = case_when( PARAMCD == \"ALT\" ~ \"B\", PARAMCD == \"CRP\" ~ \"L\", PARAMCD == \"IGA\" ~ \"H\" ) ) %>% filter(SAFFL == \"Y\" & ONTRTFL == \"Y\" & GRADDR != \"\") df <- h_adlb_worsen( adlb, worst_flag_low = c(\"WGRLOFL\" = \"Y\"), worst_flag_high = c(\"WGRHIFL\" = \"Y\"), direction_var = \"GRADDR\" ) # `h_worsen_counter` h_worsen_counter( df %>% filter(PARAMCD == \"CRP\" & GRADDR == \"Low\"), id = \"USUBJID\", .var = \"ATOXGR\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\" ) #> $fraction #> $fraction$`1` #> num denom #> 25 180 #> #> $fraction$`2` #> num denom #> 15 186 #> #> $fraction$`3` #> num denom #> 18 191 #> #> $fraction$`4` #> num denom #> 17 196 #> #> $fraction$Any #> num denom #> 75 196 #> #>"},{"path":"https://insightsengineering.github.io/tern/reference/h_xticks.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to calculate x-tick positions — h_xticks","title":"Helper function to calculate x-tick positions — h_xticks","text":"Calculate positions ticks x-axis. However, xticks already exists kept . based function ggplot2 relies , required graphic patient--risk annotation table.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_xticks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to calculate x-tick positions — h_xticks","text":"","code":"h_xticks(data, xticks = NULL, max_time = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/h_xticks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to calculate x-tick positions — h_xticks","text":"data (data.frame) survival data pre-processed h_data_plot. xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis. NULL (default), labeling::extended() used determine optimal tick positions x-axis. max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_xticks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to calculate x-tick positions — h_xticks","text":"vector positions use x-axis ticks ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/h_xticks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to calculate x-tick positions — h_xticks","text":"","code":"library(dplyr) library(survival) data <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_data_plot() h_xticks(data) #> [1] 0 1000 2000 3000 4000 5000 h_xticks(data, xticks = seq(0, 3000, 500)) #> [1] 0 500 1000 1500 2000 2500 3000 h_xticks(data, xticks = 500) #> [1] 0 500 1000 1500 2000 2500 3000 3500 4000 4500 h_xticks(data, xticks = 500, max_time = 6000) #> [1] 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 h_xticks(data, xticks = c(0, 500), max_time = 300) #> [1] 0 500 h_xticks(data, xticks = 500, max_time = 300) #> [1] 0 500 1000 1500 2000 2500 3000 3500 4000 4500"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/imputation_rule.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply 1/3 or 1/2 imputation rule to data — imputation_rule","text":"","code":"imputation_rule( df, x_stats, stat, imp_rule, post = FALSE, avalcat_var = \"AVALCAT1\" )"},{"path":"https://insightsengineering.github.io/tern/reference/imputation_rule.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply 1/3 or 1/2 imputation rule to data — imputation_rule","text":"df (data.frame) data set containing analysis variables. x_stats (named list) named list statistics, typically results s_summary(). stat (string) statistic return value/NA level according imputation rule applied. imp_rule (string) imputation rule setting. Set \"1/3\" implement 1/3 imputation rule \"1/2\" implement 1/2 imputation rule. post (flag) whether data corresponds post-dose time-point (defaults FALSE). parameter used imp_rule set \"1/3\". avalcat_var (string) name variable indicates whether row df corresponds analysis value category \"BLQ\", \"LTR\", \" $val #> max #> 0.9919061 #> #> $na_str #> [1] \"ND\" #> imputation_rule(df, x_stats, \"geom_mean\", \"1/3\") #> $val #> [1] NA #> #> $na_str #> [1] \"NE\" #> imputation_rule(df, x_stats, \"mean\", \"1/2\") #> $val #> [1] NA #> #> $na_str #> [1] \"ND\" #>"},{"path":"https://insightsengineering.github.io/tern/reference/incidence_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Incidence rate estimation — incidence_rate","title":"Incidence rate estimation — incidence_rate","text":"analyze function estimate_incidence_rate() creates layout element estimate event rate adjusted person-years risk, otherwise known incidence rate. primary analysis variable specified via vars person-years risk. addition variable, n_events variable number events observed (value 1 means event observed 0 means event observed) must also specified.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/incidence_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Incidence rate estimation — incidence_rate","text":"","code":"estimate_incidence_rate( lyt, vars, n_events, id_var = \"USUBJID\", control = control_incidence_rate(), na_str = default_na_str(), nested = TRUE, summarize = FALSE, label_fmt = \"%s - %.labels\", ..., show_labels = \"hidden\", table_names = vars, .stats = c(\"person_years\", \"n_events\", \"rate\", \"rate_ci\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_incidence_rate( df, .var, n_events, is_event = lifecycle::deprecated(), id_var = \"USUBJID\", control = control_incidence_rate() ) a_incidence_rate( df, labelstr = \"\", .var, .df_row, n_events, id_var = \"USUBJID\", control = control_incidence_rate(), .stats = NULL, .formats = c(person_years = \"xx.x\", n_events = \"xx\", rate = \"xx.xx\", rate_ci = \"(xx.xx, xx.xx)\", n_unique = \"xx\", n_rate = \"xx (xx.x)\"), .labels = NULL, .indent_mods = NULL, na_str = default_na_str(), label_fmt = \"%s - %.labels\" )"},{"path":"https://insightsengineering.github.io/tern/reference/incidence_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Incidence rate estimation — incidence_rate","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . n_events (string) name integer variable indicating whether event observed (1) (0). id_var (string) name variable used patient identifier \"n_unique\" included .stats. Defaults \"USUBJID\". control (list) parameters estimation details, specified using helper function control_incidence_rate(). Possible parameter options : conf_level (proportion) confidence level estimated incidence rate. conf_type (string)normal (default), normal_log, exact, byar confidence interval type. input_time_unit (string)day, week, month, year (default) indicating time unit data input. num_pt_year (numeric) time unit desired output (person-years). na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. summarize (flag) whether function act analyze function (summarize = FALSE), summarize function (summarize = TRUE). Defaults FALSE. label_fmt (string) labels formatted row split occurs summarize = TRUE. string use \"%s\" represent row split levels, \"%.labels\" represent labels supplied .labels argument. Defaults \"%s - %.labels\". ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'person_years', 'n_events', 'rate', 'rate_ci', 'n_unique', 'n_rate' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. is_event (flag)TRUE event, FALSE time event censored. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/incidence_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Incidence rate estimation — incidence_rate","text":"estimate_incidence_rate() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_incidence_rate() table layout. s_incidence_rate() returns following statistics: person_years: Total person-years risk. n_events: Total number events observed. rate: Estimated incidence rate. rate_ci: Confidence interval incidence rate. n_unique: Total number patients least one event observed. n_rate: Total number events observed & estimated incidence rate. a_incidence_rate() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/incidence_rate.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Incidence rate estimation — incidence_rate","text":"estimate_incidence_rate(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_incidence_rate(): Statistics function estimates incidence rate associated confidence interval. a_incidence_rate(): Formatted analysis function used afun estimate_incidence_rate().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/incidence_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Incidence rate estimation — incidence_rate","text":"","code":"df <- data.frame( USUBJID = as.character(seq(6)), CNSR = c(0, 1, 1, 0, 0, 0), AVAL = c(10.1, 20.4, 15.3, 20.8, 18.7, 23.4), ARM = factor(c(\"A\", \"A\", \"A\", \"B\", \"B\", \"B\")), STRATA1 = factor(c(\"X\", \"Y\", \"Y\", \"X\", \"X\", \"Y\")) ) df$n_events <- 1 - df$CNSR basic_table(show_colcounts = TRUE) %>% split_cols_by(\"ARM\") %>% estimate_incidence_rate( vars = \"AVAL\", n_events = \"n_events\", control = control_incidence_rate( input_time_unit = \"month\", num_pt_year = 100 ) ) %>% build_table(df) #> A B #> (N=3) (N=3) #> ————————————————————————————————————————————————————————————————————— #> Total patient-years at risk 3.8 5.2 #> Number of adverse events observed 1 3 #> AE rate per 100 patient-years 26.20 57.23 #> 95% CI (-25.15, 77.55) (-7.53, 122.00) # summarize = TRUE basic_table(show_colcounts = TRUE) %>% split_cols_by(\"ARM\") %>% split_rows_by(\"STRATA1\", child_labels = \"visible\") %>% estimate_incidence_rate( vars = \"AVAL\", n_events = \"n_events\", .stats = c(\"n_unique\", \"n_rate\"), summarize = TRUE, label_fmt = \"%.labels\" ) %>% build_table(df) #> A B #> (N=3) (N=3) #> ——————————————————————————————————————————————————————————————————————————————————————— #> X #> Total number of patients with at least one adverse event 1 2 #> Number of adverse events observed (AE rate per 100 patient-years) 1 (9.9) 2 (5.1) #> Y #> Total number of patients with at least one adverse event 0 1 #> Number of adverse events observed (AE rate per 100 patient-years) 0 (0.0) 1 (4.3) a_incidence_rate( df, .var = \"AVAL\", .df_row = df, n_events = \"n_events\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 person_years 108.7 0 #> 2 n_events 4 0 #> 3 rate 3.68 0 #> 4 rate_ci (0.07, 7.29) 0 #> 5 n_unique 4 0 #> 6 n_rate 4 (3.7) 0 #> row_label #> 1 Total patient-years at risk #> 2 Number of adverse events observed #> 3 AE rate per 100 patient-years #> 4 95% CI #> 5 Total number of patients with at least one adverse event #> 6 Number of adverse events observed (AE rate per 100 patient-years)"},{"path":"https://insightsengineering.github.io/tern/reference/labels_or_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels or names of list elements — labels_or_names","title":"Labels or names of list elements — labels_or_names","text":"Internal helper function working nested statistic function results typically labels names can use.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/labels_or_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels or names of list elements — labels_or_names","text":"","code":"labels_or_names(x)"},{"path":"https://insightsengineering.github.io/tern/reference/labels_or_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels or names of list elements — labels_or_names","text":"x (list) list.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/labels_or_names.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels or names of list elements — labels_or_names","text":"character vector labels names list elements.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/labels_use_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Update labels according to control specifications — labels_use_control","title":"Update labels according to control specifications — labels_use_control","text":"Given list statistic labels list control parameters, updates labels relevant control specification. example, control element conf_level set 0.9, default label statistic mean_ci updated \"Mean 90% CI\". labels supplied via labels_custom updated regardless control.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/labels_use_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update labels according to control specifications — labels_use_control","text":"","code":"labels_use_control(labels_default, control, labels_custom = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/labels_use_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update labels according to control specifications — labels_use_control","text":"labels_default (named character) named vector statistic labels modify according control specifications. Labels explicitly defined labels_custom affected. control (named list) list control parameters apply adjust default labels. labels_custom (named character) named vector labels customized user affected control.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/labels_use_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update labels according to control specifications — labels_use_control","text":"named character vector labels control specifications applied relevant labels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/labels_use_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Update labels according to control specifications — labels_use_control","text":"","code":"control <- list(conf_level = 0.80, quantiles = c(0.1, 0.83), test_mean = 0.57) get_labels_from_stats(c(\"mean_ci\", \"quantiles\", \"mean_pval\")) %>% labels_use_control(control = control) #> mean_ci quantiles #> \"Mean 80% CI\" \"10% and 83%-ile\" #> mean_pval #> \"Mean p-value (H0: mean = 0.57)\""},{"path":"https://insightsengineering.github.io/tern/reference/logistic_regression_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Logistic regression multivariate column layout function — logistic_regression_cols","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"Layout-creating function creates multivariate column layout summarizing logistic regression results. function wrapper rtables::split_cols_by_multivar().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/logistic_regression_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"","code":"logistic_regression_cols(lyt, conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/reference/logistic_regression_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"lyt (PreDataTableLayouts) layout analyses added . conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/logistic_regression_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"layout object suitable passing layouting functions. Adding function rtable layout split table columns corresponding statistics df, estimate, std_error, odds_ratio, ci, pvalue.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/logistic_summary_by_flag.html","id":null,"dir":"Reference","previous_headings":"","what":"Logistic regression summary table — logistic_summary_by_flag","title":"Logistic regression summary table — logistic_summary_by_flag","text":"Constructor content functions used summarize_logistic() summarize logistic regression results. function wrapper rtables::summarize_row_groups().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/logistic_summary_by_flag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logistic regression summary table — logistic_summary_by_flag","text":"","code":"logistic_summary_by_flag( flag_var, na_str = default_na_str(), .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/logistic_summary_by_flag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logistic regression summary table — logistic_summary_by_flag","text":"flag_var (string) variable name identifying row used content function. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/logistic_summary_by_flag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logistic regression summary table — logistic_summary_by_flag","text":"content function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/make_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Make names without dots — make_names","title":"Make names without dots — make_names","text":"Make names without dots","code":""},{"path":"https://insightsengineering.github.io/tern/reference/make_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Make names without dots — make_names","text":"","code":"make_names(nams)"},{"path":"https://insightsengineering.github.io/tern/reference/make_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Make names without dots — make_names","text":"nams (character) vector original names.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/make_names.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Make names without dots — make_names","text":"character vector proper names, use dots contrast make.names().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/month2day.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion of months to days — month2day","title":"Conversion of months to days — month2day","text":"Conversion months days. approximative calculation considers month average 30.4375 days.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/month2day.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion of months to days — month2day","text":"","code":"month2day(x)"},{"path":"https://insightsengineering.github.io/tern/reference/month2day.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conversion of months to days — month2day","text":"x (numeric(1)) time months.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/month2day.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conversion of months to days — month2day","text":"numeric vector time days.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/month2day.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conversion of months to days — month2day","text":"","code":"x <- c(13.25, 8.15, 1, 2.834) month2day(x) #> [1] 403.29688 248.06563 30.43750 86.25988"},{"path":"https://insightsengineering.github.io/tern/reference/muffled_car_anova.html","id":null,"dir":"Reference","previous_headings":"","what":"Muffled car::Anova — muffled_car_anova","title":"Muffled car::Anova — muffled_car_anova","text":"Applied survival models, car::Anova() signal strata terms dropped model formula present, function deliberately muffles message.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/muffled_car_anova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Muffled car::Anova — muffled_car_anova","text":"","code":"muffled_car_anova(mod, test_statistic)"},{"path":"https://insightsengineering.github.io/tern/reference/muffled_car_anova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Muffled car::Anova — muffled_car_anova","text":"mod (coxph) Cox regression model fitted survival::coxph(). test_statistic (string) method used estimation p.values; wald (default) likelihood.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/muffled_car_anova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Muffled car::Anova — muffled_car_anova","text":"output car::Anova(), convergence message muffled.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/n_available.html","id":null,"dir":"Reference","previous_headings":"","what":"Number of available (non-missing entries) in a vector — n_available","title":"Number of available (non-missing entries) in a vector — n_available","text":"Small utility function better readability.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/n_available.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Number of available (non-missing entries) in a vector — n_available","text":"","code":"n_available(x)"},{"path":"https://insightsengineering.github.io/tern/reference/n_available.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Number of available (non-missing entries) in a vector — n_available","text":"x (vector) vector count non-missing values.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/n_available.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Number of available (non-missing entries) in a vector — n_available","text":"Number non-missing values.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":null,"dir":"Reference","previous_headings":"","what":"Odds ratio estimation — odds_ratio","title":"Odds ratio estimation — odds_ratio","text":"analyze function estimate_odds_ratio() creates layout element compare bivariate responses two groups estimating odds ratio confidence interval. primary analysis variable specified vars group variable. Additional variables can included analysis via variables argument, accepts arm, arm variable, strata, stratification variable. two arm levels present, can combined two groups using groups_list argument.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Odds ratio estimation — odds_ratio","text":"","code":"estimate_odds_ratio( lyt, vars, variables = list(arm = NULL, strata = NULL), conf_level = 0.95, groups_list = NULL, na_str = default_na_str(), nested = TRUE, method = \"exact\", show_labels = \"hidden\", table_names = vars, var_labels = vars, .stats = \"or_ci\", .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_odds_ratio( df, .var, .ref_group, .in_ref_col, .df_row, variables = list(arm = NULL, strata = NULL), conf_level = 0.95, groups_list = NULL, method = \"exact\" ) a_odds_ratio( df, .var, .ref_group, .in_ref_col, .df_row, variables = list(arm = NULL, strata = NULL), conf_level = 0.95, groups_list = NULL, method = \"exact\" )"},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Odds ratio estimation — odds_ratio","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. conf_level (proportion) confidence level interval. groups_list (named list character) specifies new group levels via names levels belong character vectors elements list. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. method (string) whether use correct (\"exact\") calculation conditional likelihood one approximations. See survival::clogit() details. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. var_labels (character) variable labels. .stats (character) statistics select table. Options : 'or_ci', 'n_tot' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Odds ratio estimation — odds_ratio","text":"estimate_odds_ratio() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_odds_ratio() table layout. s_odds_ratio() returns named list statistics or_ci (containing est, lcl, ucl) n_tot. a_odds_ratio() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Odds ratio estimation — odds_ratio","text":"estimate_odds_ratio(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_odds_ratio(): Statistics function estimates odds ratio treatment control. variables list arm strata variable names must passed stratified analysis required. a_odds_ratio(): Formatted analysis function used afun estimate_odds_ratio().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Odds ratio estimation — odds_ratio","text":"function uses logistic regression unstratified analyses, conditional logistic regression stratified analyses. Wald confidence interval calculated specified confidence level. stratified analyses, currently implementation conditional likelihood confidence intervals, therefore likelihood confidence interval available option. vars contains responders non-responders odds ratio estimation possible returned values NA.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/odds_ratio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Odds ratio estimation — odds_ratio","text":"","code":"set.seed(12) dta <- data.frame( rsp = sample(c(TRUE, FALSE), 100, TRUE), grp = factor(rep(c(\"A\", \"B\"), each = 50), levels = c(\"A\", \"B\")), strata = factor(sample(c(\"C\", \"D\"), 100, TRUE)) ) l <- basic_table() %>% split_cols_by(var = \"grp\", ref_group = \"B\") %>% estimate_odds_ratio(vars = \"rsp\") build_table(l, df = dta) #> A B #> ———————————————————————————————————————————— #> Odds Ratio (95% CI) 0.85 (0.38 - 1.88) # Unstratified analysis. s_odds_ratio( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, .df_row = dta ) #> $or_ci #> est lcl ucl #> 0.8484848 0.3831831 1.8788053 #> attr(,\"label\") #> [1] \"Odds Ratio (95% CI)\" #> #> $n_tot #> n_tot #> 100 #> attr(,\"label\") #> [1] \"Total n\" #> # Stratified analysis. s_odds_ratio( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, .df_row = dta, variables = list(arm = \"grp\", strata = \"strata\") ) #> $or_ci #> est lcl ucl #> 0.7689750 0.3424155 1.7269154 #> attr(,\"label\") #> [1] \"Odds Ratio (95% CI)\" #> #> $n_tot #> n_tot #> 100 #> attr(,\"label\") #> [1] \"Total n\" #> a_odds_ratio( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, .df_row = dta ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 or_ci 0.85 (0.38 - 1.88) 1 Odds Ratio (95% CI) #> 2 n_tot 100 0 Total n"},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Proportion difference estimation — prop_diff","title":"Proportion difference estimation — prop_diff","text":"analysis function estimate_proportion_diff() creates layout element estimate difference proportion responders within studied population. primary analysis variable, vars, logical variable indicating whether response occurred record. See method parameter options methods use constructing confidence interval proportion difference. stratification variable can supplied via strata element variables argument.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Proportion difference estimation — prop_diff","text":"","code":"estimate_proportion_diff( lyt, vars, variables = list(strata = NULL), conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"cmh\", \"ha\", \"newcombe\", \"newcombecc\", \"strat_newcombe\", \"strat_newcombecc\"), weights_method = \"cmh\", na_str = default_na_str(), nested = TRUE, ..., var_labels = vars, show_labels = \"hidden\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"cmh\", \"ha\", \"newcombe\", \"newcombecc\", \"strat_newcombe\", \"strat_newcombecc\"), weights_method = \"cmh\" ) a_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"cmh\", \"ha\", \"newcombe\", \"newcombecc\", \"strat_newcombe\", \"strat_newcombecc\"), weights_method = \"cmh\" )"},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Proportion difference estimation — prop_diff","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. conf_level (proportion) confidence level interval. method (string) method used confidence interval estimation. weights_method (string) weights method. Can either \"cmh\" \"heuristic\" directs way weights estimated. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'diff', 'diff_ci' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Proportion difference estimation — prop_diff","text":"estimate_proportion_diff() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_proportion_diff() table layout. s_proportion_diff() returns named list elements diff diff_ci. a_proportion_diff() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Proportion difference estimation — prop_diff","text":"estimate_proportion_diff(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_proportion_diff(): Statistics function estimating difference terms responder proportion. a_proportion_diff(): Formatted analysis function used afun estimate_proportion_diff().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Proportion difference estimation — prop_diff","text":"performing unstratified analysis, methods \"cmh\", \"strat_newcombe\", \"strat_newcombecc\" permitted.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Proportion difference estimation — prop_diff","text":"","code":"## \"Mid\" case: 4/4 respond in group A, 1/2 respond in group B. nex <- 100 # Number of example rows dta <- data.frame( \"rsp\" = sample(c(TRUE, FALSE), nex, TRUE), \"grp\" = sample(c(\"A\", \"B\"), nex, TRUE), \"f1\" = sample(c(\"a1\", \"a2\"), nex, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), nex, TRUE), stringsAsFactors = TRUE ) l <- basic_table() %>% split_cols_by(var = \"grp\", ref_group = \"B\") %>% estimate_proportion_diff( vars = \"rsp\", conf_level = 0.90, method = \"ha\" ) build_table(l, df = dta) #> A B #> —————————————————————————————————————————————————— #> Difference in Response rate (%) 12.0 #> 90% CI (Anderson-Hauck) (-5.4, 29.4) s_proportion_diff( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, conf_level = 0.90, method = \"ha\" ) #> $diff #> [1] 12 #> attr(,\"label\") #> [1] \"Difference in Response rate (%)\" #> #> $diff_ci #> [1] -5.374519 29.374519 #> attr(,\"label\") #> [1] \"90% CI (Anderson-Hauck)\" #> # CMH example with strata s_proportion_diff( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, variables = list(strata = c(\"f1\", \"f2\")), conf_level = 0.90, method = \"cmh\" ) #> $diff #> [1] 12.05847 #> attr(,\"label\") #> [1] \"Difference in Response rate (%)\" #> #> $diff_ci #> [1] -2.67057 26.78750 #> attr(,\"label\") #> [1] \"90% CI (CMH, without correction)\" #> a_proportion_diff( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, conf_level = 0.90, method = \"ha\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 diff 12.0 0 Difference in Response rate (%) #> 2 diff_ci (-5.4, 29.4) 1 90% CI (Anderson-Hauck)"},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Difference test for two proportions — prop_diff_test","title":"Difference test for two proportions — prop_diff_test","text":"analyze function test_proportion_diff() creates layout element test difference two proportions. primary analysis variable, vars, indicates whether response occurred record. See method parameter options methods use calculate p-value. Additionally, stratification variable can supplied via strata element variables argument.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Difference test for two proportions — prop_diff_test","text":"","code":"test_proportion_diff( lyt, vars, variables = list(strata = NULL), method = c(\"chisq\", \"schouten\", \"fisher\", \"cmh\"), na_str = default_na_str(), nested = TRUE, ..., var_labels = vars, show_labels = \"hidden\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_test_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), method = c(\"chisq\", \"schouten\", \"fisher\", \"cmh\") ) a_test_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), method = c(\"chisq\", \"schouten\", \"fisher\", \"cmh\") )"},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Difference test for two proportions — prop_diff_test","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. method (string) one chisq, cmh, fisher, schouten; specifies test used calculate p-value. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'pval' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Difference test for two proportions — prop_diff_test","text":"test_proportion_diff() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_test_proportion_diff() table layout. s_test_proportion_diff() returns named list single item pval attribute label describing method used. p-value tests null hypothesis proportions two groups . a_test_proportion_diff() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff_test.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Difference test for two proportions — prop_diff_test","text":"test_proportion_diff(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_test_proportion_diff(): Statistics function tests difference two proportions. a_test_proportion_diff(): Formatted analysis function used afun test_proportion_diff().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/prop_diff_test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Difference test for two proportions — prop_diff_test","text":"","code":"dta <- data.frame( rsp = sample(c(TRUE, FALSE), 100, TRUE), grp = factor(rep(c(\"A\", \"B\"), each = 50)), strata = factor(rep(c(\"V\", \"W\", \"X\", \"Y\", \"Z\"), each = 20)) ) # With `rtables` pipelines. l <- basic_table() %>% split_cols_by(var = \"grp\", ref_group = \"B\") %>% test_proportion_diff( vars = \"rsp\", method = \"cmh\", variables = list(strata = \"strata\") ) build_table(l, df = dta) #> A B #> ————————————————————————————————————————————————————— #> p-value (Cochran-Mantel-Haenszel Test) 1.0000"},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":null,"dir":"Reference","previous_headings":"","what":"Occurrence table pruning — prune_occurrences","title":"Occurrence table pruning — prune_occurrences","text":"Family constructor condition functions flexibly prune occurrence tables. condition functions always return whether row result higher threshold. Since class CombinationFunction() can logically combined condition functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Occurrence table pruning — prune_occurrences","text":"","code":"keep_rows(row_condition) keep_content_rows(content_row_condition) has_count_in_cols(atleast, ...) has_count_in_any_col(atleast, ...) has_fraction_in_cols(atleast, ...) has_fraction_in_any_col(atleast, ...) has_fractions_difference(atleast, ...) has_counts_difference(atleast, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Occurrence table pruning — prune_occurrences","text":"row_condition (CombinationFunction) condition function works individual analysis rows flags whether kept pruned table. content_row_condition (CombinationFunction) condition function works individual first content rows leaf tables flags whether leaf tables kept pruned table. atleast (numeric(1)) threshold met order keep row. ... arguments row column access, see rtables_access: either col_names (character) including names columns used, alternatively col_indices (integer) giving indices directly instead.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Occurrence table pruning — prune_occurrences","text":"keep_rows() returns pruning function can used rtables::prune_table() prune rtables table. keep_content_rows() returns pruning function checks condition first content row leaf tables table. has_count_in_cols() returns condition function sums counts specified column. has_count_in_any_col() returns condition function compares counts specified columns threshold. has_fraction_in_cols() returns condition function sums counts specified column, computes fraction dividing total column counts. has_fraction_in_any_col() returns condition function looks fractions specified columns checks whether fulfill threshold. has_fractions_difference() returns condition function extracts fractions specified column, computes difference minimum maximum. has_counts_difference() returns condition function extracts counts specified column, computes difference minimum maximum.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Occurrence table pruning — prune_occurrences","text":"keep_rows(): Constructor creating pruning functions based row condition function. removes analysis rows (TableRow) pruned, .e., fulfill row condition. removes sub-tree children left. keep_content_rows(): Constructor creating pruning functions based condition (first) content row leaf tables. removes leaf tables first content row fulfill condition. check individual rows. proceeds recursively removing sub tree children left. has_count_in_cols(): Constructor creating condition functions total counts specified columns. has_count_in_any_col(): Constructor creating condition functions counts specified columns satisfying threshold. has_fraction_in_cols(): Constructor creating condition functions total fraction specified columns. has_fraction_in_any_col(): Constructor creating condition functions fraction specified columns. has_fractions_difference(): Constructor creating condition function checks difference fractions reported specified column. has_counts_difference(): Constructor creating condition function checks difference counts reported specified column.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Occurrence table pruning — prune_occurrences","text":"Since table specifications worded positively, name constructor condition functions positively, . However, note result keep_rows() says pruned, conform rtables::prune_table() interface.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/prune_occurrences.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Occurrence table pruning — prune_occurrences","text":"","code":"# \\donttest{ tab <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"RACE\") %>% split_rows_by(\"STRATA1\") %>% summarize_row_groups() %>% analyze_vars(\"COUNTRY\", .stats = \"count_fraction\") %>% build_table(DM) # } # \\donttest{ # `keep_rows` is_non_empty <- !CombinationFunction(all_zero_or_na) prune_table(tab, keep_rows(is_non_empty)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # `keep_content_rows` # \\donttest{ more_than_twenty <- has_count_in_cols(atleast = 20L, col_names = names(tab)) prune_table(tab, keep_content_rows(more_than_twenty)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> CHE 0 0 0 #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> CAN 0 0 0 #> CHE 0 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> GBR 0 0 0 #> CAN 0 0 0 #> CHE 0 0 0 #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> RUS 0 0 0 #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> CAN 0 0 0 #> CHE 0 0 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> NGA 0 0 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> CHE 0 0 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> JPN 0 0 0 #> GBR 0 0 0 #> CAN 0 0 0 #> CHE 0 0 0 # } # \\donttest{ more_than_one <- has_count_in_cols(atleast = 1L, col_names = names(tab)) prune_table(tab, keep_rows(more_than_one)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ # `has_count_in_any_col` any_more_than_one <- has_count_in_any_col(atleast = 1L, col_names = names(tab)) prune_table(tab, keep_rows(any_more_than_one)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ # `has_fraction_in_cols` more_than_five_percent <- has_fraction_in_cols(atleast = 0.05, col_names = names(tab)) prune_table(tab, keep_rows(more_than_five_percent)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> BLACK OR AFRICAN AMERICAN #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) # } # \\donttest{ # `has_fraction_in_any_col` any_atleast_five_percent <- has_fraction_in_any_col(atleast = 0.05, col_names = names(tab)) prune_table(tab, keep_rows(any_atleast_five_percent)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ # `has_fractions_difference` more_than_five_percent_diff <- has_fractions_difference(atleast = 0.05, col_names = names(tab)) prune_table(tab, keep_rows(more_than_five_percent_diff)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ more_than_one_diff <- has_counts_difference(atleast = 1L, col_names = names(tab)) prune_table(tab, keep_rows(more_than_one_diff)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # }"},{"path":"https://insightsengineering.github.io/tern/reference/range_noinf.html","id":null,"dir":"Reference","previous_headings":"","what":"Re-implemented range() default S3 method for numerical objects — range_noinf","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"function returns c(NA, NA) instead c(-Inf, Inf) zero-length data without warnings.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/range_noinf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"","code":"range_noinf(x, na.rm = FALSE, finite = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/range_noinf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"x (numeric) sequence numbers range computed. na.rm (flag) flag indicating NA omitted. finite (flag) flag indicating non-finite elements removed.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/range_noinf.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"2-element vector class numeric.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/reapply_varlabels.html","id":null,"dir":"Reference","previous_headings":"","what":"Reapply variable labels — reapply_varlabels","title":"Reapply variable labels — reapply_varlabels","text":"helper function used tests.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/reapply_varlabels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reapply variable labels — reapply_varlabels","text":"","code":"reapply_varlabels(x, varlabels, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/reapply_varlabels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reapply variable labels — reapply_varlabels","text":"x (vector) vector elements needs new labels. varlabels (character) vector labels x. ... parameters added list.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/reapply_varlabels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reapply variable labels — reapply_varlabels","text":"x variable labels reapplied.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"tabulate_rsp_biomarkers() function creates layout element tabulate estimated biomarker effects binary response endpoint across subgroups, returning statistics including response rate odds ratio population subgroup. table created df, list data frames returned extract_rsp_biomarkers(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"","code":"tabulate_rsp_biomarkers( df, vars = c(\"n_tot\", \"n_rsp\", \"prop\", \"or\", \"ci\", \"pval\"), na_str = default_na_str(), .indent_mods = 0L )"},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"df (data.frame) containing analysis variables, returned extract_rsp_biomarkers(). vars (character) names statistics reported among: n_tot: Total number patients per group. n_rsp: Total number responses per group. prop: Total response proportion per group. : Odds ratio. ci: Confidence interval odds ratio. pval: p-value effect. Note, statistics n_tot, ci required. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"rtables table summarizing biomarker effects binary response subgroup.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"functions create layout starting data frame contains required statistics. tables typically used input forest plots.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"contrast tabulate_rsp_subgroups() tabulation function start input layout lyt. internally table created combining multiple subtables.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/response_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% mutate(rsp = AVALC == \"CR\") formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") df <- extract_rsp_biomarkers( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", subgroups = \"BMRKR2\" ), data = adrs_f ) # \\donttest{ ## Table with default columns. tabulate_rsp_biomarkers(df) #> Total n Responders Response (%) Odds Ratio 95% CI p-value (Wald) #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Age #> All Patients 200 164 82.0% 1.00 (0.95, 1.05) 0.8530 #> Continuous Level Biomarker 2 #> LOW 70 53 75.7% 0.93 (0.85, 1.01) 0.0845 #> MEDIUM 68 58 85.3% 0.99 (0.88, 1.11) 0.8190 #> HIGH 62 53 85.5% 1.06 (0.96, 1.18) 0.2419 #> Continuous Level Biomarker 1 #> All Patients 200 164 82.0% 0.98 (0.88, 1.08) 0.6353 #> Continuous Level Biomarker 2 #> LOW 70 53 75.7% 1.15 (0.95, 1.40) 0.1584 #> MEDIUM 68 58 85.3% 0.88 (0.73, 1.06) 0.1700 #> HIGH 62 53 85.5% 0.88 (0.72, 1.08) 0.2104 ## Table with a manually chosen set of columns: leave out \"pval\", reorder. tab <- tabulate_rsp_biomarkers( df = df, vars = c(\"n_rsp\", \"ci\", \"n_tot\", \"prop\", \"or\") ) ## Finally produce the forest plot. g_forest(tab, xlim = c(0.7, 1.4)) # }"},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate binary response by subgroup — response_subgroups","title":"Tabulate binary response by subgroup — response_subgroups","text":"tabulate_rsp_subgroups() function creates layout element tabulate binary response subgroup, returning statistics including response rate odds ratio population subgroup. table created df, list data frames returned extract_rsp_subgroups(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate binary response by subgroup — response_subgroups","text":"","code":"tabulate_rsp_subgroups( lyt, df, vars = c(\"n_tot\", \"n\", \"prop\", \"or\", \"ci\"), groups_lists = list(), label_all = \"All Patients\", riskdiff = NULL, na_str = default_na_str(), .formats = c(n = \"xx\", n_rsp = \"xx\", prop = \"xx.x%\", n_tot = \"xx\", or = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\") ) a_response_subgroups( .formats = list(n = \"xx\", n_rsp = \"xx\", prop = \"xx.x%\", n_tot = \"xx\", or = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\", riskdiff = \"xx.x (xx.x - xx.x)\"), na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate binary response by subgroup — response_subgroups","text":"lyt (PreDataTableLayouts) layout analyses added . df (list) list data frames containing analysis variables. List created using extract_rsp_subgroups(). vars (character) names statistics reported among: n: Total number observations per group. n_rsp: Number responders per group. prop: Proportion responders. n_tot: Total number observations. : Odds ratio. ci : Confidence interval odds ratio. pval: p-value effect. Note, statistics n_tot, , ci required. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all (string) label total population analysis. riskdiff (list) risk (proportion) difference column added, list settings apply within column. See control_riskdiff() details. NULL, risk difference column added. riskdiff$arm_x riskdiff$arm_y NULL, first level df$prop$arm used arm_x second level arm_y. na_str (string) string used replace NA empty values output. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate binary response by subgroup — response_subgroups","text":"rtables table summarizing binary response subgroup. a_response_subgroups() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate binary response by subgroup — response_subgroups","text":"functions create layout starting data frame contains required statistics. Tables typically used part forest plot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Tabulate binary response by subgroup — response_subgroups","text":"tabulate_rsp_subgroups(): Table-creating function creates table summarizing binary response subgroup. function wrapper rtables::analyze_colvars() rtables::summarize_row_groups(). a_response_subgroups(): Formatted analysis function used afun tabulate_rsp_subgroups().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/response_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate binary response by subgroup — response_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>% droplevels() %>% mutate( # Reorder levels of factor to make the placebo group the reference arm. ARM = fct_relevel(ARM, \"B: Placebo\"), rsp = AVALC == \"CR\" ) formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") # Unstratified analysis. df <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f ) df #> $prop #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2 #> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2 #> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2 #> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2 #> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2 #> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $or #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.1804488 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.2669576 51.452218 0.95 F SEX #> 3 64 0.920000 0.2966470 2.853223 0.95 M SEX #> 4 50 3.553846 1.0047370 12.570277 0.95 LOW BMRKR2 #> 5 49 2.705882 0.5911718 12.385232 0.95 MEDIUM BMRKR2 #> 6 43 2.250000 0.3970298 12.750933 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> # Stratified analysis. df_strat <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\"), strata = \"STRATA1\"), data = adrs_f ) df_strat #> $prop #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2 #> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2 #> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2 #> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2 #> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2 #> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $or #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.6343899 1.1537821 6.015009 0.95 All Patients ALL #> 2 78 9.5946605 2.0379337 45.171985 0.95 F SEX #> 3 64 0.8947158 0.2936803 2.725809 0.95 M SEX #> 4 50 3.5976656 1.0101319 12.813374 0.95 LOW BMRKR2 #> 5 49 2.6242168 0.5162572 13.339308 0.95 MEDIUM BMRKR2 #> 6 43 2.2816865 0.4116391 12.647228 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> # Grouping of the BMRKR2 levels. df_grouped <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) df_grouped #> $prop #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 low BMRKR2 #> 8 A: Drug X 26 21 0.8076923 low BMRKR2 #> 9 B: Placebo 47 30 0.6382979 low/medium BMRKR2 #> 10 A: Drug X 52 44 0.8461538 low/medium BMRKR2 #> 11 B: Placebo 73 50 0.6849315 low/medium/high BMRKR2 #> 12 A: Drug X 69 59 0.8550725 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $or #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.180449 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.266958 51.452218 0.95 F SEX #> 3 64 0.920000 0.296647 2.853223 0.95 M SEX #> 4 50 3.553846 1.004737 12.570277 0.95 low BMRKR2 #> 5 99 3.116667 1.193409 8.139385 0.95 low/medium BMRKR2 #> 6 142 2.714000 1.180449 6.239827 0.95 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> # Table with default columns basic_table() %>% tabulate_rsp_subgroups(df) #> B: Placebo A: Drug X #> Baseline Risk Factors Total n n Response (%) n Response (%) Odds Ratio 95% CI #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————— #> All Patients 142 73 68.5% 69 85.5% 2.71 (1.18, 6.24) #> Sex #> F 78 40 62.5% 38 94.7% 10.80 (2.27, 51.45) #> M 64 33 75.8% 31 74.2% 0.92 (0.30, 2.85) #> Continuous Level Biomarker 2 #> LOW 50 24 54.2% 26 80.8% 3.55 (1.00, 12.57) #> MEDIUM 49 23 73.9% 26 88.5% 2.71 (0.59, 12.39) #> HIGH 43 26 76.9% 17 88.2% 2.25 (0.40, 12.75) # Table with selected columns basic_table() %>% tabulate_rsp_subgroups( df = df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\") ) #> B: Placebo A: Drug X #> Baseline Risk Factors Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> All Patients 142 73 50 68.5% 69 59 85.5% 2.71 (1.18, 6.24) #> Sex #> F 78 40 25 62.5% 38 36 94.7% 10.80 (2.27, 51.45) #> M 64 33 25 75.8% 31 23 74.2% 0.92 (0.30, 2.85) #> Continuous Level Biomarker 2 #> LOW 50 24 13 54.2% 26 21 80.8% 3.55 (1.00, 12.57) #> MEDIUM 49 23 17 73.9% 26 23 88.5% 2.71 (0.59, 12.39) #> HIGH 43 26 20 76.9% 17 15 88.2% 2.25 (0.40, 12.75) # Table with risk difference column added basic_table() %>% tabulate_rsp_subgroups( df, riskdiff = control_riskdiff( arm_x = levels(df$prop$arm)[1], arm_y = levels(df$prop$arm)[2] ) ) #> B: Placebo A: Drug X #> Baseline Risk Factors Total n n Response (%) n Response (%) Odds Ratio 95% CI Risk Difference (%) (95% CI) #> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> All Patients 142 73 68.5% 69 85.5% 2.71 (1.18, 6.24) -17.0 (-30.5 - -3.5) #> Sex #> F 78 40 62.5% 38 94.7% 10.80 (2.27, 51.45) -32.2 (-48.8 - -15.6) #> M 64 33 75.8% 31 74.2% 0.92 (0.30, 2.85) 1.6 (-19.7 - 22.8) #> Continuous Level Biomarker 2 #> LOW 50 24 54.2% 26 80.8% 3.55 (1.00, 12.57) -26.6 (-51.6 - -1.6) #> MEDIUM 49 23 73.9% 26 88.5% 2.71 (0.59, 12.39) -14.5 (-36.3 - 7.2) #> HIGH 43 26 76.9% 17 88.2% 2.25 (0.40, 12.75) -11.3 (-33.6 - 11.0)"},{"path":"https://insightsengineering.github.io/tern/reference/rtable2gg.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert rtable objects to ggplot objects — rtable2gg","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"Given rtables::rtable() object, performs basic conversion ggplot2::ggplot() object built using functions ggplot2 package. table titles /footnotes ignored.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/rtable2gg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"","code":"rtable2gg(tbl, fontsize = 12, colwidths = NULL, lbl_col_padding = 0)"},{"path":"https://insightsengineering.github.io/tern/reference/rtable2gg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"tbl (VTableTree)rtables table object. fontsize (numeric(1)) font size. colwidths (numeric NULL) vector column widths. element's position colwidths corresponds column tbl position. NULL, column widths calculated according maximum number characters per column. lbl_col_padding (numeric) additional padding use calculating spacing first (label) column second column tbl. colwidths specified, width first column becomes colwidths[1] + lbl_col_padding. Defaults 0.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/rtable2gg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/rtable2gg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"","code":"dta <- data.frame( ARM = rep(LETTERS[1:3], rep(6, 3)), AVISIT = rep(paste0(\"V\", 1:3), 6), AVAL = c(9:1, rep(NA, 9)) ) lyt <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\") tbl <- build_table(lyt, df = dta) rtable2gg(tbl) rtable2gg(tbl, fontsize = 15, colwidths = c(2, 1, 1, 1))"},{"path":"https://insightsengineering.github.io/tern/reference/rtables_access.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for accessing information from rtables — rtables_access","title":"Helper functions for accessing information from rtables — rtables_access","text":"couple functions help accessing data rtables objects. Currently work occurrence tables, defined count first element fraction second element cell.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/rtables_access.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for accessing information from rtables — rtables_access","text":"","code":"h_row_first_values(table_row, col_names = NULL, col_indices = NULL) h_row_counts(table_row, col_names = NULL, col_indices = NULL) h_row_fractions(table_row, col_names = NULL, col_indices = NULL) h_col_counts(table, col_names = NULL, col_indices = NULL) h_content_first_row(table) is_leaf_table(table) check_names_indices(table_row, col_names = NULL, col_indices = NULL)"},{"path":"https://insightsengineering.github.io/tern/reference/rtables_access.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for accessing information from rtables — rtables_access","text":"table_row (TableRow) analysis row occurrence table. col_names (character) names columns extract . col_indices (integer) indices columns extract . col_names provided, inferred names table_row. Note currently works well single column split. table (VTableNodeInfo) occurrence table row.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/rtables_access.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for accessing information from rtables — rtables_access","text":"h_row_first_values() returns vector numeric values. h_row_counts() returns vector numeric values. h_row_fractions() returns vector proportions. h_col_counts() returns vector column counts. h_content_first_row() returns row rtables table. is_leaf_table() returns logical value indicating whether current table leaf. check_names_indices returns column indices.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/rtables_access.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for accessing information from rtables — rtables_access","text":"h_row_first_values(): Helper function extract first values content cell specified columns TableRow. Defaults columns. h_row_counts(): Helper function extracts row values checks convertible integers (integerish values). h_row_fractions(): Helper function extract fractions specified columns TableRow. specifically extracts second values content cell checks fraction. h_col_counts(): Helper function extract column counts specified columns table. h_content_first_row(): Helper function get first row content table current table. is_leaf_table(): Helper function says whether current table leaf tree. check_names_indices(): Internal helper function tests standard inputs column indices.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/rtables_access.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for accessing information from rtables — rtables_access","text":"","code":"tbl <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"RACE\") %>% analyze(\"AGE\", function(x) { list( \"mean (sd)\" = rcell(c(mean(x), sd(x)), format = \"xx.x (xx.x)\"), \"n\" = length(x), \"frac\" = rcell(c(0.1, 0.1), format = \"xx (xx)\") ) }) %>% build_table(tern_ex_adsl) %>% prune_table() tree_row_elem <- collect_leaves(tbl[2, ])[[1]] result <- max(h_row_first_values(tree_row_elem)) result #> [1] 35.31214 # Row counts (integer values) # h_row_counts(tree_row_elem) # Fails because there are no integers # Using values with integers tree_row_elem <- collect_leaves(tbl[3, ])[[1]] result <- h_row_counts(tree_row_elem) # result # Row fractions tree_row_elem <- collect_leaves(tbl[4, ])[[1]] h_row_fractions(tree_row_elem) #> A: Drug X B: Placebo C: Combination #> 0.1 0.1 0.1"},{"path":"https://insightsengineering.github.io/tern/reference/s_bland_altman.html","id":null,"dir":"Reference","previous_headings":"","what":"Bland-Altman analysis — s_bland_altman","title":"Bland-Altman analysis — s_bland_altman","text":"Statistics function uses Bland-Altman method assess agreement two numerical vectors calculates variety statistics.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/s_bland_altman.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bland-Altman analysis — s_bland_altman","text":"","code":"s_bland_altman(x, y, conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/reference/s_bland_altman.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bland-Altman analysis — s_bland_altman","text":"x (numeric) vector numbers want analyze. y (numeric) vector numbers want analyze, compared x. conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/s_bland_altman.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bland-Altman analysis — s_bland_altman","text":"named list following elements: df difference_mean ci_mean difference_sd difference_se upper_agreement_limit lower_agreement_limit agreement_limit_se upper_agreement_limit_ci lower_agreement_limit_ci t_value n","code":""},{"path":"https://insightsengineering.github.io/tern/reference/s_bland_altman.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Bland-Altman analysis — s_bland_altman","text":"","code":"x <- seq(1, 60, 5) y <- seq(5, 50, 4) s_bland_altman(x, y, conf_level = 0.9) #> $df #> average difference #> 1 3.0 -4 #> 2 7.5 -3 #> 3 12.0 -2 #> 4 16.5 -1 #> 5 21.0 0 #> 6 25.5 1 #> 7 30.0 2 #> 8 34.5 3 #> 9 39.0 4 #> 10 43.5 5 #> 11 48.0 6 #> 12 52.5 7 #> #> $difference_mean #> [1] 1.5 #> #> $ci_mean #> [1] -0.3692162 3.3692162 #> #> $difference_sd #> [1] 3.605551 #> #> $difference_se #> [1] 1.040833 #> #> $upper_agreement_limit #> [1] 7.430604 #> #> $lower_agreement_limit #> [1] -4.430604 #> #> $agreement_limit_se #> [1] 1.802776 #> #> $upper_agreement_limit_ci #> [1] 4.193027 10.668181 #> #> $lower_agreement_limit_ci #> [1] -7.668181 -1.193027 #> #> $t_value #> [1] 1.795885 #> #> $n #> [1] 12 #>"},{"path":"https://insightsengineering.github.io/tern/reference/s_cox_multivariate.html","id":null,"dir":"Reference","previous_headings":"","what":"Multivariate Cox model - summarized results — s_cox_multivariate","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"Analyses based multivariate Cox model usually performed Controlled Substance Reporting regulatory documents serve exploratory purposes (e.g., publication). practice, model usually includes main effects (without interaction terms). produces hazard ratio estimates covariates included model. analysis follows principles (e.g., stratified vs. unstratified analysis tie handling) usual Cox model analysis. Since usually pre-specified hypothesis testing analysis, p.values need interpreted caution. (Statistical Analysis Clinical Trials Data R, NEST's bookdown)","code":""},{"path":"https://insightsengineering.github.io/tern/reference/s_cox_multivariate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"","code":"s_cox_multivariate( formula, data, conf_level = 0.95, pval_method = c(\"wald\", \"likelihood\"), ... )"},{"path":"https://insightsengineering.github.io/tern/reference/s_cox_multivariate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"formula (formula) formula corresponding investigated survival::Surv() survival model including covariates. data (data.frame) data frame includes variable formula covariates. conf_level (proportion) confidence level hazard ratio interval estimations. Default 0.95. pval_method (string) method used estimation p-values, one \"wald\" (default) \"likelihood\". ... optional parameters passed survival::coxph(). Can include ties, character string specifying method tie handling, one exact (default), efron, breslow.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/s_cox_multivariate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"list elements mod, msum, aov, coef_inter.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/s_cox_multivariate.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"output limited single effect terms. Work ongoing estimation interaction terms scope defined Global Data Standards Repository (GDS_Standard_TLG_Specs_Tables_2.doc).","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/s_cox_multivariate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"","code":"library(dplyr) adtte <- tern_ex_adtte adtte_f <- subset(adtte, PARAMCD == \"OS\") # _f: filtered adtte_f <- filter( adtte_f, PARAMCD == \"OS\" & SEX %in% c(\"F\", \"M\") & RACE %in% c(\"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"WHITE\") ) adtte_f$SEX <- droplevels(adtte_f$SEX) adtte_f$RACE <- droplevels(adtte_f$RACE)"},{"path":"https://insightsengineering.github.io/tern/reference/sas_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert strings to NA — sas_na","title":"Convert strings to NA — sas_na","text":"SAS imports missing data empty strings strings whitespaces . helper function can used convert values NAs.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/sas_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert strings to NA — sas_na","text":"","code":"sas_na(x, empty = TRUE, whitespaces = TRUE)"},{"path":"https://insightsengineering.github.io/tern/reference/sas_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert strings to NA — sas_na","text":"x (factor character) values missing values substituted. empty (flag) TRUE, empty strings get replaced NA. whitespaces (flag) TRUE, strings made whitespaces get replaced NA.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/sas_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert strings to NA — sas_na","text":"x \"\" /whitespace-values substituted NA, depending values empty whitespaces.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/sas_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert strings to NA — sas_na","text":"","code":"sas_na(c(\"1\", \"\", \" \", \" \", \"b\")) #> [1] \"1\" NA NA NA \"b\" sas_na(factor(c(\"\", \" \", \"b\"))) #> [1] b #> Levels: b is.na(sas_na(c(\"1\", \"\", \" \", \" \", \"b\"))) #> [1] FALSE TRUE TRUE TRUE FALSE"},{"path":"https://insightsengineering.github.io/tern/reference/score_occurrences.html","id":null,"dir":"Reference","previous_headings":"","what":"Occurrence table sorting — score_occurrences","title":"Occurrence table sorting — score_occurrences","text":"Functions score occurrence table subtables rows can used sorting occurrence tables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/score_occurrences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Occurrence table sorting — score_occurrences","text":"","code":"score_occurrences(table_row) score_occurrences_cols(...) score_occurrences_subtable(...) score_occurrences_cont_cols(...)"},{"path":"https://insightsengineering.github.io/tern/reference/score_occurrences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Occurrence table sorting — score_occurrences","text":"table_row (TableRow) analysis row occurrence table. ... arguments row column access, see rtables_access: either col_names (character) including names columns used, alternatively col_indices (integer) giving indices directly instead.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/score_occurrences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Occurrence table sorting — score_occurrences","text":"score_occurrences() returns sum counts across columns table row. score_occurrences_cols() returns function sums counts across specified columns table row. score_occurrences_subtable() returns function sums counts subtable across specified columns. score_occurrences_cont_cols() returns function sums counts first content row specified columns.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/score_occurrences.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Occurrence table sorting — score_occurrences","text":"score_occurrences(): Scoring function sums counts across columns. fail anything else counts used. score_occurrences_cols(): Scoring functions can produced constructor include specific columns scoring. See h_row_counts() information. score_occurrences_subtable(): Scoring functions produced constructor can used subtables: sum specified column counts subtable. useful available content row summing counts. score_occurrences_cont_cols(): Produces score function sorting table summing first content row specified columns. Note extending rtables::cont_n_onecol() rtables::cont_n_allcols().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/score_occurrences.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Occurrence table sorting — score_occurrences","text":"","code":"lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% analyze_num_patients( vars = \"USUBJID\", .stats = c(\"unique\"), .labels = c(\"Total number of patients with at least one event\") ) %>% split_rows_by(\"AEBODSYS\", child_labels = \"visible\", nested = FALSE) %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( \"Total number of patients with at least one event\", \"Total number of events\" ) ) %>% count_occurrences(vars = \"AEDECOD\") tbl <- build_table(lyt, tern_ex_adae, alt_counts_df = tern_ex_adsl) %>% prune_table() tbl_sorted <- tbl %>% sort_at_path(path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"), scorefun = score_occurrences) tbl_sorted #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> cl D.1 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 20 (34.5%) #> Total number of events 39 35 28 #> dcd D.1.1.4.2 16 (23.2%) 13 (17.8%) 16 (27.6%) #> dcd D.1.1.1.1 17 (24.6%) 18 (24.7%) 7 (12.1%) #> cl C.1 #> Total number of patients with at least one event 15 (21.7%) 13 (17.8%) 18 (31.0%) #> Total number of events 17 15 19 #> dcd C.1.1.1.3 15 (21.7%) 13 (17.8%) 18 (31.0%) #> cl C.2 #> Total number of patients with at least one event 20 (29.0%) 14 (19.2%) 10 (17.2%) #> Total number of events 21 15 14 #> dcd C.2.1.2.1 20 (29.0%) 14 (19.2%) 10 (17.2%) #> cl B.2 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 24 (41.4%) #> Total number of events 40 38 33 #> dcd B.2.2.3.1 17 (24.6%) 15 (20.5%) 16 (27.6%) #> dcd B.2.1.2.1 17 (24.6%) 16 (21.9%) 13 (22.4%) #> cl B.1 #> Total number of patients with at least one event 15 (21.7%) 19 (26.0%) 15 (25.9%) #> Total number of events 19 19 18 #> dcd B.1.1.1.1 15 (21.7%) 19 (26.0%) 15 (25.9%) #> cl D.2 #> Total number of patients with at least one event 21 (30.4%) 20 (27.4%) 12 (20.7%) #> Total number of events 27 22 15 #> dcd D.2.1.5.3 21 (30.4%) 20 (27.4%) 12 (20.7%) #> cl A.1 #> Total number of patients with at least one event 31 (44.9%) 24 (32.9%) 27 (46.6%) #> Total number of events 39 33 35 #> dcd A.1.1.1.1 17 (24.6%) 17 (23.3%) 14 (24.1%) #> dcd A.1.1.1.2 17 (24.6%) 14 (19.2%) 17 (29.3%) score_cols_a_and_b <- score_occurrences_cols(col_names = c(\"A: Drug X\", \"B: Placebo\")) # Note that this here just sorts the AEDECOD inside the AEBODSYS. The AEBODSYS are not sorted. # That would require a second pass of `sort_at_path`. tbl_sorted <- tbl %>% sort_at_path(path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"), scorefun = score_cols_a_and_b) tbl_sorted #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> cl D.1 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 20 (34.5%) #> Total number of events 39 35 28 #> dcd D.1.1.1.1 17 (24.6%) 18 (24.7%) 7 (12.1%) #> dcd D.1.1.4.2 16 (23.2%) 13 (17.8%) 16 (27.6%) #> cl C.1 #> Total number of patients with at least one event 15 (21.7%) 13 (17.8%) 18 (31.0%) #> Total number of events 17 15 19 #> dcd C.1.1.1.3 15 (21.7%) 13 (17.8%) 18 (31.0%) #> cl C.2 #> Total number of patients with at least one event 20 (29.0%) 14 (19.2%) 10 (17.2%) #> Total number of events 21 15 14 #> dcd C.2.1.2.1 20 (29.0%) 14 (19.2%) 10 (17.2%) #> cl B.2 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 24 (41.4%) #> Total number of events 40 38 33 #> dcd B.2.1.2.1 17 (24.6%) 16 (21.9%) 13 (22.4%) #> dcd B.2.2.3.1 17 (24.6%) 15 (20.5%) 16 (27.6%) #> cl B.1 #> Total number of patients with at least one event 15 (21.7%) 19 (26.0%) 15 (25.9%) #> Total number of events 19 19 18 #> dcd B.1.1.1.1 15 (21.7%) 19 (26.0%) 15 (25.9%) #> cl D.2 #> Total number of patients with at least one event 21 (30.4%) 20 (27.4%) 12 (20.7%) #> Total number of events 27 22 15 #> dcd D.2.1.5.3 21 (30.4%) 20 (27.4%) 12 (20.7%) #> cl A.1 #> Total number of patients with at least one event 31 (44.9%) 24 (32.9%) 27 (46.6%) #> Total number of events 39 33 35 #> dcd A.1.1.1.1 17 (24.6%) 17 (23.3%) 14 (24.1%) #> dcd A.1.1.1.2 17 (24.6%) 14 (19.2%) 17 (29.3%) score_subtable_all <- score_occurrences_subtable(col_names = names(tbl)) # Note that this code just sorts the AEBODSYS, not the AEDECOD within AEBODSYS. That # would require a second pass of `sort_at_path`. tbl_sorted <- tbl %>% sort_at_path(path = c(\"AEBODSYS\"), scorefun = score_subtable_all, decreasing = FALSE) tbl_sorted #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> cl C.2 #> Total number of patients with at least one event 20 (29.0%) 14 (19.2%) 10 (17.2%) #> Total number of events 21 15 14 #> dcd C.2.1.2.1 20 (29.0%) 14 (19.2%) 10 (17.2%) #> cl C.1 #> Total number of patients with at least one event 15 (21.7%) 13 (17.8%) 18 (31.0%) #> Total number of events 17 15 19 #> dcd C.1.1.1.3 15 (21.7%) 13 (17.8%) 18 (31.0%) #> cl B.1 #> Total number of patients with at least one event 15 (21.7%) 19 (26.0%) 15 (25.9%) #> Total number of events 19 19 18 #> dcd B.1.1.1.1 15 (21.7%) 19 (26.0%) 15 (25.9%) #> cl D.2 #> Total number of patients with at least one event 21 (30.4%) 20 (27.4%) 12 (20.7%) #> Total number of events 27 22 15 #> dcd D.2.1.5.3 21 (30.4%) 20 (27.4%) 12 (20.7%) #> cl D.1 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 20 (34.5%) #> Total number of events 39 35 28 #> dcd D.1.1.1.1 17 (24.6%) 18 (24.7%) 7 (12.1%) #> dcd D.1.1.4.2 16 (23.2%) 13 (17.8%) 16 (27.6%) #> cl B.2 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 24 (41.4%) #> Total number of events 40 38 33 #> dcd B.2.1.2.1 17 (24.6%) 16 (21.9%) 13 (22.4%) #> dcd B.2.2.3.1 17 (24.6%) 15 (20.5%) 16 (27.6%) #> cl A.1 #> Total number of patients with at least one event 31 (44.9%) 24 (32.9%) 27 (46.6%) #> Total number of events 39 33 35 #> dcd A.1.1.1.1 17 (24.6%) 17 (23.3%) 14 (24.1%) #> dcd A.1.1.1.2 17 (24.6%) 14 (19.2%) 17 (29.3%)"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/split_cols_by_groups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split columns by groups of levels — split_cols_by_groups","text":"","code":"split_cols_by_groups(lyt, var, groups_list = NULL, ref_group = NULL, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/split_cols_by_groups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split columns by groups of levels — split_cols_by_groups","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. groups_list (named list character) specifies new group levels via names levels belong character vectors elements list. ref_group (data.frame vector) data corresponding reference group. ... additional arguments rtables::split_cols_by() order. instance, control formats (format), add joint column groups (incl_all).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/split_cols_by_groups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split columns by groups of levels — split_cols_by_groups","text":"layout object suitable passing layouting functions. Adding function rtable layout add column split including given groups table layout.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/split_cols_by_groups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split columns by groups of levels — split_cols_by_groups","text":"","code":"# 1 - Basic use # Without group combination `split_cols_by_groups` is # equivalent to [rtables::split_cols_by()]. basic_table() %>% split_cols_by_groups(\"ARM\") %>% add_colcounts() %>% analyze(\"AGE\") %>% build_table(DM) #> A: Drug X B: Placebo C: Combination #> (N=121) (N=106) (N=129) #> —————————————————————————————————————————————— #> Mean 34.91 33.02 34.57 # Add a reference column. basic_table() %>% split_cols_by_groups(\"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% analyze( \"AGE\", afun = function(x, .ref_group, .in_ref_col) { if (.in_ref_col) { in_rows(\"Diff Mean\" = rcell(NULL)) } else { in_rows(\"Diff Mean\" = rcell(mean(x) - mean(.ref_group), format = \"xx.xx\")) } } ) %>% build_table(DM) #> A: Drug X B: Placebo C: Combination #> (N=121) (N=106) (N=129) #> ——————————————————————————————————————————————————— #> Diff Mean 1.89 1.55 # 2 - Adding group specification # Manual preparation of the groups. groups <- list( \"Arms A+B\" = c(\"A: Drug X\", \"B: Placebo\"), \"Arms A+C\" = c(\"A: Drug X\", \"C: Combination\") ) # Use of split_cols_by_groups without reference column. basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze(\"AGE\") %>% build_table(DM) #> Arms A+B Arms A+C #> (N=227) (N=250) #> —————————————————————————— #> Mean 34.03 34.73 # Including differentiated output in the reference column. basic_table() %>% split_cols_by_groups(\"ARM\", groups_list = groups, ref_group = \"Arms A+B\") %>% analyze( \"AGE\", afun = function(x, .ref_group, .in_ref_col) { if (.in_ref_col) { in_rows(\"Diff. of Averages\" = rcell(NULL)) } else { in_rows(\"Diff. of Averages\" = rcell(mean(x) - mean(.ref_group), format = \"xx.xx\")) } } ) %>% build_table(DM) #> Arms A+B Arms A+C #> ——————————————————————————————————————— #> Diff. of Averages 0.71 # 3 - Binary list dividing factor levels into reference and treatment # `combine_groups` defines reference and treatment. groups <- combine_groups( fct = DM$ARM, ref = c(\"A: Drug X\", \"B: Placebo\") ) groups #> $`A: Drug X/B: Placebo` #> [1] \"A: Drug X\" \"B: Placebo\" #> #> $`C: Combination` #> [1] \"C: Combination\" #> # Use group definition without reference column. basic_table() %>% split_cols_by_groups(\"ARM\", groups_list = groups) %>% add_colcounts() %>% analyze(\"AGE\") %>% build_table(DM) #> A: Drug X/B: Placebo C: Combination #> (N=227) (N=129) #> ———————————————————————————————————————————— #> Mean 34.03 34.57 # Use group definition with reference column (first item of groups). basic_table() %>% split_cols_by_groups(\"ARM\", groups, ref_group = names(groups)[1]) %>% add_colcounts() %>% analyze( \"AGE\", afun = function(x, .ref_group, .in_ref_col) { if (.in_ref_col) { in_rows(\"Diff Mean\" = rcell(NULL)) } else { in_rows(\"Diff Mean\" = rcell(mean(x) - mean(.ref_group), format = \"xx.xx\")) } } ) %>% build_table(DM) #> A: Drug X/B: Placebo C: Combination #> (N=227) (N=129) #> ————————————————————————————————————————————————— #> Diff Mean 0.54"},{"path":"https://insightsengineering.github.io/tern/reference/split_text_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Split text according to available text width — split_text_grob","title":"Split text according to available text width — split_text_grob","text":"Dynamically wrap text.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/split_text_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split text according to available text width — split_text_grob","text":"","code":"split_text_grob( text, x = grid::unit(0.5, \"npc\"), y = grid::unit(0.5, \"npc\"), width = grid::unit(1, \"npc\"), just = \"centre\", hjust = NULL, vjust = NULL, default.units = \"npc\", name = NULL, gp = grid::gpar(), vp = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/split_text_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split text according to available text width — split_text_grob","text":"text (string) text wrap. x numeric vector unit object specifying x-values. y numeric vector unit object specifying y-values. width (grid::unit) unit object specifying maximum width text. just justification text relative (x, y) location. two values, first value specifies horizontal justification second value specifies vertical justification. Possible string values : \"left\", \"right\", \"centre\", \"center\", \"bottom\", \"top\". numeric values, 0 means left (bottom) alignment 1 means right (top) alignment. hjust numeric vector specifying horizontal justification. specified, overrides just setting. vjust numeric vector specifying vertical justification. specified, overrides just setting. default.units string indicating default units use x y given numeric vectors. name character identifier. gp object class \"gpar\", typically output call function gpar. basically list graphical parameter settings. vp Grid viewport object (NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/reference/split_text_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split text according to available text width — split_text_grob","text":"text grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/split_text_grob.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Split text according to available text width — split_text_grob","text":"code taken R Graphics Paul Murell, 2nd edition","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stack_grobs.html","id":null,"dir":"Reference","previous_headings":"","what":"Stack multiple grobs — stack_grobs","title":"Stack multiple grobs — stack_grobs","text":"Stack grobs new grob 1 column multiple rows layout.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stack_grobs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stack multiple grobs — stack_grobs","text":"","code":"stack_grobs( ..., grobs = list(...), padding = grid::unit(2, \"line\"), vp = NULL, gp = NULL, name = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/stack_grobs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stack multiple grobs — stack_grobs","text":"... grobs. grobs (list grob) list grobs. padding (grid::unit) unit length 1, space grob. vp (viewport NULL) viewport() object (NULL). gp (gpar) gpar() object. name (string) character identifier grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stack_grobs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stack multiple grobs — stack_grobs","text":"grob.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stack_grobs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stack multiple grobs — stack_grobs","text":"","code":"library(grid) g1 <- circleGrob(gp = gpar(col = \"blue\")) g2 <- circleGrob(gp = gpar(col = \"red\")) g3 <- textGrob(\"TEST TEXT\") grid.newpage() grid.draw(stack_grobs(g1, g2, g3)) showViewport() grid.newpage() pushViewport(viewport(layout = grid.layout(1, 2))) vp1 <- viewport(layout.pos.row = 1, layout.pos.col = 2) grid.draw(stack_grobs(g1, g2, g3, vp = vp1, name = \"test\")) showViewport() grid.ls(grobs = TRUE, viewports = TRUE, print = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence interval for mean — stat_mean_ci","title":"Confidence interval for mean — stat_mean_ci","text":"Convenient function calculating mean confidence interval. calculates arithmetic well geometric mean. can used ggplot helper function plotting.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence interval for mean — stat_mean_ci","text":"","code":"stat_mean_ci( x, conf_level = 0.95, na.rm = TRUE, n_min = 2, gg_helper = TRUE, geom_mean = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence interval for mean — stat_mean_ci","text":"x (numeric) vector numbers want analyze. conf_level (proportion) confidence level interval. na.rm (flag) whether NA values removed x prior analysis. n_min (numeric(1)) minimum number non-missing x estimate confidence interval mean. gg_helper (flag) whether output aligned use ggplots. geom_mean (flag) whether geometric mean calculated.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence interval for mean — stat_mean_ci","text":"named vector values mean_ci_lwr mean_ci_upr.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence interval for mean — stat_mean_ci","text":"","code":"stat_mean_ci(sample(10), gg_helper = FALSE) #> mean_ci_lwr mean_ci_upr #> 3.334149 7.665851 p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) + ggplot2::geom_point() p + ggplot2::stat_summary( fun.data = stat_mean_ci, geom = \"errorbar\" ) p + ggplot2::stat_summary( fun.data = stat_mean_ci, fun.args = list(conf_level = 0.5), geom = \"errorbar\" ) p + ggplot2::stat_summary( fun.data = stat_mean_ci, fun.args = list(conf_level = 0.5, geom_mean = TRUE), geom = \"errorbar\" )"},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_pval.html","id":null,"dir":"Reference","previous_headings":"","what":"p-Value of the mean — stat_mean_pval","title":"p-Value of the mean — stat_mean_pval","text":"Convenient function calculating two-sided p-value mean.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_pval.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"p-Value of the mean — stat_mean_pval","text":"","code":"stat_mean_pval(x, na.rm = TRUE, n_min = 2, test_mean = 0)"},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_pval.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"p-Value of the mean — stat_mean_pval","text":"x (numeric) vector numbers want analyze. na.rm (flag) whether NA values removed x prior analysis. n_min (numeric(1)) minimum number non-missing x estimate p-value mean. test_mean (numeric(1)) mean value test null hypothesis.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_pval.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"p-Value of the mean — stat_mean_pval","text":"p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_mean_pval.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"p-Value of the mean — stat_mean_pval","text":"","code":"stat_mean_pval(sample(10)) #> p_value #> 0.000278196 stat_mean_pval(rnorm(10), test_mean = 0.5) #> p_value #> 0.04235675"},{"path":"https://insightsengineering.github.io/tern/reference/stat_median_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence interval for median — stat_median_ci","title":"Confidence interval for median — stat_median_ci","text":"Convenient function calculating median confidence interval. can used ggplot helper function plotting.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_median_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence interval for median — stat_median_ci","text":"","code":"stat_median_ci(x, conf_level = 0.95, na.rm = TRUE, gg_helper = TRUE)"},{"path":"https://insightsengineering.github.io/tern/reference/stat_median_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence interval for median — stat_median_ci","text":"x (numeric) vector numbers want analyze. conf_level (proportion) confidence level interval. na.rm (flag) whether NA values removed x prior analysis. gg_helper (flag) whether output aligned use ggplots.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_median_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence interval for median — stat_median_ci","text":"named vector values median_ci_lwr median_ci_upr.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_median_ci.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Confidence interval for median — stat_median_ci","text":"function adapted DescTools/versions/0.99.35/source","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_median_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence interval for median — stat_median_ci","text":"","code":"stat_median_ci(sample(10), gg_helper = FALSE) #> median_ci_lwr median_ci_upr #> 2 9 #> attr(,\"conf_level\") #> [1] 0.9785156 p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) + ggplot2::geom_point() p + ggplot2::stat_summary( fun.data = stat_median_ci, geom = \"errorbar\" )"},{"path":"https://insightsengineering.github.io/tern/reference/stat_propdiff_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Proportion difference and confidence interval — stat_propdiff_ci","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"Function calculating proportion (risk) difference confidence interval arm X (reference group) arm Y. Risk difference calculated subtracting cumulative incidence arm Y cumulative incidence arm X.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_propdiff_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"","code":"stat_propdiff_ci( x, y, N_x, N_y, list_names = NULL, conf_level = 0.95, pct = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/stat_propdiff_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"x (list integer) list number occurrences arm X (reference group). y (list integer) list number occurrences arm Y. Must equal length x. N_x (numeric(1)) total number records arm X. N_y (numeric(1)) total number records arm Y. list_names (character) names variable/level corresponding pair proportions x y. Must equal length x y. conf_level (proportion) confidence level interval. pct (flag) whether output returned percentages. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/stat_propdiff_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"List proportion differences CIs corresponding pair number occurrences x y. list element consists 3 statistics: proportion difference, CI lower bound, CI upper bound.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/stat_propdiff_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"","code":"stat_propdiff_ci( x = list(0.375), y = list(0.01), N_x = 5, N_y = 5, list_names = \"x\", conf_level = 0.9 ) #> $x #> [1] 7.30000 -12.35184 26.95184 #> stat_propdiff_ci( x = list(0.5, 0.75, 1), y = list(0.25, 0.05, 0.5), N_x = 10, N_y = 20, pct = FALSE ) #> [[1]] #> [1] 0.0375000 -0.1060891 0.1810891 #> #> [[2]] #> [1] 0.07250000 -0.09220915 0.23720915 #> #> [[3]] #> [1] 0.0750000 -0.1231285 0.2731285 #>"},{"path":"https://insightsengineering.github.io/tern/reference/strata_normal_quantile.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"function wraps estimation stratified percentiles assume approximation large numbers. necessary case proportions strata unequal.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/strata_normal_quantile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"","code":"strata_normal_quantile(vars, weights, conf_level)"},{"path":"https://insightsengineering.github.io/tern/reference/strata_normal_quantile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"vars (character) variable names primary analysis variable iterated . weights (numeric NULL) weights level strata. NULL, estimated using iterative algorithm proposed Yan2010-jt;textualtern minimizes weighted squared length confidence interval. conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/strata_normal_quantile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"Stratified quantile.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/strata_normal_quantile.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"","code":"strata_data <- table(data.frame( \"f1\" = sample(c(TRUE, FALSE), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), stringsAsFactors = TRUE )) ns <- colSums(strata_data) ests <- strata_data[\"TRUE\", ] / ns vars <- ests * (1 - ests) / ns weights <- rep(1 / length(ns), length(ns)) strata_normal_quantile(vars, weights, 0.95) #> [1] 1.14181"},{"path":"https://insightsengineering.github.io/tern/reference/study_arm.html","id":null,"dir":"Reference","previous_headings":"","what":"Indicate study arm variable in formula — study_arm","title":"Indicate study arm variable in formula — study_arm","text":"use study_arm indicate study arm variable tern formulas.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/study_arm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Indicate study arm variable in formula — study_arm","text":"","code":"study_arm(x)"},{"path":"https://insightsengineering.github.io/tern/reference/study_arm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Indicate study arm variable in formula — study_arm","text":"x arm information","code":""},{"path":"https://insightsengineering.github.io/tern/reference/study_arm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Indicate study arm variable in formula — study_arm","text":"x","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_ancova.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"analyze function summarize_ancova() creates layout element summarize ANCOVA results. function can used analyze multiple endpoints /multiple timepoints within response variable(s) specified vars. Additional variables analysis, namely arm (grouping) variable covariate variables, can defined via variables argument. See details specify variables. interaction term can implemented model needed. interaction variable interact arm variable specified via interaction_term parameter, specific value interaction_term extract ANCOVA results via interaction_y parameter.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_ancova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"","code":"summarize_ancova( lyt, vars, variables, conf_level, interaction_y = FALSE, interaction_item = NULL, var_labels, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"visible\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_ancova( df, .var, .df_row, variables, .ref_group, .in_ref_col, conf_level, interaction_y = FALSE, interaction_item = NULL ) a_ancova( df, .var, .df_row, variables, .ref_group, .in_ref_col, conf_level, interaction_y = FALSE, interaction_item = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_ancova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". conf_level (proportion) confidence level interval. interaction_y (string flag) selected item inside interaction_item variable used select specific ANCOVA results. interaction needed, default option FALSE. interaction_item (string NULL) name variable interactions arm. interaction needed, default option NULL. var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'lsmean', 'lsmean_diff', 'lsmean_diff_ci', 'pval' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) data set includes variables called .var variables. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_ancova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"summarize_ancova() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_ancova() table layout. s_ancova() returns named list 5 statistics: n: Count complete sample size group. lsmean: Estimated marginal means group. lsmean_diff: Difference estimated marginal means comparison reference group. working reference group, empty. lsmean_diff_ci: Confidence level difference estimated marginal means comparison reference group. pval: p-value (adjusted multiple comparisons). a_ancova() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_ancova.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"summarize_ancova(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_ancova(): Statistics function produces named list results investigated linear model. a_ancova(): Formatted analysis function used afun summarize_ancova().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_ancova.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"","code":"basic_table() %>% split_cols_by(\"Species\", ref_group = \"setosa\") %>% add_colcounts() %>% summarize_ancova( vars = \"Petal.Length\", variables = list(arm = \"Species\", covariates = NULL), table_names = \"unadj\", conf_level = 0.95, var_labels = \"Unadjusted comparison\", .labels = c(lsmean = \"Mean\", lsmean_diff = \"Difference in Means\") ) %>% summarize_ancova( vars = \"Petal.Length\", variables = list(arm = \"Species\", covariates = c(\"Sepal.Length\", \"Sepal.Width\")), table_names = \"adj\", conf_level = 0.95, var_labels = \"Adjusted comparison (covariates: Sepal.Length and Sepal.Width)\" ) %>% build_table(iris) #> setosa versicolor virginica #> (N=50) (N=50) (N=50) #> ————————————————————————————————————————————————————————————————————————————————————————————————————— #> Unadjusted comparison #> n 50 50 50 #> Mean 1.46 4.26 5.55 #> Difference in Means 2.80 4.09 #> 95% CI (2.63, 2.97) (3.92, 4.26) #> p-value <0.0001 <0.0001 #> Adjusted comparison (covariates: Sepal.Length and Sepal.Width) #> n 50 50 50 #> Adjusted Mean 2.02 4.19 5.07 #> Difference in Adjusted Means 2.17 3.05 #> 95% CI (1.96, 2.38) (2.81, 3.29) #> p-value <0.0001 <0.0001"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize change from baseline values or absolute baseline values — summarize_change","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"analyze function summarize_change() creates layout element summarize change baseline absolute baseline values. primary analysis variable vars indicates numerical change baseline results. Required secondary analysis variables value baseline_flag can supplied function via variables argument. value element name analysis value variable, baseline_flag element name flag variable indicates whether records contain baseline values. Depending baseline flag given, either absolute baseline values (baseline) change baseline values (post-baseline) summarized.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"","code":"summarize_change( lyt, vars, variables, var_labels = vars, na_str = default_na_str(), na_rm = TRUE, nested = TRUE, show_labels = \"default\", table_names = vars, section_div = NA_character_, ..., .stats = c(\"n\", \"mean_sd\", \"median\", \"range\"), .formats = c(n = \"xx\", mean_sd = \"xx.xx (xx.xx)\", mean_se = \"xx.xx (xx.xx)\", median = \"xx.xx\", range = \"xx.xx - xx.xx\", mean_ci = \"(xx.xx, xx.xx)\", median_ci = \"(xx.xx, xx.xx)\", mean_pval = \"xx.xx\"), .labels = c(mean_sd = \"Mean (SD)\", mean_se = \"Mean (SE)\", median = \"Median\", range = \"Min - Max\"), .indent_mods = NULL ) s_change_from_baseline(df, ...) a_change_from_baseline( df, ..., .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. ... additional arguments lower level functions. .stats (character) statistics select table. Options : 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"summarize_change() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_change_from_baseline() table layout. s_change_from_baseline() returns values returned s_summary.numeric(). a_change_from_baseline() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"summarize_change(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_change_from_baseline(): Statistics function summarizes baseline post-baseline visits. a_change_from_baseline(): Formatted analysis function used afun summarize_change().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"used split visits layout, data subset contains either baseline post-baseline data. data df must either baseline post-baseline visits. Otherwise error thrown.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_change.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"","code":"library(dplyr) # Fabricate dataset dta_test <- data.frame( USUBJID = rep(1:6, each = 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)) ) %>% mutate(ABLFLL = AVISIT == \"V1\") %>% group_by(USUBJID) %>% mutate( BLVAL = AVAL[ABLFLL], CHG = AVAL - BLVAL ) %>% ungroup() results <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\")) %>% build_table(dta_test) results #> A B C #> ——————————————————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 () #> Median 7.50 3.00 #> Min - Max 6.00 - 9.00 3.00 - 3.00 #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 () #> Median -1.00 -1.00 #> Min - Max -1.00 - -1.00 -1.00 - -1.00 #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 () #> Median -2.00 -2.00 #> Min - Max -2.00 - -2.00 -2.00 - -2.00 "},{"path":"https://insightsengineering.github.io/tern/reference/summarize_colvars.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize variables in columns — summarize_colvars","title":"Summarize variables in columns — summarize_colvars","text":"analyze function summarize_colvars() uses statistics function s_summary() analyze variables arranged columns. variables analyze specified table layout via column splits (see rtables::split_cols_by() rtables::split_cols_by_multivar()) prior using summarize_colvars(). function minimal wrapper rtables::analyze_colvars(), function typically used apply different analysis methods rows column variable. use analysis methods column labels, please refer analyze_vars_in_cols() function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_colvars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize variables in columns — summarize_colvars","text":"","code":"summarize_colvars( lyt, ..., na_str = default_na_str(), .stats = c(\"n\", \"mean_sd\", \"median\", \"range\", \"count_fraction\"), .formats = NULL, .labels = NULL, .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_colvars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize variables in columns — summarize_colvars","text":"lyt (PreDataTableLayouts) layout analyses added . ... arguments passed s_summary(). na_str (string) string used replace NA empty values output. .stats (character) statistics select table. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named vector integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_colvars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize variables in columns — summarize_colvars","text":"layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout summarize given variables, arrange output columns, add table layout.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/summarize_colvars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize variables in columns — summarize_colvars","text":"","code":"dta_test <- data.frame( USUBJID = rep(1:6, each = 3), PARAMCD = rep(\"lab\", 6 * 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)), CHG = c(1:9, rep(NA, 9)) ) ## Default output within a `rtables` pipeline. basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% split_cols_by_multivar(vars = c(\"AVAL\", \"CHG\")) %>% summarize_colvars() %>% build_table(dta_test) #> A B C #> AVAL CHG AVAL CHG AVAL CHG #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> V1 #> n 2 2 1 1 0 0 #> Mean (SD) 7.5 (2.1) 2.5 (2.1) 3.0 () 7.0 () #> Median 7.5 2.5 3.0 7.0 #> Min - Max 6.0 - 9.0 1.0 - 4.0 3.0 - 3.0 7.0 - 7.0 #> V2 #> n 2 2 1 1 0 0 #> Mean (SD) 6.5 (2.1) 3.5 (2.1) 2.0 () 8.0 () #> Median 6.5 3.5 2.0 8.0 #> Min - Max 5.0 - 8.0 2.0 - 5.0 2.0 - 2.0 8.0 - 8.0 #> V3 #> n 2 2 1 1 0 0 #> Mean (SD) 5.5 (2.1) 4.5 (2.1) 1.0 () 9.0 () #> Median 5.5 4.5 1.0 9.0 #> Min - Max 4.0 - 7.0 3.0 - 6.0 1.0 - 1.0 9.0 - 9.0 ## Selection of statistics, formats and labels also work. basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% split_cols_by_multivar(vars = c(\"AVAL\", \"CHG\")) %>% summarize_colvars( .stats = c(\"n\", \"mean_sd\"), .formats = c(\"mean_sd\" = \"xx.x, xx.x\"), .labels = c(n = \"n\", mean_sd = \"Mean, SD\") ) %>% build_table(dta_test) #> A B C #> AVAL CHG AVAL CHG AVAL CHG #> —————————————————————————————————————————————————————————————————————————————————————————— #> V1 #> n 2 2 1 1 0 0 #> Mean, SD 7.5, 2.1 2.5, 2.1 3.0, 7.0, #> V2 #> n 2 2 1 1 0 0 #> Mean, SD 6.5, 2.1 3.5, 2.1 2.0, 8.0, #> V3 #> n 2 2 1 1 0 0 #> Mean, SD 5.5, 2.1 4.5, 2.1 1.0, 9.0, ## Use arguments interpreted by `s_summary`. basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% split_cols_by_multivar(vars = c(\"AVAL\", \"CHG\")) %>% summarize_colvars(na.rm = FALSE) %>% build_table(dta_test) #> A B C #> AVAL CHG AVAL CHG AVAL CHG #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> V1 #> n 2 2 1 1 0 0 #> Mean (SD) 7.5 (2.1) 2.5 (2.1) 3.0 () 7.0 () #> Median 7.5 2.5 3.0 7.0 #> Min - Max 6.0 - 9.0 1.0 - 4.0 3.0 - 3.0 7.0 - 7.0 #> V2 #> n 2 2 1 1 0 0 #> Mean (SD) 6.5 (2.1) 3.5 (2.1) 2.0 () 8.0 () #> Median 6.5 3.5 2.0 8.0 #> Min - Max 5.0 - 8.0 2.0 - 5.0 2.0 - 2.0 8.0 - 8.0 #> V3 #> n 2 2 1 1 0 0 #> Mean (SD) 5.5 (2.1) 4.5 (2.1) 1.0 () 9.0 () #> Median 5.5 4.5 1.0 9.0 #> Min - Max 4.0 - 7.0 3.0 - 6.0 1.0 - 1.0 9.0 - 9.0 "},{"path":"https://insightsengineering.github.io/tern/reference/summarize_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize functions — summarize_functions","title":"Summarize functions — summarize_functions","text":"functions wrappers rtables::summarize_row_groups(), applying corresponding tern content functions add summary rows given table layout:","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_functions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize functions — summarize_functions","text":"add_rowcounts() estimate_multinomial_response() (rtables::analyze()) h_tab_one_biomarker() (probably deprecate) logistic_summary_by_flag() summarize_num_patients() summarize_occurrences() summarize_occurrences_by_grade() summarize_patients_events_in_cols() summarize_patients_exposure_in_cols() Additionally, summarize_coxreg() function utilizes rtables::summarize_row_groups() (combination several rtables functions like rtables::analyze_colvars()) output Cox regression summary table.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize Poisson negative binomial regression — summarize_glm_count","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"Summarize results Poisson negative binomial regression. can used analyze count /frequency data using linear model. specifically useful analyzing count data (using Poisson Negative Binomial distribution) result generalized linear model one (e.g. arm) covariates.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"","code":"summarize_glm_count( lyt, vars, variables, distribution, conf_level, rate_mean_method = c(\"emmeans\", \"ppmeans\")[1], weights = stats::weights, scale = 1, var_labels, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"visible\", table_names = vars, .stats = get_stats(\"summarize_glm_count\"), .formats = NULL, .labels = NULL, .indent_mods = c(n = 0L, rate = 0L, rate_ci = 1L, rate_ratio = 0L, rate_ratio_ci = 1L, pval = 1L) ) s_glm_count( df, .var, .df_row, variables, .ref_group, .in_ref_col, distribution, conf_level, rate_mean_method, weights, scale = 1 )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". offset (numeric) numeric vector scalar adding offset. distribution (character) character value specifying distribution used regression (Poisson, Quasi-Poisson, negative binomial). conf_level (proportion) confidence level interval. rate_mean_method (character(1)) method used estimate mean odds ratio. Defaults emmeans. see details information. weights (character) character vector specifying weights used averaging predictions. Number weights must equal number levels included covariates. Weights option passed emmeans::emmeans(). scale (numeric(1)) linear scaling factor rate confidence intervals. Defaults 1. var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'rate', 'rate_ci', 'rate_ratio', 'rate_ratio_ci', 'pval' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) dataset includes variables called .var variables. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"summarize_glm_count() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_glm_count() table layout. s_glm_count() returns named list 5 statistics: n: Count complete sample size group. rate: Estimated event rate per follow-time. rate_ci: Confidence level estimated rate per follow-time. rate_ratio: Ratio event rates treatment arm reference arm. rate_ratio_ci: Confidence level rate ratio. pval: p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"summarize_glm_count() uses s_glm_count() calculate statistics table. analysis function uses h_glm_count() estimate GLM stats::glm() Poisson Quasi-Poisson distributions MASS::glm.nb() Negative Binomial distribution. methods assume logarithmic link function. point, rates confidence intervals estimated model using either emmeans::emmeans() rate_mean_method = \"emmeans\" h_ppmeans() rate_mean_method = \"ppmeans\". reference group specified building table split_cols_by(ref_group), rate ratio p-value calculated. Otherwise, use emmeans::contrast() calculate rate ratio p-value reference group. Values always estimated method = \"trt.vs.ctrl\" ref equal first arm value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"summarize_glm_count(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_glm_count(): Statistics function produces named list results investigated Poisson model.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_glm_count.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"","code":"library(dplyr) anl <- tern_ex_adtte %>% filter(PARAMCD == \"TNE\") anl$AVAL_f <- as.factor(anl$AVAL) lyt <- basic_table() %>% split_cols_by(\"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% analyze_vars( \"AVAL_f\", var_labels = \"Number of exacerbations per patient\", .stats = c(\"count_fraction\"), .formats = c(\"count_fraction\" = \"xx (xx.xx%)\"), .labels = c(\"Number of exacerbations per patient\") ) %>% summarize_glm_count( vars = \"AVAL\", variables = list(arm = \"ARM\", offset = \"lgTMATRSK\", covariates = NULL), conf_level = 0.95, distribution = \"poisson\", rate_mean_method = \"emmeans\", var_labels = \"Adjusted (P) exacerbation rate (per year)\", table_names = \"adjP\", .stats = c(\"rate\"), .labels = c(rate = \"Rate\") ) %>% summarize_glm_count( vars = \"AVAL\", variables = list(arm = \"ARM\", offset = \"lgTMATRSK\", covariates = c(\"REGION1\")), conf_level = 0.95, distribution = \"quasipoisson\", rate_mean_method = \"ppmeans\", var_labels = \"Adjusted (QP) exacerbation rate (per year)\", table_names = \"adjQP\", .stats = c(\"rate\", \"rate_ci\", \"rate_ratio\", \"rate_ratio_ci\", \"pval\"), .labels = c( rate = \"Rate\", rate_ci = \"Rate CI\", rate_ratio = \"Rate Ratio\", rate_ratio_ci = \"Rate Ratio CI\", pval = \"p value\" ) ) build_table(lyt = lyt, df = anl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————————————————————————— #> Number of exacerbations per patient #> 0 3 (4.35%) 8 (10.96%) 6 (10.34%) #> 1 11 (15.94%) 9 (12.33%) 6 (10.34%) #> 2 18 (26.09%) 15 (20.55%) 9 (15.52%) #> 3 14 (20.29%) 11 (15.07%) 15 (25.86%) #> 4 10 (14.49%) 9 (12.33%) 9 (15.52%) #> 5 7 (10.14%) 9 (12.33%) 8 (13.79%) #> 6 4 (5.80%) 4 (5.48%) 4 (6.90%) #> 7 2 (2.90%) 8 (10.96%) 0 (0.00%) #> 10 0 (0.00%) 0 (0.00%) 1 (1.72%) #> Adjusted (P) exacerbation rate (per year) #> Rate 8.2061 9.1554 7.8551 #> Adjusted (QP) exacerbation rate (per year) #> Rate 3.1214 3.4860 2.6152 #> Rate CI (1.7307, 5.6294) (1.9833, 6.1272) (1.3661, 5.0065) #> Rate Ratio 0.8954 0.7502 #> Rate Ratio CI (0.3975, 2.0170) (0.3067, 1.8348) #> p value 0.7897 0.5288"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_logistic.html","id":null,"dir":"Reference","previous_headings":"","what":"Multivariate logistic regression table — summarize_logistic","title":"Multivariate logistic regression table — summarize_logistic","text":"Layout-creating function summarizes logistic variable regression binary outcome categorical/continuous covariates model statement. covariate category (categorical) specified values (continuous), present degrees freedom, regression parameter estimate standard error (SE) relative reference group category. Report odds ratios covariate category specified values corresponding Wald confidence intervals default allow user specify confidence levels. Report p-value Wald chi-square test null hypothesis covariate effect response model containing specified covariates. Allow option include one two-way interaction present similar output interaction degree freedom.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_logistic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multivariate logistic regression table — summarize_logistic","text":"","code":"summarize_logistic( lyt, conf_level, drop_and_remove_str = \"\", .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_logistic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multivariate logistic regression table — summarize_logistic","text":"lyt (PreDataTableLayouts) layout analyses added . conf_level (proportion) confidence level interval. drop_and_remove_str (string) string dropped removed. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_logistic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multivariate logistic regression table — summarize_logistic","text":"layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add logistic regression variable summary table layout.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_logistic.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Multivariate logistic regression table — summarize_logistic","text":"formula, variable names need standard data.frame column names without special characters.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_logistic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multivariate logistic regression table — summarize_logistic","text":"","code":"library(dplyr) library(broom) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred df <- tidy(mod1, conf_level = 0.99) df2 <- tidy(mod2, conf_level = 0.99) # flagging empty strings with \"_\" df <- df_explicit_na(df, na_level = \"_\") df2 <- df_explicit_na(df2, na_level = \"_\") result1 <- basic_table() %>% summarize_logistic( conf_level = 0.95, drop_and_remove_str = \"_\" ) %>% build_table(df = df) result1 #> Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Planned Arm Code 2 0.3004 #> Reference ARM A, n = 64 #> ARM B, n = 68 1 -1.775 1.144 0.17 (<0.01, 3.23) 0.1209 #> ARM C, n = 52 1 17.192 3626.588 >999.99 (0.00, >999.99) 0.9962 #> Age #> Age 1 0.170 0.095 1.19 (0.93, 1.51) 0.0746 #> Race 2 0.7967 #> Reference ASIAN, n = 110 #> BLACK OR AFRICAN AMERICAN, n = 40 1 17.923 4001.705 >999.99 (0.00, >999.99) 0.9964 #> WHITE, n = 34 1 -0.656 0.974 0.52 (0.04, 6.37) 0.5002 result2 <- basic_table() %>% summarize_logistic( conf_level = 0.95, drop_and_remove_str = \"_\" ) %>% build_table(df = df2) result2 #> Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Race 2 0.9361 #> Reference ASIAN, n = 110 #> BLACK OR AFRICAN AMERICAN, n = 40 1 18.150 3944.701 >999.99 (0.00, >999.99) 0.9963 #> WHITE, n = 34 1 -0.373 1.026 0.69 (0.05, 9.68) 0.7164 #> Planned Arm Code 2 0.2539 #> Reference ARM A, n = 64 #> ARM B, n = 68 1 -11.527 6.962 0.0978 #> Age #> 35 0.48 (0.01, 15.48) #> ARM C, n = 52 1 16.333 20278.387 0.9994 #> Age #> 35 >999.99 (0.00, >999.99) #> Age #> Age 1 -0.039 0.151 0.7981 #> Planned Arm Code #> ARM A 0.96 (0.65, 1.42) #> ARM B 1.31 (0.92, 1.86) #> ARM C 0.99 (0.00, >999.99) #> Interaction of Planned Arm Code * Age 2 0.3276 #> Reference ARM A, n = 64 #> ARM B, n = 68 1 0.308 0.206 0.1352 #> ARM C, n = 52 1 0.029 548.592 1.0000"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":null,"dir":"Reference","previous_headings":"","what":"Count number of patients — summarize_num_patients","title":"Count number of patients — summarize_num_patients","text":"analyze function analyze_num_patients() creates layout element count total numbers unique non-unique patients. primary analysis variable vars used uniquely identify patients. count_by variable can used identify non-unique patients number patients unique combination values vars count_by returned instead nonunique statistic. required variable can used specify variable required non-missing record included counts. summarize function summarize_num_patients() performs function analyze_num_patients() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count number of patients — summarize_num_patients","text":"","code":"analyze_num_patients( lyt, vars, required = NULL, count_by = NULL, unique_count_suffix = TRUE, na_str = default_na_str(), nested = TRUE, .stats = NULL, .formats = NULL, .labels = c(unique = \"Number of patients with at least one event\", nonunique = \"Number of events\"), show_labels = c(\"default\", \"visible\", \"hidden\"), .indent_mods = 0L, riskdiff = FALSE, ... ) summarize_num_patients( lyt, var, required = NULL, count_by = NULL, unique_count_suffix = TRUE, na_str = default_na_str(), .stats = NULL, .formats = NULL, .labels = c(unique = \"Number of patients with at least one event\", nonunique = \"Number of events\"), .indent_mods = 0L, riskdiff = FALSE, ... ) s_num_patients( x, labelstr, .N_col, count_by = NULL, unique_count_suffix = TRUE ) s_num_patients_content( df, labelstr = \"\", .N_col, .var, required = NULL, count_by = NULL, unique_count_suffix = TRUE )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count number of patients — summarize_num_patients","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . required (character NULL) name variable required non-missing. count_by (character NULL) name variable combined vars counting nonunique records. unique_count_suffix (flag) whether \"(n)\" suffix added unique_count labels. Defaults TRUE. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. .stats (character) statistics select table. Options : 'unique', 'nonunique', 'unique_count' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. ... additional arguments lower level functions. x (character factor) vector patient IDs. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count number of patients — summarize_num_patients","text":"analyze_num_patients() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_num_patients_content() table layout. summarize_num_patients() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_num_patients_content() table layout. s_num_patients() returns named list 3 statistics: unique: Vector counts percentages. nonunique: Vector counts. unique_count: Counts. s_num_patients_content() returns values s_num_patients().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Count number of patients — summarize_num_patients","text":"general, functions starts analyze* expected work like rtables::analyze(), functions starts summarize* based upon rtables::summarize_row_groups(). latter provides value dividing split row column space, , bound fundamental splits, repeated design every page pagination involved.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count number of patients — summarize_num_patients","text":"analyze_num_patients(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). summarize_num_patients(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_num_patients(): Statistics function counts number unique patients, corresponding percentage taken respect total number patients, number non-unique patients. s_num_patients_content(): Statistics function counts number unique patients column (variable), corresponding percentage taken respect total number patients, number non-unique patients column.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count number of patients — summarize_num_patients","text":"opposed summarize_num_patients(), function repeat produced rows.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_num_patients.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count number of patients — summarize_num_patients","text":"","code":"df <- data.frame( USUBJID = as.character(c(1, 2, 1, 4, NA, 6, 6, 8, 9)), ARM = c(\"A\", \"A\", \"A\", \"A\", \"A\", \"B\", \"B\", \"B\", \"B\"), AGE = c(10, 15, 10, 17, 8, 11, 11, 19, 17), SEX = c(\"M\", \"M\", \"M\", \"F\", \"F\", \"F\", \"M\", \"F\", \"M\") ) # analyze_num_patients tbl <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% analyze_num_patients(\"USUBJID\", .stats = c(\"unique\")) %>% build_table(df) tbl #> A B #> (N=5) (N=4) #> —————————————————————————————————————————————————————————————————— #> Number of patients with at least one event 3 (60.0%) 3 (75.0%) # summarize_num_patients tbl <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"SEX\") %>% summarize_num_patients(\"USUBJID\", .stats = \"unique_count\") %>% build_table(df) tbl #> A B #> ————————————— #> M (n) 2 2 #> F (n) 1 2 # Use the statistics function to count number of unique and nonunique patients. s_num_patients(x = as.character(c(1, 1, 1, 2, 4, NA)), labelstr = \"\", .N_col = 6L) #> $unique #> [1] 3.0 0.5 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 5 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #> s_num_patients( x = as.character(c(1, 1, 1, 2, 4, NA)), labelstr = \"\", .N_col = 6L, count_by = c(1, 1, 2, 1, 1, 1) ) #> $unique #> [1] 3.0 0.5 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 4 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #> # Count number of unique and non-unique patients. df <- data.frame( USUBJID = as.character(c(1, 2, 1, 4, NA)), EVENT = as.character(c(10, 15, 10, 17, 8)) ) s_num_patients_content(df, .N_col = 5, .var = \"USUBJID\") #> $unique #> [1] 3.0 0.6 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 4 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #> df_by_event <- data.frame( USUBJID = as.character(c(1, 2, 1, 4, NA)), EVENT = c(10, 15, 10, 17, 8) ) s_num_patients_content(df_by_event, .N_col = 5, .var = \"USUBJID\", count_by = \"EVENT\") #> $unique #> [1] 3.0 0.6 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 3 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #>"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"analyze function analyze_patients_exposure_in_cols() creates layout element count total numbers patients sum analysis value (.e. exposure) across patients columns. primary analysis variable ex_var exposure variable used calculate sum_exposure statistic. id variable used uniquely identify patients data unique patients counted n_patients statistic, var variable used create row split needed. percentage returned part n_patients statistic proportion records correspond unique patient. summarize function summarize_patients_exposure_in_cols() performs function analyze_patients_exposure_in_cols() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred. column split yet performed table, col_split must set TRUE first call analyze_patients_exposure_in_cols() summarize_patients_exposure_in_cols().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"","code":"analyze_patients_exposure_in_cols( lyt, var = NULL, ex_var = \"AVAL\", id = \"USUBJID\", add_total_level = FALSE, custom_label = NULL, col_split = TRUE, na_str = default_na_str(), .stats = c(\"n_patients\", \"sum_exposure\"), .labels = c(n_patients = \"Patients\", sum_exposure = \"Person time\"), .indent_mods = 0L, ... ) summarize_patients_exposure_in_cols( lyt, var, ex_var = \"AVAL\", id = \"USUBJID\", add_total_level = FALSE, custom_label = NULL, col_split = TRUE, na_str = default_na_str(), ..., .stats = c(\"n_patients\", \"sum_exposure\"), .labels = c(n_patients = \"Patients\", sum_exposure = \"Person time\"), .indent_mods = NULL ) s_count_patients_sum_exposure( df, ex_var = \"AVAL\", id = \"USUBJID\", labelstr = \"\", .stats = c(\"n_patients\", \"sum_exposure\"), .N_col, custom_label = NULL ) a_count_patients_sum_exposure( df, var = NULL, ex_var = \"AVAL\", id = \"USUBJID\", add_total_level = FALSE, custom_label = NULL, labelstr = \"\", .N_col, .stats, .formats = list(n_patients = \"xx (xx.x%)\", sum_exposure = \"xx\") )"},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. ex_var (string) name variable df containing exposure values. id (string) subject variable name. add_total_level (flag) adds \"total\" level others includes levels constitute split. custom label can set level via custom_label argument. custom_label (string NULL) provided labelstr empty, used label. col_split (flag) whether columns split. Set FALSE required column split done already earlier layout pipe. na_str (string) string used replace NA empty values output. .stats (character) statistics select table. Options : 'n_patients', 'sum_exposure' .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. ... additional arguments lower level functions. df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"analyze_patients_exposure_in_cols() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted data rows, statistics s_count_patients_sum_exposure() arranged columns, table layout. summarize_patients_exposure_in_cols() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows, statistics s_count_patients_sum_exposure() arranged columns, table layout. s_count_patients_sum_exposure() returns named list statistics: n_patients: Number unique patients df. sum_exposure: Sum ex_var across patients df. a_count_patients_sum_exposure() returns formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"analyze_patients_exposure_in_cols(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::split_cols_by_multivar() rtables::analyze_colvars(). summarize_patients_exposure_in_cols(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::split_cols_by_multivar() rtables::summarize_row_groups(). s_count_patients_sum_exposure(): Statistics function counts numbers patients sum exposure across patients. a_count_patients_sum_exposure(): Analysis function used afun rtables::analyze_colvars() within analyze_patients_exposure_in_cols() cfun rtables::summarize_row_groups() within summarize_patients_exposure_in_cols().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"opposed summarize_patients_exposure_in_cols() generates content rows, analyze_patients_exposure_in_cols() generates data rows repeated multiple pages pagination used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/summarize_patients_exposure_in_cols.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"","code":"set.seed(1) df <- data.frame( USUBJID = c(paste(\"id\", seq(1, 12), sep = \"\")), ARMCD = c(rep(\"ARM A\", 6), rep(\"ARM B\", 6)), SEX = c(rep(\"Female\", 6), rep(\"Male\", 6)), AVAL = as.numeric(sample(seq(1, 20), 12)), stringsAsFactors = TRUE ) adsl <- data.frame( USUBJID = c(paste(\"id\", seq(1, 12), sep = \"\")), ARMCD = c(rep(\"ARM A\", 2), rep(\"ARM B\", 2)), SEX = c(rep(\"Female\", 2), rep(\"Male\", 2)), stringsAsFactors = TRUE ) lyt <- basic_table() %>% split_cols_by(\"ARMCD\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>% summarize_patients_exposure_in_cols(var = \"AVAL\", col_split = TRUE) %>% analyze_patients_exposure_in_cols(var = \"SEX\", col_split = FALSE) result <- build_table(lyt, df = df, alt_counts_df = adsl) result #> ARM A ARM B Total #> Patients Person time Patients Person time Patients Person time #> ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total patients numbers/person time 6 (100.0%) 46 6 (100.0%) 68 12 (100.0%) 114 #> Female 6 (100.0%) 46 0 (0.0%) 0 6 (50.0%) 46 #> Male 0 (0.0%) 0 6 (100.0%) 68 6 (50.0%) 68 lyt2 <- basic_table() %>% split_cols_by(\"ARMCD\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>% summarize_patients_exposure_in_cols( var = \"AVAL\", col_split = TRUE, .stats = \"n_patients\", custom_label = \"some custom label\" ) %>% analyze_patients_exposure_in_cols(var = \"SEX\", col_split = FALSE, ex_var = \"AVAL\") result2 <- build_table(lyt2, df = df, alt_counts_df = adsl) result2 #> ARM A ARM B Total #> Patients Patients Patients #> ————————————————————————————————————————————————————————— #> some custom label 6 (100.0%) 6 (100.0%) 12 (100.0%) #> Female 6 (100.0%) 0 (0.0%) 6 (50.0%) #> Male 0 (0.0%) 6 (100.0%) 6 (50.0%) lyt3 <- basic_table() %>% analyze_patients_exposure_in_cols(var = \"SEX\", col_split = TRUE, ex_var = \"AVAL\") result3 <- build_table(lyt3, df = df, alt_counts_df = adsl) result3 #> Patients Person time #> ———————————————————————————————— #> Female 6 (50.0%) 46 #> Male 6 (50.0%) 68 # Adding total levels and custom label lyt4 <- basic_table( show_colcounts = TRUE ) %>% analyze_patients_exposure_in_cols( var = \"ARMCD\", col_split = TRUE, add_total_level = TRUE, custom_label = \"TOTAL\" ) %>% append_topleft(c(\"\", \"Sex\")) result4 <- build_table(lyt4, df = df, alt_counts_df = adsl) result4 #> Patients Person time #> Sex (N=12) (N=12) #> ————————————————————————————————— #> ARM A 6 (50.0%) 46 #> ARM B 6 (50.0%) 68 #> TOTAL 12 (100.0%) 114 lyt5 <- basic_table() %>% summarize_patients_exposure_in_cols(var = \"AVAL\", col_split = TRUE) result5 <- build_table(lyt5, df = df, alt_counts_df = adsl) result5 #> Patients Person time #> —————————————————————————————————————————————————————————————— #> Total patients numbers/person time 12 (100.0%) 114 lyt6 <- basic_table() %>% summarize_patients_exposure_in_cols(var = \"AVAL\", col_split = TRUE, .stats = \"sum_exposure\") result6 <- build_table(lyt6, df = df, alt_counts_df = adsl) result6 #> Person time #> ———————————————————————————————————————————————— #> Total patients numbers/person time 114 a_count_patients_sum_exposure( df = df, var = \"SEX\", .N_col = nrow(df), .stats = \"n_patients\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Female 6 (50.0%) 0 Female #> 2 Male 6 (50.0%) 0 Male"},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"tabulate_survival_biomarkers() function creates layout element tabulate estimated effects multiple continuous biomarker variables survival across subgroups, returning statistics including median survival time hazard ratio population subgroup. table created df, list data frames returned extract_survival_biomarkers(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"","code":"tabulate_survival_biomarkers( df, vars = c(\"n_tot\", \"n_tot_events\", \"median\", \"hr\", \"ci\", \"pval\"), groups_lists = list(), control = control_coxreg(), label_all = lifecycle::deprecated(), time_unit = NULL, na_str = default_na_str(), .indent_mods = 0L )"},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"df (data.frame) containing analysis variables, returned extract_survival_biomarkers(). vars (character) names statistics reported among: n_tot_events: Total number events per group. n_tot: Total number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (list) list parameters returned helper function control_coxreg(). label_all please assign label_all parameter within extract_survival_biomarkers() function creating df. time_unit (string) label unit median survival time. Default NULL skips displaying unit. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"rtables table summarizing biomarker effects survival subgroup.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"functions create layout starting data frame contains required statistics. tables typically used input forest plots.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"tabulate_survival_biomarkers(): Table-creating function creates table summarizing biomarker effects survival subgroup.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"contrast tabulate_survival_subgroups() tabulation function start input layout lyt. internally table created combining multiple subtables.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/survival_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"","code":"library(dplyr) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) adtte_f <- adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- c(\"AVALU\" = adtte_labels[[\"AVALU\"]], \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels # Typical analysis of two continuous biomarkers `BMRKR1` and `AGE`, # in multiple regression models containing one covariate `RACE`, # as well as one stratification variable `STRATA1`. The subgroups # are defined by the levels of `BMRKR2`. df <- extract_survival_biomarkers( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), strata = \"STRATA1\", covariates = \"SEX\", subgroups = \"BMRKR2\" ), label_all = \"Total Patients\", data = adtte_f ) df #> biomarker biomarker_label n_tot n_tot_events median hr #> 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.0010939 #> 2 AGE Age 200 141 753.5176 1.0106406 #> 3 BMRKR1 Continuous Level Biomarker 1 70 52 735.4722 0.9905065 #> 4 AGE Age 70 52 735.4722 1.0106279 #> 5 BMRKR1 Continuous Level Biomarker 1 68 42 858.9952 0.9623210 #> 6 AGE Age 68 42 858.9952 1.0360765 #> 7 BMRKR1 Continuous Level Biomarker 1 62 47 727.8043 1.0770946 #> 8 AGE Age 62 47 727.8043 1.0009890 #> lcl ucl conf_level pval pval_label subgroup var #> 1 0.9538978 1.050625 0.95 0.9646086 p-value (Wald) Total Patients ALL #> 2 0.9871004 1.034742 0.95 0.3787395 p-value (Wald) Total Patients ALL #> 3 0.9142220 1.073156 0.95 0.8155443 p-value (Wald) LOW BMRKR2 #> 4 0.9621192 1.061582 0.95 0.6735773 p-value (Wald) LOW BMRKR2 #> 5 0.8708694 1.063376 0.95 0.4509368 p-value (Wald) MEDIUM BMRKR2 #> 6 0.9727439 1.103532 0.95 0.2707796 p-value (Wald) MEDIUM BMRKR2 #> 7 0.9756250 1.189118 0.95 0.1412524 p-value (Wald) HIGH BMRKR2 #> 8 0.9678535 1.035259 0.95 0.9541048 p-value (Wald) HIGH BMRKR2 #> var_label row_type #> 1 Total Patients content #> 2 Total Patients content #> 3 Continuous Level Biomarker 2 analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis # Here we group the levels of `BMRKR2` manually. df_grouped <- extract_survival_biomarkers( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), strata = \"STRATA1\", covariates = \"SEX\", subgroups = \"BMRKR2\" ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) df_grouped #> biomarker biomarker_label n_tot n_tot_events median hr #> 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.0010939 #> 2 AGE Age 200 141 753.5176 1.0106406 #> 3 BMRKR1 Continuous Level Biomarker 1 70 52 735.4722 0.9905065 #> 4 AGE Age 70 52 735.4722 1.0106279 #> 5 BMRKR1 Continuous Level Biomarker 1 138 94 777.8929 0.9801709 #> 6 AGE Age 138 94 777.8929 1.0236283 #> 7 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.0010939 #> 8 AGE Age 200 141 753.5176 1.0106406 #> lcl ucl conf_level pval pval_label subgroup var #> 1 0.9538978 1.050625 0.95 0.9646086 p-value (Wald) All Patients ALL #> 2 0.9871004 1.034742 0.95 0.3787395 p-value (Wald) All Patients ALL #> 3 0.9142220 1.073156 0.95 0.8155443 p-value (Wald) low BMRKR2 #> 4 0.9621192 1.061582 0.95 0.6735773 p-value (Wald) low BMRKR2 #> 5 0.9235465 1.040267 0.95 0.5094582 p-value (Wald) low/medium BMRKR2 #> 6 0.9859367 1.062761 0.95 0.2224475 p-value (Wald) low/medium BMRKR2 #> 7 0.9538978 1.050625 0.95 0.9646086 p-value (Wald) low/medium/high BMRKR2 #> 8 0.9871004 1.034742 0.95 0.3787395 p-value (Wald) low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Continuous Level Biomarker 2 analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis ## Table with default columns. tabulate_survival_biomarkers(df) #> Total n Total Events Median Hazard Ratio 95% Wald CI p-value (Wald) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Age #> Total Patients 200 141 753.5 1.01 (0.99, 1.03) 0.3787 #> Continuous Level Biomarker 2 #> LOW 70 52 735.5 1.01 (0.96, 1.06) 0.6736 #> MEDIUM 68 42 859.0 1.04 (0.97, 1.10) 0.2708 #> HIGH 62 47 727.8 1.00 (0.97, 1.04) 0.9541 #> Continuous Level Biomarker 1 #> Total Patients 200 141 753.5 1.00 (0.95, 1.05) 0.9646 #> Continuous Level Biomarker 2 #> LOW 70 52 735.5 0.99 (0.91, 1.07) 0.8155 #> MEDIUM 68 42 859.0 0.96 (0.87, 1.06) 0.4509 #> HIGH 62 47 727.8 1.08 (0.98, 1.19) 0.1413 ## Table with a manually chosen set of columns: leave out \"pval\", reorder. tab <- tabulate_survival_biomarkers( df = df, vars = c(\"n_tot_events\", \"ci\", \"n_tot\", \"median\", \"hr\"), time_unit = as.character(adtte_f$AVALU[1]) ) ## Finally produce the forest plot. # \\donttest{ g_forest(tab, xlim = c(0.8, 1.2)) # }"},{"path":"https://insightsengineering.github.io/tern/reference/survival_coxph_pairwise.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"analyze function coxph_pairwise() creates layout element analyze pairwise Cox-PH model. function can return statistics including p-value, hazard ratio (HR), HR confidence intervals stratified unstratified Cox-PH models. variable(s) analyzed specified via vars argument stratification factors via strata argument.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_coxph_pairwise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"","code":"coxph_pairwise( lyt, vars, strata = NULL, control = control_coxph(), na_str = default_na_str(), nested = TRUE, ..., var_labels = \"CoxPH\", show_labels = \"visible\", table_names = vars, .stats = c(\"pvalue\", \"hr\", \"hr_ci\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_coxph_pairwise( df, .ref_group, .in_ref_col, .var, is_event, strata = NULL, strat = lifecycle::deprecated(), control = control_coxph() ) a_coxph_pairwise( df, .ref_group, .in_ref_col, .var, is_event, strata = NULL, strat = lifecycle::deprecated(), control = control_coxph() )"},{"path":"https://insightsengineering.github.io/tern/reference/survival_coxph_pairwise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . strata (character NULL) variable names indicating stratification factors. control (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing null hypothesis hazard ratio = 1. Default method \"log-rank\" comes survival::survdiff(), can also set \"wald\" \"likelihood\" (survival::coxph()). ties (string) specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval HR. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'pvalue', 'hr', 'hr_ci', 'n_tot', 'n_tot_events' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. .var (string) single variable name passed rtables requested statistics function. is_event (flag)TRUE event, FALSE time event censored. strat Please use strata argument instead.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_coxph_pairwise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"coxph_pairwise() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_coxph_pairwise() table layout. s_coxph_pairwise() returns statistics: pvalue: p-value test null hypothesis hazard ratio = 1. hr: Hazard ratio. hr_ci: Confidence interval hazard ratio. n_tot: Total number observations. n_tot_events: Total number events. a_coxph_pairwise() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_coxph_pairwise.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"coxph_pairwise(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_coxph_pairwise(): Statistics function analyzes HR, CIs HR, p-value Cox-PH model. a_coxph_pairwise(): Formatted analysis function used afun coxph_pairwise().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_coxph_pairwise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"","code":"library(dplyr) adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) df <- adtte_f %>% filter(ARMCD == \"ARM A\") df_ref_group <- adtte_f %>% filter(ARMCD == \"ARM B\") basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% coxph_pairwise( vars = \"AVAL\", is_event = \"is_event\", var_labels = \"Unstratified Analysis\" ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ———————————————————————————————————————————————————————————— #> Unstratified Analysis #> p-value (log-rank) 0.0905 0.0086 #> Hazard Ratio 1.41 1.81 #> 95% CI (0.95, 2.09) (1.16, 2.84) basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% coxph_pairwise( vars = \"AVAL\", is_event = \"is_event\", var_labels = \"Stratified Analysis\", strata = \"SEX\", control = control_coxph(pval_method = \"wald\") ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————————————— #> Stratified Analysis #> p-value (wald) 0.0784 0.0066 #> Hazard Ratio 1.44 1.89 #> 95% CI (0.96, 2.15) (1.19, 2.98)"},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate survival duration by subgroup — survival_duration_subgroups","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"tabulate_survival_subgroups() function creates layout element tabulate survival duration subgroup, returning statistics including median survival time hazard ratio population subgroup. table created df, list data frames returned extract_survival_subgroups(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"","code":"tabulate_survival_subgroups( lyt, df, vars = c(\"n_tot_events\", \"n_events\", \"median\", \"hr\", \"ci\"), groups_lists = list(), label_all = lifecycle::deprecated(), time_unit = NULL, riskdiff = NULL, na_str = default_na_str(), .formats = c(n = \"xx\", n_events = \"xx\", n_tot_events = \"xx\", median = \"xx.x\", n_tot = \"xx\", hr = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\") ) a_survival_subgroups( .formats = list(n = \"xx\", n_events = \"xx\", n_tot_events = \"xx\", median = \"xx.x\", n_tot = \"xx\", hr = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\"), na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"lyt (PreDataTableLayouts) layout analyses added . df (list) list data frames containing analysis variables. List created using extract_survival_subgroups(). vars (character) names statistics reported among: n_tot_events: Total number events per group. n_events: Number events per group. n_tot: Total number observations per group. n: Number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all please assign label_all parameter within extract_survival_subgroups() function creating df. time_unit (string) label unit median survival time. Default NULL skips displaying unit. riskdiff (list) risk (proportion) difference column added, list settings apply within column. See control_riskdiff() details. NULL, risk difference column added. riskdiff$arm_x riskdiff$arm_y NULL, first level df$survtime$arm used arm_x second level arm_y. na_str (string) string used replace NA empty values output. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"rtables table summarizing survival subgroup. a_survival_subgroups() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"functions create layout starting data frame contains required statistics. Tables typically used part forest plot.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"tabulate_survival_subgroups(): Table-creating function creates table summarizing survival subgroup. function wrapper rtables::analyze_colvars() rtables::summarize_row_groups(). a_survival_subgroups(): Formatted analysis function used afun tabulate_survival_subgroups().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/survival_duration_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"","code":"library(dplyr) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) adtte_f <- adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\"), SEX %in% c(\"M\", \"F\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")), SEX = droplevels(SEX), AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- c( \"ARM\" = adtte_labels[[\"ARM\"]], \"SEX\" = adtte_labels[[\"SEX\"]], \"AVALU\" = adtte_labels[[\"AVALU\"]], \"is_event\" = \"Event Flag\" ) formatters::var_labels(adtte_f)[names(labels)] <- labels df <- extract_survival_subgroups( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), label_all = \"Total Patients\", data = adtte_f ) df #> $survtime #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 Total Patients ALL #> 2 A: Drug X 69 44 974.6402 Total Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 LOW BMRKR2 #> 8 A: Drug X 26 15 974.6402 LOW BMRKR2 #> 9 B: Placebo 23 14 731.8352 MEDIUM BMRKR2 #> 10 A: Drug X 26 17 964.2197 MEDIUM BMRKR2 #> 11 B: Placebo 26 22 654.8245 HIGH BMRKR2 #> 12 A: Drug X 17 12 1016.2982 HIGH BMRKR2 #> var_label row_type #> 1 Total Patients content #> 2 Total Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $hr #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 49 31 0.7651261 0.3641277 1.6077269 0.95 0.47860004 #> 6 43 34 0.6662356 0.3257413 1.3626456 0.95 0.26285846 #> pval_label subgroup var var_label #> 1 p-value (log-rank) Total Patients ALL Total Patients #> 2 p-value (log-rank) F SEX Sex #> 3 p-value (log-rank) M SEX Sex #> 4 p-value (log-rank) LOW BMRKR2 Continuous Level Biomarker 2 #> 5 p-value (log-rank) MEDIUM BMRKR2 Continuous Level Biomarker 2 #> 6 p-value (log-rank) HIGH BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 analysis #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis #> df_grouped <- extract_survival_subgroups( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) df_grouped #> $survtime #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 All Patients ALL #> 2 A: Drug X 69 44 974.6402 All Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 low BMRKR2 #> 8 A: Drug X 26 15 974.6402 low BMRKR2 #> 9 B: Placebo 47 35 735.4722 low/medium BMRKR2 #> 10 A: Drug X 52 32 964.2197 low/medium BMRKR2 #> 11 B: Placebo 73 57 727.8043 low/medium/high BMRKR2 #> 12 A: Drug X 69 44 974.6402 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $hr #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 99 67 0.7472958 0.4600419 1.2139136 0.95 0.23764314 #> 6 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> pval_label subgroup var var_label #> 1 p-value (log-rank) All Patients ALL All Patients #> 2 p-value (log-rank) F SEX Sex #> 3 p-value (log-rank) M SEX Sex #> 4 p-value (log-rank) low BMRKR2 Continuous Level Biomarker 2 #> 5 p-value (log-rank) low/medium BMRKR2 Continuous Level Biomarker 2 #> 6 p-value (log-rank) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 analysis #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis #> ## Table with default columns. basic_table() %>% tabulate_survival_subgroups(df, time_unit = adtte_f$AVALU[1]) #> B: Placebo A: Drug X #> Baseline Risk Factors Total Events Events Median (DAYS) Events Median (DAYS) Hazard Ratio 95% Wald CI #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total Patients 101 57 727.8 44 974.6 0.71 (0.48, 1.06) #> Sex #> F 55 31 599.2 24 1016.3 0.56 (0.32, 0.96) #> M 46 26 888.5 20 974.6 0.91 (0.50, 1.65) #> Continuous Level Biomarker 2 #> LOW 36 21 735.5 15 974.6 0.76 (0.39, 1.51) #> MEDIUM 31 14 731.8 17 964.2 0.77 (0.36, 1.61) #> HIGH 34 22 654.8 12 1016.3 0.67 (0.33, 1.36) ## Table with a manually chosen set of columns: adding \"pval\". basic_table() %>% tabulate_survival_subgroups( df = df, vars = c(\"n_tot_events\", \"n_events\", \"median\", \"hr\", \"ci\", \"pval\"), time_unit = adtte_f$AVALU[1] ) #> B: Placebo A: Drug X #> Baseline Risk Factors Total Events Events Median (DAYS) Events Median (DAYS) Hazard Ratio 95% Wald CI p-value (log-rank) #> ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total Patients 101 57 727.8 44 974.6 0.71 (0.48, 1.06) 0.0905 #> Sex #> F 55 31 599.2 24 1016.3 0.56 (0.32, 0.96) 0.0341 #> M 46 26 888.5 20 974.6 0.91 (0.50, 1.65) 0.7558 #> Continuous Level Biomarker 2 #> LOW 36 21 735.5 15 974.6 0.76 (0.39, 1.51) 0.4324 #> MEDIUM 31 14 731.8 17 964.2 0.77 (0.36, 1.61) 0.4786 #> HIGH 34 22 654.8 12 1016.3 0.67 (0.33, 1.36) 0.2629"},{"path":"https://insightsengineering.github.io/tern/reference/survival_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Survival time analysis — survival_time","title":"Survival time analysis — survival_time","text":"analyze function surv_time() creates layout element analyze survival time calculating survival time median, median confidence interval, quantiles, range (, censored, event patients). primary analysis variable vars time variable secondary analysis variable is_event indicates whether event occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Survival time analysis — survival_time","text":"","code":"surv_time( lyt, vars, is_event, control = control_surv_time(), ref_fn_censor = TRUE, na_str = default_na_str(), nested = TRUE, ..., var_labels = \"Time to Event\", show_labels = \"visible\", table_names = vars, .stats = c(\"median\", \"median_ci\", \"quantiles\", \"range\"), .formats = NULL, .labels = NULL, .indent_mods = c(median_ci = 1L) ) s_surv_time(df, .var, is_event, control = control_surv_time()) a_surv_time( df, labelstr = \"\", .var = NULL, .df_row = NULL, is_event, control = control_surv_time(), ref_fn_censor = TRUE, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/reference/survival_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Survival time analysis — survival_time","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . is_event (flag)TRUE event, FALSE time event censored. control (list) parameters comparison details, specified using helper function control_surv_time(). possible parameter options : conf_level (proportion) confidence level interval survival time. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" supported. quantiles (numeric) vector length two specify quantiles survival time. ref_fn_censor (flag) whether referential footnotes indicating censored observations printed range statistic included. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'median', 'median_ci', 'median_ci_3d', 'quantiles', 'quantiles_lower', 'quantiles_upper', 'range_censor', 'range_event', 'range' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Survival time analysis — survival_time","text":"surv_time() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_surv_time() table layout. s_surv_time() returns statistics: median: Median survival time. median_ci: Confidence interval median time. median_ci_3d: Median confidence interval median time. quantiles: Survival time two specified quantiles. quantiles_lower: quantile confidence interval first specified quantile. quantiles_upper: quantile confidence interval second specified quantile. range_censor: Survival time range censored observations. range_event: Survival time range observations events. range: Survival time range observations. a_surv_time() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_time.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Survival time analysis — survival_time","text":"surv_time(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_surv_time(): Statistics function analyzes survival times. a_surv_time(): Formatted analysis function used afun surv_time().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Survival time analysis — survival_time","text":"","code":"library(dplyr) adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) df <- adtte_f %>% filter(ARMCD == \"ARM A\") basic_table() %>% split_cols_by(var = \"ARMCD\") %>% add_colcounts() %>% surv_time( vars = \"AVAL\", var_labels = \"Survival Time (Months)\", is_event = \"is_event\", control = control_surv_time(conf_level = 0.9, conf_type = \"log-log\") ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————— #> Survival Time (Months) #> Median 32.0 23.9 20.8 #> 90% CI (22.6, 46.5) (18.3, 29.2) (12.9, 25.9) #> 25% and 75%-ile 17.4, 65.3 9.8, 42.0 7.3, 37.1 #> Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 a_surv_time( df, .df_row = df, .var = \"AVAL\", is_event = \"is_event\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Median 32.0 0 Median #> 2 95% CI (22.5, 49.3) 0 95% CI #> 3 Median (95% CI) 32.0 (22.5 - 49.3) 0 Median (95% CI) #> 4 25% and 75%-ile 17.4, 65.3 0 25% and 75%-ile #> 5 25%-ile (95% CI) 17.4 (10.1 - 22.5) 0 25%-ile (95% CI) #> 6 75%-ile (95% CI) 65.3 (49.3 - 87.2) 0 75%-ile (95% CI) #> 7 Range (censored) 0.8 to 63.5 0 Range (censored) #> 8 Range (event) 0.3 to 155.5 0 Range (event) #> 9 Range 0.3 to 155.5 0 Range"},{"path":"https://insightsengineering.github.io/tern/reference/survival_timepoint.html","id":null,"dir":"Reference","previous_headings":"","what":"Survival time point analysis — survival_timepoint","title":"Survival time point analysis — survival_timepoint","text":"analyze function surv_timepoint() creates layout element analyze patient survival rates difference survival rates groups given time point. primary analysis variable vars time variable. required inputs time_point, numeric time point interest, is_event, variable indicates whether event occurred. method argument used specify whether want analyze survival estimations (\"surv\"), difference survival control (\"surv_diff\"), (\"\").","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_timepoint.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Survival time point analysis — survival_timepoint","text":"","code":"surv_timepoint( lyt, vars, time_point, is_event, control = control_surv_timepoint(), method = c(\"surv\", \"surv_diff\", \"both\"), na_str = default_na_str(), nested = TRUE, ..., table_names_suffix = \"\", var_labels = \"Time\", show_labels = \"visible\", .stats = c(\"pt_at_risk\", \"event_free_rate\", \"rate_ci\", \"rate_diff\", \"rate_diff_ci\", \"ztest_pval\"), .formats = NULL, .labels = NULL, .indent_mods = if (method == \"both\") { c(rate_diff = 1L, rate_diff_ci = 2L, ztest_pval = 2L) } else { c(rate_diff_ci = 1L, ztest_pval = 1L) } ) s_surv_timepoint( df, .var, time_point, is_event, control = control_surv_timepoint() ) a_surv_timepoint( df, .var, time_point, is_event, control = control_surv_timepoint() ) s_surv_timepoint_diff( df, .var, .ref_group, .in_ref_col, time_point, control = control_surv_timepoint(), ... ) a_surv_timepoint_diff( df, .var, .ref_group, .in_ref_col, time_point, control = control_surv_timepoint(), ... )"},{"path":"https://insightsengineering.github.io/tern/reference/survival_timepoint.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Survival time point analysis — survival_timepoint","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . time_point (numeric(1)) survival time point interest. is_event (flag)TRUE event, FALSE time event censored. control (list) parameters comparison details, specified using helper function control_surv_timepoint(). possible parameter options : conf_level (proportion) confidence level interval survival rate. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" longer supported. method (string)\"surv\" (survival estimations), \"surv_diff\" (difference survival control), \"\". na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names_suffix (string) optional suffix table_names used rtables avoid warnings duplicate table names. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". .stats (character) statistics select table. Options : 'pt_at_risk', 'event_free_rate', 'rate_se', 'rate_ci', 'rate_diff', 'rate_diff_ci', 'ztest_pval', 'event_free_rate_3d' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_timepoint.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Survival time point analysis — survival_timepoint","text":"surv_timepoint() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_surv_timepoint() /s_surv_timepoint_diff() table layout depending value method. s_surv_timepoint() returns statistics: pt_at_risk: Patients remaining risk. event_free_rate: Event-free rate (%). rate_se: Standard error event free rate. rate_ci: Confidence interval event free rate. event_free_rate_3d: Event-free rate (%) Confidence interval. a_surv_timepoint() returns corresponding list formatted rtables::CellValue(). s_surv_timepoint_diff() returns statistics: rate_diff: Event-free rate difference two groups. rate_diff_ci: Confidence interval difference. rate_diff_ci_3d: Event-free rate difference confidence interval two groups. ztest_pval: p-value test difference 0. a_surv_timepoint_diff() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_timepoint.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Survival time point analysis — survival_timepoint","text":"surv_timepoint(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_surv_timepoint(): Statistics function analyzes survival rate. a_surv_timepoint(): Formatted analysis function used afun surv_timepoint() method = \"surv\". s_surv_timepoint_diff(): Statistics function analyzes difference two survival rates. a_surv_timepoint_diff(): Formatted analysis function used afun surv_timepoint() method = \"surv_diff\".","code":""},{"path":"https://insightsengineering.github.io/tern/reference/survival_timepoint.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Survival time point analysis — survival_timepoint","text":"","code":"library(dplyr) adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) # Survival at given time points. basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% surv_timepoint( vars = \"AVAL\", var_labels = \"Months\", is_event = \"is_event\", time_point = 7 ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————— #> 7 Months #> Patients remaining at risk 54 57 42 #> Event Free Rate (%) 84.89 79.43 75.50 #> 95% CI (76.24, 93.53) (70.15, 88.71) (64.33, 86.67) # Difference in survival at given time points. basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% surv_timepoint( vars = \"AVAL\", var_labels = \"Months\", is_event = \"is_event\", time_point = 9, method = \"surv_diff\", .indent_mods = c(\"rate_diff\" = 0L, \"rate_diff_ci\" = 2L, \"ztest_pval\" = 2L) ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————————————————————————————— #> 9 Months #> Difference in Event Free Rate -9.64 -13.03 #> 95% CI (-22.80, 3.52) (-27.59, 1.53) #> p-value (Z-test) 0.1511 0.0794 # Survival and difference in survival at given time points. basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% surv_timepoint( vars = \"AVAL\", var_labels = \"Months\", is_event = \"is_event\", time_point = 9, method = \"both\" ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————————————————————————————————————— #> 9 Months #> Patients remaining at risk 53 53 39 #> Event Free Rate (%) 84.89 75.25 71.86 #> 95% CI (76.24, 93.53) (65.32, 85.17) (60.14, 83.57) #> Difference in Event Free Rate -9.64 -13.03 #> 95% CI (-22.80, 3.52) (-27.59, 1.53) #> p-value (Z-test) 0.1511 0.0794"},{"path":"https://insightsengineering.github.io/tern/reference/tern-package.html","id":null,"dir":"Reference","previous_headings":"","what":"tern Package — tern-package","title":"tern Package — tern-package","text":"Package create tables, listings graphs analyze clinical trials data.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/tern-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"tern Package — tern-package","text":"Maintainer: Joe Zhu joe.zhu@roche.com Authors: Daniel Sabanés Bové daniel.sabanes_bove@roche.com Jana Stoilova jana.stoilova@roche.com Davide Garolini davide.garolini@roche.com Emily de la Rua emily.de_la_rua@contractors.roche.com Abinaya Yogasekaram abinaya.yogasekaram@contractors.roche.com Heng Wang wang.heng@gene.com Francois Collin Adrian Waddell adrian.waddell@gene.com Pawel Rucki pawel.rucki@roche.com Chendi Liao chendi.liao@roche.com Jennifer Li li.jing@gene.com contributors: F. Hoffmann-La Roche AG [copyright holder, funder]","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy.glm.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom tidy method for binomial GLM results — tidy.glm","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"Helper method (broom::tidy()) prepare data frame glm object binomial family.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy.glm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"","code":"# S3 method for class 'glm' tidy(x, conf_level = 0.95, at = NULL, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/tidy.glm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"x (glm) logistic regression model fitted stats::glm() \"binomial\" family. conf_level (proportion) confidence level interval. (numeric NULL) optional values interaction variable. Otherwise median used. ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy.glm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"data.frame containing tidied model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/tidy.glm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"","code":"library(dplyr) library(broom) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred df <- tidy(mod1, conf_level = 0.99) df2 <- tidy(mod2, conf_level = 0.99)"},{"path":"https://insightsengineering.github.io/tern/reference/tidy.step.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom tidy method for STEP results — tidy.step","title":"Custom tidy method for STEP results — tidy.step","text":"Tidy STEP results tibble format ready plotting.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy.step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom tidy method for STEP results — tidy.step","text":"","code":"# S3 method for class 'step' tidy(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/tidy.step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom tidy method for STEP results — tidy.step","text":"x (matrix) results fit_survival_step(). ... used.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy.step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom tidy method for STEP results — tidy.step","text":"tibble one row per STEP subgroup. estimates CIs HR scale, respectively. Additional attributes carry metadata also used plotting.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/tidy.step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom tidy method for STEP results — tidy.step","text":"","code":"library(survival) lung$sex <- factor(lung$sex) vars <- list( time = \"time\", event = \"status\", arm = \"sex\", biomarker = \"age\" ) step_matrix <- fit_survival_step( variables = vars, data = lung, control = c(control_coxph(), control_step(num_points = 10, degree = 2)) ) broom::tidy(step_matrix) #> # A tibble: 10 × 12 #> `Percentile Center` `Percentile Lower` `Percentile Upper` `Interval Center` #> * #> 1 0.0909 0 0.341 50 #> 2 0.182 0 0.432 54 #> 3 0.273 0.0227 0.523 57 #> 4 0.364 0.114 0.614 59.5 #> 5 0.455 0.205 0.705 62 #> 6 0.545 0.295 0.795 64 #> 7 0.636 0.386 0.886 67 #> 8 0.727 0.477 0.977 69 #> 9 0.818 0.568 1 71 #> 10 0.909 0.659 1 74 #> # ℹ 8 more variables: `Interval Lower` , `Interval Upper` , n , #> # events , `Hazard Ratio` , se , ci_lower , #> # ci_upper "},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/tidy_coxreg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"","code":"# S3 method for class 'summary.coxph' tidy(x, ...) # S3 method for class 'coxreg.univar' tidy(x, ...) # S3 method for class 'coxreg.multivar' tidy(x, ...)"},{"path":"https://insightsengineering.github.io/tern/reference/tidy_coxreg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"x (list) result Cox regression model fitted fit_coxreg_univar() (univariate models) fit_coxreg_multivar() (multivariate models). ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy_coxreg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"broom::tidy() returns: summary.coxph objects, data.frame columns: Pr(>|z|), exp(coef), exp(-coef), lower .95, upper .95, level, n. coxreg.univar objects, data.frame columns: effect, term, term_label, level, n, hr, lcl, ucl, pval, ci. coxreg.multivar objects, data.frame columns: term, pval, term_label, hr, lcl, ucl, level, ci.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/tidy_coxreg.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"tidy(summary.coxph): Custom tidy method survival::coxph() summary results. Tidy survival::coxph() results data.frame extract model results. tidy(coxreg.univar): Custom tidy method univariate Cox regression. Tidy result Cox regression model fitted fit_coxreg_univar(). tidy(coxreg.multivar): Custom tidy method multivariate Cox regression. Tidy result Cox regression model fitted fit_coxreg_multivar().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/tidy_coxreg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"","code":"library(survival) library(broom) set.seed(1, kind = \"Mersenne-Twister\") dta_bladder <- with( data = bladder[bladder$enum < 5, ], data.frame( time = stop, status = event, armcd = as.factor(rx), covar1 = as.factor(enum), covar2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) ) ) labels <- c(\"armcd\" = \"ARM\", \"covar1\" = \"A Covariate Label\", \"covar2\" = \"Sex (F/M)\") formatters::var_labels(dta_bladder)[names(labels)] <- labels dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) formula <- \"survival::Surv(time, status) ~ armcd + covar1\" msum <- summary(coxph(stats::as.formula(formula), data = dta_bladder)) tidy(msum) #> Pr(>|z|) exp(coef) exp(-coef) lower .95 upper .95 level n #> 1 1.287954e-02 0.6110123 1.636628 0.41442417 0.9008549 armcd2 340 #> 2 6.407916e-04 0.4460731 2.241785 0.28061816 0.7090818 covar12 340 #> 3 5.272933e-06 0.3075864 3.251119 0.18517346 0.5109230 covar13 340 #> 4 2.125359e-08 0.1808795 5.528541 0.09943722 0.3290258 covar14 340 ## Cox regression: arm + 1 covariate. mod1 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = \"covar1\" ), data = dta_bladder, control = control_coxreg(conf_level = 0.91) ) ## Cox regression: arm + 1 covariate + interaction, 2 candidate covariates. mod2 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder, control = control_coxreg(conf_level = 0.91, interaction = TRUE) ) tidy(mod1) #> effect term term_label level n hr lcl #> ref Treatment: armcd 2 vs control (1) 2 340 0.6386426 0.4557586 #> covar1 Covariate: covar1 A Covariate Label 2 340 0.607037 0.4324571 #> ucl pval ci #> ref 0.8949131 0.02423805 0.4557586, 0.8949131 #> covar1 0.8520935 0.01257339 0.4324571, 0.8520935 tidy(mod2) #> effect term term_label level n hr #> ref Treatment: armcd 2 vs control (1) 2 340 0.6386426 #> covar1.1 Covariate: covar1 A Covariate Label 340 #> covar1.armcd2/covar11 Covariate: covar1 1 1 0.6284569 #> covar1.armcd2/covar12 Covariate: covar1 2 2 0.5806499 #> covar1.armcd2/covar13 Covariate: covar1 3 3 0.5486103 #> covar1.armcd2/covar14 Covariate: covar1 4 4 0.6910725 #> covar2.1 Covariate: covar2 Sex (F/M) 340 #> covar2.armcd2/covar2F Covariate: covar2 F F 0.6678243 #> covar2.armcd2/covar2M Covariate: covar2 M M 0.5954021 #> lcl ucl pval pval_inter #> ref 0.4557586 0.8949131 0.02423805 #> covar1.1 NA NA 0.9883021 #> covar1.armcd2/covar11 0.3450471 1.1446499 #> covar1.armcd2/covar12 0.2684726 1.2558239 #> covar1.armcd2/covar13 0.2226814 1.3515868 #> covar1.armcd2/covar14 0.2308006 2.0692373 #> covar2.1 NA NA 0.7759013 #> covar2.armcd2/covar2F 0.3649842 1.2219413 #> covar2.armcd2/covar2M 0.3572772 0.9922368 #> ci #> ref 0.4557586, 0.8949131 #> covar1.1 #> covar1.armcd2/covar11 0.3450471, 1.1446499 #> covar1.armcd2/covar12 0.2684726, 1.2558239 #> covar1.armcd2/covar13 0.2226814, 1.3515868 #> covar1.armcd2/covar14 0.2308006, 2.0692373 #> covar2.1 #> covar2.armcd2/covar2F 0.3649842, 1.2219413 #> covar2.armcd2/covar2M 0.3572772, 0.9922368 multivar_model <- fit_coxreg_multivar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder ) broom::tidy(multivar_model) #> term pval term_label #> armcd.1 armcd ARM (reference = 1) #> armcd.2 ARM 0.01232761 2 #> covar1.1 covar1 7.209956e-09 A Covariate Label (reference = 1) #> covar1.2 A Covariate Label 0.001120332 2 #> covar1.3 A Covariate Label 6.293725e-06 3 #> covar1.4 A Covariate Label 3.013875e-08 4 #> covar2.1 covar2 Sex (F/M) (reference = F) #> covar2.2 Sex (F/M) 0.1910521 M #> hr lcl ucl level ci #> armcd.1 NA NA #> armcd.2 0.6062777 0.40970194 0.8971710 2 0.4097019, 0.8971710 #> covar1.1 NA NA #> covar1.2 0.4564763 0.28481052 0.7316115 2 0.2848105, 0.7316115 #> covar1.3 0.3069612 0.18386073 0.5124813 3 0.1838607, 0.5124813 #> covar1.4 0.1817017 0.09939435 0.3321668 4 0.09939435, 0.33216684 #> covar2.1 NA NA #> covar2.2 1.289373 0.88087820 1.8873019 M 0.8808782, 1.8873019"},{"path":"https://insightsengineering.github.io/tern/reference/to_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Replicate entries of a vector if required — to_n","title":"Replicate entries of a vector if required — to_n","text":"Replicate entries vector required.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replicate entries of a vector if required — to_n","text":"","code":"to_n(x, n)"},{"path":"https://insightsengineering.github.io/tern/reference/to_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replicate entries of a vector if required — to_n","text":"x (numeric) vector numbers want analyze. n (integer(1)) number entries needed.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Replicate entries of a vector if required — to_n","text":"x required length already NULL, otherwise scalar replicated version n entries.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_n.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Replicate entries of a vector if required — to_n","text":"function fail x length n /scalar.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_string_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert table into matrix of strings — to_string_matrix","title":"Convert table into matrix of strings — to_string_matrix","text":"Helper function use mostly within tests. with_spacesparameter allows test content also indentation table structure. print_txt_to_copy instead facilitate testing development returning well formatted text needs copied pasted expected output.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_string_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert table into matrix of strings — to_string_matrix","text":"","code":"to_string_matrix( x, widths = NULL, max_width = NULL, hsep = formatters::default_hsep(), with_spaces = TRUE, print_txt_to_copy = FALSE )"},{"path":"https://insightsengineering.github.io/tern/reference/to_string_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert table into matrix of strings — to_string_matrix","text":"x (VTableTree)rtables table object. widths (numeric NULL) Proposed widths columns x. expected length numeric vector can retrieved ncol(x) + 1 column row names must also considered. max_width (integer(1), string NULL) width title footer (including footnotes) materials word-wrapped . NULL, set current print width session (getOption(\"width\")). set \"auto\", width table (plus table inset) used. Parameter ignored tf_wrap = FALSE. hsep (string) character repeat create header/body separator line. NULL, object value used. \" \", empty separator printed. See default_hsep() information. with_spaces (flag) whether tested table keep indentation relevant spaces. print_txt_to_copy (flag) utility way copy input table directly expected variable instead copying manually.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_string_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert table into matrix of strings — to_string_matrix","text":"matrix strings. print_txt_to_copy = TRUE well formatted printout table printed console, ready copied expected value.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/to_string_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert table into matrix of strings — to_string_matrix","text":"","code":"tbl <- basic_table() %>% split_rows_by(\"SEX\") %>% split_cols_by(\"ARM\") %>% analyze(\"AGE\") %>% build_table(tern_ex_adsl) to_string_matrix(tbl, widths = ceiling(propose_column_widths(tbl) / 2)) #> [1] \" A: \" \" Drug B: Pl C: Comb\" #> [3] \" X acebo ination\" \"—————————————————————————————\" #> [5] \"F \" \" M 33.68 35.98 36.02 \" #> [7] \" e \" \" a \" #> [9] \" n \" \"M \" #> [11] \" M 34.70 35.68 36.28 \" \" e \" #> [13] \" a \" \" n \""},{"path":"https://insightsengineering.github.io/tern/reference/try_car_anova.html","id":null,"dir":"Reference","previous_headings":"","what":"tryCatch around car::Anova — try_car_anova","title":"tryCatch around car::Anova — try_car_anova","text":"Captures warnings executing car::Anova.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/try_car_anova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"tryCatch around car::Anova — try_car_anova","text":"","code":"try_car_anova(mod, test.statistic)"},{"path":"https://insightsengineering.github.io/tern/reference/try_car_anova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"tryCatch around car::Anova — try_car_anova","text":"mod lm, aov, glm, multinom, polr mlm, coxph, coxme, lme, mer, merMod, svyglm, svycoxph, rlm, clm, clmm, suitable model object. test.statistic generalized linear model, whether calculate \"LR\" (likelihood-ratio), \"Wald\", \"F\" tests; Cox Cox mixed-effects model, whether calculate \"LR\" (partial-likelihood ratio) \"Wald\" tests (\"LR\" tests unavailable Cox models using tt argument); default case linear mixed models fit lmer, whether calculate Wald \"Chisq\" Kenward-Roger \"F\" tests Satterthwaite degrees freedom (warning: KR F-tests can time-consuming). multivariate linear model, multivariate test statistic compute — one \"Pillai\", \"Wilks\", \"Hotelling-Lawley\", \"Roy\", \"Pillai\" default. summary method Anova.mlm objects permits specification one multivariate test statistic, default report four.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/try_car_anova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"tryCatch around car::Anova — try_car_anova","text":"list item aov result model error_text captured warnings.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/try_car_anova.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"tryCatch around car::Anova — try_car_anova","text":"","code":"# `car::Anova` on cox regression model including strata and expected # a likelihood ratio test triggers a warning as only Wald method is # accepted. library(survival) mod <- coxph( formula = Surv(time = futime, event = fustat) ~ factor(rx) + strata(ecog.ps), data = ovarian )"},{"path":"https://insightsengineering.github.io/tern/reference/ungroup_stats.html","id":null,"dir":"Reference","previous_headings":"","what":"Ungroup non-numeric statistics — ungroup_stats","title":"Ungroup non-numeric statistics — ungroup_stats","text":"Ungroups grouped non-numeric statistics within input vectors .formats, .labels, .indent_mods.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/ungroup_stats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ungroup non-numeric statistics — ungroup_stats","text":"","code":"ungroup_stats(x, .formats, .labels, .indent_mods)"},{"path":"https://insightsengineering.github.io/tern/reference/ungroup_stats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ungroup non-numeric statistics — ungroup_stats","text":"x (named list numeric) list numeric statistics containing statistics ungroup. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/ungroup_stats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ungroup non-numeric statistics — ungroup_stats","text":"list modified elements x, .formats, .labels, .indent_mods.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/univariate.html","id":null,"dir":"Reference","previous_headings":"","what":"Univariate formula special term — univariate","title":"Univariate formula special term — univariate","text":"special term univariate indicate model fitted individually every variable included univariate.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/univariate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Univariate formula special term — univariate","text":"","code":"univariate(x)"},{"path":"https://insightsengineering.github.io/tern/reference/univariate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Univariate formula special term — univariate","text":"x (character) vector variable names separated commas.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/univariate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Univariate formula special term — univariate","text":"used within model formula, produces univariate models variable provided.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/univariate.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Univariate formula special term — univariate","text":"provided alongside pairwise specification, model y ~ ARM + univariate(SEX, AGE, RACE) lead study comparison models y ~ ARM y ~ ARM + SEX y ~ ARM + AGE y ~ ARM + RACE","code":""},{"path":"https://insightsengineering.github.io/tern/reference/unlist_and_blank_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Blank for missing input — unlist_and_blank_na","title":"Blank for missing input — unlist_and_blank_na","text":"Helper function use tabulating model results.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/unlist_and_blank_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Blank for missing input — unlist_and_blank_na","text":"","code":"unlist_and_blank_na(x)"},{"path":"https://insightsengineering.github.io/tern/reference/unlist_and_blank_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Blank for missing input — unlist_and_blank_na","text":"x (vector) input cell.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/unlist_and_blank_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Blank for missing input — unlist_and_blank_na","text":"empty character vector entries x missing (NA), otherwise unlisted version x.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/update_weights_strat_wilson.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"function wraps iteration procedure allows estimate weights proportional strata. assumes minimize weighted squared length confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/update_weights_strat_wilson.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"","code":"update_weights_strat_wilson( vars, strata_qnorm, initial_weights, n_per_strata, max_iterations = 50, conf_level = 0.95, tol = 0.001 )"},{"path":"https://insightsengineering.github.io/tern/reference/update_weights_strat_wilson.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"vars (numeric) normalized proportions strata. strata_qnorm (numeric(1)) initial estimation identical weights quantiles. initial_weights (numeric) initial weights used calculate strata_qnorm. can optimized future need estimate better initial weights. n_per_strata (numeric) number elements strata. max_iterations (integer(1)) maximum number iterations tried. Convergence always checked. conf_level (proportion) confidence level interval. tol (numeric(1)) tolerance threshold convergence.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/update_weights_strat_wilson.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"list 3 elements: n_it, weights, diff_v.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/update_weights_strat_wilson.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"","code":"vs <- c(0.011, 0.013, 0.012, 0.014, 0.017, 0.018) sq <- 0.674 ws <- rep(1 / length(vs), length(vs)) ns <- c(22, 18, 17, 17, 14, 12) update_weights_strat_wilson(vs, sq, ws, ns, 100, 0.95, 0.001) #> $n_it #> [1] 3 #> #> $weights #> [1] 0.2067191 0.1757727 0.1896962 0.1636346 0.1357615 0.1284160 #> #> $diff_v #> [1] 1.458717e-01 1.497223e-03 1.442189e-06 #>"},{"path":"https://insightsengineering.github.io/tern/reference/util_handling_additional_fun_params.html","id":null,"dir":"Reference","previous_headings":"","what":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"Important additional parameters, useful modify behavior analysis summary functions listed rtables::additional_fun_params. utility functions can retrieve curated list parameters environment, pass analysis functions dedicated ...; notice final s_* function get argument matching.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/util_handling_additional_fun_params.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"","code":"retrieve_extra_afun_params(extra_afun_params) get_additional_afun_params(add_alt_df = FALSE)"},{"path":"https://insightsengineering.github.io/tern/reference/util_handling_additional_fun_params.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"extra_afun_params (list) list additional parameters (character) retrieved environment. Curated list present rtables::additional_fun_params. add_alt_df (logical) TRUE, function also add .alt_df .alt_df_row parameters.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/util_handling_additional_fun_params.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"retrieve_extra_afun_params returns list values parameters environment. get_additional_afun_params returns list additional parameters.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/util_handling_additional_fun_params.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"retrieve_extra_afun_params(): Retrieve additional parameters environment. get_additional_afun_params(): Curated list additional parameters analysis functions. Please check rtables::additional_fun_params precise descriptions.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/utils_split_funs.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom split functions — utils_split_funs","title":"Custom split functions — utils_split_funs","text":"Collection useful functions expanding core list functions provided rtables. See rtables::custom_split_funs rtables::make_split_fun() information make custom split function. functions work rtables::split_rows_by() argument split_fun modify way split happens. split functions, consider consulting rtables::split_funcs.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/utils_split_funs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom split functions — utils_split_funs","text":"","code":"ref_group_position(position = \"first\") level_order(order)"},{"path":"https://insightsengineering.github.io/tern/reference/utils_split_funs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom split functions — utils_split_funs","text":"position (string integer) position use reference group facet. Can \"first\", \"last\", specific position. order (character numeric) vector ordering indices split facets.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/utils_split_funs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom split functions — utils_split_funs","text":"ref_group_position() returns utility function puts reference group first, last certain position needs assigned split_fun. level_order() returns utility function changes original levels' order, depending input order split levels.","code":""},{"path":"https://insightsengineering.github.io/tern/reference/utils_split_funs.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Custom split functions — utils_split_funs","text":"ref_group_position(): Split function place reference group facet specific position post-processing stage. level_order(): Split function change level order based integer vector character vector represent split variable's factor levels.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/reference/utils_split_funs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom split functions — utils_split_funs","text":"","code":"library(dplyr) dat <- data.frame( x = factor(letters[1:5], levels = letters[5:1]), y = 1:5 ) # With rtables layout functions basic_table() %>% split_cols_by(\"x\", ref_group = \"c\", split_fun = ref_group_position(\"last\")) %>% analyze(\"y\") %>% build_table(dat) #> e d b a c #> ——————————————————————————————————————— #> Mean 5.00 4.00 2.00 1.00 3.00 # With tern layout funcitons adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM B\", split_fun = ref_group_position(\"first\")) %>% add_colcounts() %>% surv_time( vars = \"AVAL\", var_labels = \"Survival Time (Months)\", is_event = \"is_event\", ) %>% build_table(df = adtte_f) #> ARM B ARM A ARM C #> (N=73) (N=69) (N=58) #> ——————————————————————————————————————————————————————————————————— #> Survival Time (Months) #> Median 23.9 32.0 20.8 #> 95% CI (18.3, 32.9) (22.5, 49.3) (12.9, 26.0) #> 25% and 75%-ile 9.8, 42.0 17.4, 65.3 7.3, 37.1 #> Range 0.1 to 154.1 0.3 to 155.5 0.6 to 80.7 basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM B\", split_fun = ref_group_position(2)) %>% add_colcounts() %>% surv_time( vars = \"AVAL\", var_labels = \"Survival Time (Months)\", is_event = \"is_event\", ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————— #> Survival Time (Months) #> Median 32.0 23.9 20.8 #> 95% CI (22.5, 49.3) (18.3, 32.9) (12.9, 26.0) #> 25% and 75%-ile 17.4, 65.3 9.8, 42.0 7.3, 37.1 #> Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 # level_order -------- # Even if default would bring ref_group first, the original order puts it last basic_table() %>% split_cols_by(\"Species\", split_fun = level_order(c(1, 3, 2))) %>% analyze(\"Sepal.Length\") %>% build_table(iris) #> setosa virginica versicolor #> —————————————————————————————————————— #> Mean 5.01 6.59 5.94 # character vector new_order <- level_order(levels(iris$Species)[c(1, 3, 2)]) basic_table() %>% split_cols_by(\"Species\", ref_group = \"virginica\", split_fun = new_order) %>% analyze(\"Sepal.Length\") %>% build_table(iris) #> setosa virginica versicolor #> —————————————————————————————————————— #> Mean 5.01 6.59 5.94"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-6-9015","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.6.9015","text":"Added denom parameter s_count_cumulative(), s_count_missed_doses(), s_count_occurrences_by_grade(). Added \"N_row\" optional input denom s_count_occurrences(). Refactored a_count_occurrences_by_grade(), a_count_patients_with_event(), a_count_patients_with_flags() longer use make_afun(). Added rel_height_plot parameter g_lineplot() control line plot height relative annotation table height. Updated table_font_size parameter g_lineplot() control size text annotation table, including labels. Added as_list parameter g_lineplot() allow users return line plot annotation table elements list instead stacked complex customization. Refactored summarize_change() work without make_afun() access additional function parameter. Added vignette “Understanding tern functions” future reference.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-6-9015","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.6.9015","text":"Fixed bug a_summary() causing non-unique row_name values occur multiple statistics selected count variables.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-6-9015","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.6.9015","text":"Reverted deprecation quick get functions summary_formats() summary_labels(). Added disclaimer underlying use get_stats. Corrected handling extra arguments NA summarize_change().","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-096","dir":"Changelog","previous_headings":"","what":"tern 0.9.6","title":"tern 0.9.6","text":"CRAN release: 2024-09-24","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-6","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.6","text":"Added median_ci_3d s_summary includes estimate confidence interval one statistic. Added median_ci_3d, quantiles_lower quantiles_upper s_surv_time includes estimate confidence interval one statistic. Added hr_ci_3d s_coxph_pairwise includes estimate confidence interval one statistic. Added event_free_rate_3d s_surv_timepoint includes estimate confidence interval one statistic. Added rate_diff_ci_3d s_surv_timepoint_diff includes estimate confidence interval one statistic. Added errorbar_width linetype parameters g_lineplot. Added .formats argument tabulate_rsp_subgroups tabulate_survival_subgroups allow users specify formats. Added riskdiff argument tabulate_rsp_subgroups tabulate_survival_subgroups allow users add risk difference table column, function control_riskdiff specify settings risk difference column. Added warning tabulate_rsp_subgroups pval statistic selected df correctly generated add p-values output table. Added n_rate statistic non-default option estimate_incidence_rate returns number events observed estimated incidence rate. Added n_unique statistic non-default option estimate_incidence_rate returns total number patients least one event observed. Refactored estimate_incidence_rate work analyze function summarize function, controlled added summarize parameter. summarize = TRUE, labels can fine-tuned via new label_fmt argument function. Added fraction statistic analyze_var_count method group. Improved summarize_glm_count() documentation associated functions better describe results functions’ purpose. Added method argument s_odds_ratio() estimate_odds_ratio() control whether exact approximate conditional likelihood calculations used.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-6","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.6","text":"Added defaults d_count_cumulative parameters described documentation. Fixed bug empty levels g_lineplot x-axis shown either plots. Fixed bug a_surv_time threw error split \"is_event\". Fixed disappearing line g_lineplot using one group strata level. Fixed defaults formats labels get_formats_from_stats get_labels_from_stats. Fixed bug linear scaling factor (scale parameter) applied response rate h_glm_count distributions logarithmic link function. Fixed bug decorate_grob handle well empty strings NULL values title footers. Fixed bug g_km caused error multiple records data estimates max time. Fixed issue wrong wrapping due different \\n vector behavior cope well split_string().","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-6","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.6","text":"Began deprecation confusing functions summary_formats summary_labels. Enhanced general descriptions analyze summarize functions throughout package documentation. Finalized deprecation strata cohort_id arguments g_lineplot. Moved incidence rate helper functions separate h_incidence_rate.R file.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-095","dir":"Changelog","previous_headings":"","what":"tern 0.9.5","title":"tern 0.9.5","text":"CRAN release: 2024-06-21","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.5","text":"Added facet_var g_lineplot allow plot faceting factor variable. Added examples tests label_all parameter extract_survival_biomarkers extract_survival_subgroups. Added xticks, xlim, ylim arguments g_lineplot allow customization x y axes. Updated g_lineplot legend follow factor levels set users.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-5","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.5","text":"Fixed bug s_ancova prevented statistics printed arm levels include special characters. Fixed bug decorate_grob prevented right margins respected adding title footers decorations.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-5","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.5","text":"Began deprecation unused label_all parameter tabulate_survival_biomarkers tabulate_survival_subgroups, redirection parameter associated extract_* functions.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-094","dir":"Changelog","previous_headings":"","what":"tern 0.9.4","title":"tern 0.9.4","text":"CRAN release: 2024-04-17","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-9-4","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.4","text":"Added h_glm_negbin h_glm_count enable count data analysis using negative binomial model. Added argument grade_groups_only count_occurrences_by_grade allow users display rows specified grade groups. Added internal function df2gg converts data.frame objects ggplot objects. Added functions control_surv_med_annot control_coxph_annot configure g_km annotation table sizes/positions. Refactored g_km output ggplot object instead grob object. Refactored g_forest output ggplot object instead grob object.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.4","text":"Default format mean p-values (mean_pval) updated \"xx.xx\" \"x.xxxx | (<0.0001)\".","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-4","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.4","text":"Fixed nested column split label overlay issue rtable2gg clean appearance text labels. Fixed bug s_ancova causing incorrect difference calculations arm variables irregular levels. Fixed bug format_count_fraction_fixed_dp print fraction 1 (100%). Fixed bug g_lineplot causing default labels update according specified control settings. Fixed bug causing error automatic value formatting applied NA values.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-4","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.4","text":"Added function expect_snapshot_ggplot test setup file process plot snapshot tests allow plot dimensions set. Adapted argument renames introduced ggplot2 3.5.0. Renamed individual_patient_plot.R g_ipp.R. Removed instances deprecated parameters time_unit_input, time_unit_output, na_level indent_mod. Removed deprecated functions summarize_vars, control_summarize_vars, a_compare, create_afun_summary, create_afun_compare, summary_custom. Removed vdiffr package Suggests DESCRIPTION file. Began deprecation named element strat, renamed strata, within variables argument h_rsp_to_logistic_variables, h_logistic_mult_cont_df, h_odds_ratio_subgroups_df, h_coxreg_mult_cont_df, h_coxph_subgroups_df, h_tbl_coxph_pairwise, extract_rsp_biomarkers, extract_rsp_subgroups, extract_survival_biomarkers, extract_survival_subgroups. Began deprecation strat argument s_coxph_pairwise replaced strata argument. Began deprecation forest_grob, forest_dot_line, forest_viewport, vp_forest_table_part, grid.forest functions. Began deprecation longer used Kaplan-Meier helper functions h_ggkm, h_decompose_gg, h_km_layout, h_grob_tbl_at_risk, h_grob_median_surv, h_grob_y_annot, h_grob_coxph. Began deprecation grob/grid related functions stack_grobs, arrange_grobs, draw_grob longer used tern.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-093","dir":"Changelog","previous_headings":"","what":"tern 0.9.3","title":"tern 0.9.3","text":"CRAN release: 2023-12-08","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-9-3","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.3","text":"Added ref_group_position function place reference group facet last, first certain position. Added keep_level_order split function retain original order levels split. Added level_order split function reorder manually levels. Added function get_indents_from_stats format return indent modifiers given set statistics. Added internal utility function apply_auto_formatting check \"auto\" formats replace implementation format_auto analyze functions. Added utility function labels_use_control modify labels control specifications. Added list containing default statistics method group, tern_default_stats. Added summarize function version count_occurrences analyze function, summarize_occurrences. Added referential footnotes surv_time censored range observations, controlled via ref_fn_censor parameter. Added helper function h_adlb_abnormal_by_worst_grade prepare ADLB data use input count_abnormal_by_worst_grade. Added s_bland_altman function assess agreement two numerical vectors. Added function rtable2gg converts rtable objects ggplot objects. Added helper function set default na_str globally set_default_na_str() added default_na_str() interested functions.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.3","text":"Added ref_group_coxph parameter g_km specify reference group used pairwise Cox-PH calculations annot_coxph = TRUE. Added annot_coxph_ref_lbls parameter g_km enable printing reference group table labels annot_coxph = TRUE. Added x_lab parameter g_lineplot customize x-axis label. Remove 25% padding y-axis g_lineplot. Added support creating multiple risk difference columns, comparing single comparison group. Multiple comparison groups can specified vector via arm_y argument. Allowed numeric vector count_by input analyze_num_patients summarize_num_patients. Aligned plot table vertically g_lineplot.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-3","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.3","text":"Fixed bug decorate_grob preventing text wrapping accounting font size. Fixed implementation na_str argument column-wise analysis tabulation functions.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-3","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.3","text":"Specified minimal version package dependencies. Upgraded to_string_matrix take account widths printing parameters.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-9-2","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.2","text":"Added na_str argument analyze & summarize_row_groups wrapper functions count_abnormal, count_abnormal_by_baseline, count_abnormal_by_marked, count_abnormal_by_worst_grade, count_abnormal_lab_worsen_by_baseline, count_cumulative, count_missed_doses, count_occurrences, count_occurrences_by_grade, summarize_occurrences_by_grade, summarize_patients_events_in_cols, count_patients_with_event, count_patients_with_flags, count_values, estimate_multinomial_response, estimate_proportion, h_tab_one_biomarker, estimate_incidence_rate, logistic_summary_by_flag, estimate_odds_ratio, estimate_proportion_diff, test_proportion_diff, summarize_ancova, summarize_change, summarize_glm_count, summarize_num_patients, analyze_num_patients, summarize_patients_exposure_in_cols, coxph_pairwise, tabulate_survival_subgroups, surv_time, surv_timepoint.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.2","text":"Added formatting function format_count_fraction_lt10 formatting count_fraction special consideration count less 10. Updated s_summary.logical output count_fraction denominator zero display NA instead 0 tables. Updated analyze_vars_in_cols allow character input indicate whether nominal time point post-dose pre-dose applying 1/3 imputation rule.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-2","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.2","text":"Fixed bug g_km causing error converting certain annotation width units.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-2","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.2","text":"Began deprecation na_level argument s_count_abnormal_by_baseline, a_summary, analyze_vars, analyze_vars_in_cols, compare_vars, h_map_for_count_abnormal, h_stack_by_baskets, summarize_colvars, a_coxreg, summarize_coxreg replaced na_str argument. strata cohort_id parameters renamed group_var subject_var respectively g_lineplot control_lineplot_vars .","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-9-1","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.1","text":"Added imputation_rule function apply imputation rule data. Added new format function format_sigfig allow numeric value formatting specified number significant figures. Added vectors containing default statistic formats labels tern_default_formats tern_default_labels, respectively. Added function get_stats return methods given statistical method groups. Added function get_formats_from_stats return formats get_labels_from_stats return labels given set statistics. Added \"auto\" option .formats. uses format_auto determine automatically number digits. Added title argument h_grob_tbl_at_risk annot_at_risk_title argument g_km h_km_layout allows user add “Patients Risk” title Kaplan-Meier risk annotation table.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-1","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.1","text":"Refactored tabulate_rsp_subgroups pass sanitation checks preventing creation degenerate subtables. Updated analyze_vars_in_cols use caching, allow implementation imputation rule via imp_rule argument, allow user specify cell alignment via .aligns argument. Updated add_rowcounts allow addition row counts alt_counts_df using alt_counts argument. Added gp argument g_forest control graphical parameters font size.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-1","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.1","text":"Grouped functions relating valid method names default formats labels new source file utils_defaults_handling.R. Started deprecation summary_custom() a_summary() S3 method. Renamed statistical method p-value discrete case pval_counts. Removed a_summary_internal() favor one main a_summary().","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-090","dir":"Changelog","previous_headings":"","what":"tern 0.9.0","title":"tern 0.9.0","text":"CRAN release: 2023-09-01","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-9-0","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.0","text":"Added stat_propdiff_ci function calculate proportion/risk difference CI. Added risk difference column functionality via riskdiff argument functions count_occurrences, count_occurrences_by_grade, count_patients_with_event, count_patients_with_flags, analyze_num_patients, summarize_num_patients.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-9-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.0","text":"Refactored function a_summary longer use helper function create_afun_summary. Refactored functions summarize_vars compare_vars use refactored a_summary function. Created new internal helper functions ungroup_stats ungroup statistics calculated factor variables, a_summary_internal perform calculations a_summary.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-9-0","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.0","text":"Fixed bug s_count_occurrences_by_grade “missing” grade always appears final level. Fixed bug analyze_vars_in_cols categorical data used. Fixed bug s_count_occurrences_by_grade levels relabeled reordering account “missing” grades.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-9-0","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.0","text":"Fixed swapped descriptions .N_row .N_col parameters. Removed internal calls df_explicit_na. Changes NA values happen externally tern functions, depending users’ needs. Reinstated correct soft deprecation create_afun_summary create_afun_compare.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-8-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.5","text":"Added ylim argument g_km allow user set custom limits y-axis. Added assertion g_km checks whether one arm present data annot_coxph true. Added flag_labels argument s_count_patients_with_flags enable label handling options count_patients_by_flags. Added nested argument analyze wrapper functions count_abnormal, count_abnormal_by_baseline, count_abnormal_by_marked, count_abnormal_by_worst_grade, count_abnormal_lab_worsen_by_baseline, count_cumulative, count_missed_doses, count_occurrences, count_occurrences_by_grade, count_patients_with_event, count_patients_with_flags, count_values, estimate_multinomial_response, estimate_proportion, estimate_incidence_rate, estimate_odds_ratio, estimate_proportion_diff, test_proportion_diff, summarize_ancova, summarize_change, summarize_glm_count, analyze_num_patients, coxph_pairwise, surv_time, surv_timepoint.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-8-5","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.5","text":"Started deprecation cycle summarize_vars control_summarize_vars. Renamed analyze_vars control_analyze_vars reflect underlying rtables machinery keeping backward compatibility aliases.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-084","dir":"Changelog","previous_headings":"","what":"tern 0.8.4","title":"tern 0.8.4","text":"CRAN release: 2023-06-27","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-8-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.4","text":"Added method character class h_coxreg_inter_effect enabling character covariates summarize_coxreg.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-8-4","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.4","text":"Began deprecation time_unit_input time_unit_output arguments replaced input_time_unit num_pt_year, respectively, control_incidence_rate. Removed deprecated pairwise function. Deprecated a_compare replaced a_summary argument compare = TRUE. Deprecated helper functions create_afun_summary create_afun_compare longer used a_summary a_compare respectively.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-8-4","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.4","text":"Fixed long double assertion check sum(weights) M1mac installation.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-083","dir":"Changelog","previous_headings":"","what":"tern 0.8.3","title":"tern 0.8.3","text":"CRAN release: 2023-06-19","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-8-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.3","text":"Added explicit zero counts g_km plot “risk” annotation tables. Added flag total level split analyze_patients_exposure_in_cols. Implemented .indent_mods argument functions h_tab_one_biomarker, h_tab_rsp_one_biomarker, h_tab_surv_one_biomarker, summarize_logistic, logistic_summary_by_flag, tabulate_rsp_biomarkers, a_coxreg, summarize_coxreg, tabulate_survival_biomarkers, surv_time, surv_timepoint, cfun_by_flag. Updated summarize_coxreg print covariates data rows univariate Cox regression interactions content rows otherwise. Removed “baseline status” text d_count_abnormal_by_baseline labels. Improved default sizing annotation tables g_km added dynamic scaling surv_med coxph annotation tables, customization via width_annots argument.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-8-3","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.3","text":"Fixed bug split_text_grob preventing titles footnotes properly formatted printed decorate_grob. Fixed bug g_lineplot preventing addition lines plot midpoint statistic calculations result NA value(s). Fixed tern:::tidy.glm formals respect broom:::tidy.default formals.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-8-3","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.3","text":"Updated README include installation instructions CRAN. Remove examples unexported functions. Export functions has_count_in_cols, has_counts_difference, combine_counts, h_tab_rsp_one_biomarker, arrange_grobs, a_count_patients_sum_exposure, a_coxreg, groups_list_to_df, forest_viewport. Updated README include installation instructions CRAN. Began deprecation indent_mod argument replaced .indent_mods argument summarize_num_patients analyze_num_patients.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"breaking-changes-0-8-2","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"tern 0.8.2","text":"Refactored s_coxreg summarize_coxregto work new analysis function a_coxreg.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-8-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.2","text":"Added section_div na_level arguments summarize_vars. Added median_range numeric variable statistic option summarize_vars. Corrected ordering factor levels d_onco_rsp_label. Added new “Analyze Functions”, “Summarize Functions”, “Analyze Functions Columns” overview pages. Consolidated KM plot documentation within g_km function. Added a_count_patients_sum_exposure summarize_patients_exposure_in_cols new analyze function analyze_patients_exposure_in_cols. Added informative error user selects invalid method unstratified analyses s_proportion_diff. Updated s_summary s_compare allow NA values input variables. factor variables NAs, na.rm = FALSE explicit NA level automatically added. na.rm = TRUE also consider \"\" values exclude . Updated purpose na_level parameter s_summary s_compare align tern functions. Instead string consider NA setting na.rm = TRUE, now defines string print place NA values output table.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-8-2","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.2","text":"Fixed missing label TRTEDTM tern datasets. Fixed improper implementation na_level argument summarize_vars preventing effect.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-8-2","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.2","text":"Implemented lubridate package date variables tern datasets. Organized .gitignore .Rbuildignore files. Removed deprecated footnotes functions related files. Started deprecation cycle pairwise function. Moved count_patients_with_flags functions count_patients_with_event.R count_patients_with_flags.R.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-8-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.0","text":"Added summarize_glm_count function analyze count data using linear model. Added legend g_step. Added formatting functions format_fraction_fixed_dp format_count_fraction_fixed_dp fixed single decimal place percentages. Added na_level labelstr arguments summarize_vars_in_cols. Added analyze_num_patients include summary beginning repeat paginating. Added h_row_first_values function general helper function retrieve first values specific rows. Added option remove \"(n)\" suffix unique_count labels s_num_patients. Added options g_km annotate statistics (annot_stats) add corresponding vertical lines (annot_stats_lines).","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-8-0","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.0","text":"Fixed bug causing incorrect ordering numeric grade levels missing grades present s_count_occurrences_by_grade. Refactored summarize_vars_in_cols work pagination machinery. Fixed bug allow passing conf_level argument emmeans::contrast() s_ancova. Fixed bugs rtables_access.R caused checking specific combinations (also standard values never used) column indices names. Fixed single applicable record bug count_abnormal_by_grade. Fixed bug add_rowcounts caused row count row values count zero. Fixed bug h_col_indices causing error pruning combination columns. Fixed bug test_proportion_diff missing argument var_labels.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"documentation-and-tests-0-8-0","dir":"Changelog","previous_headings":"","what":"Documentation and Tests","title":"tern 0.8.0","text":"Added tests increase code coverage. Created separate documentation files functions different sections pkgdown reference. Created separate .R files logistic regression cox regression helper functions. Fixed table tests using analyze_num_patients generate initial summary repetition paginating. Updated tests use testthat 3rd edition replaced applicable tests snapshot testing. Updated summarize_ancova examples use iris dataset instead scda data. Created vignette saves cached synthetic CDISC dataset files data/ folder generated cached synthetic datasets. Updated examples/tests use datasets data/ folder instead scda datasets. Removed template tests tern. tests internal repo scda.test.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-8-0","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.0","text":"Renamed summarize_vars_in_cols analyze_vars_in_cols reflect appropriate analyze logic. Removed redundant summary_in_cols helper functions. Exported function format_xx. Replaced deprecated ggplot2 functions/arguments fix warnings. Replaced deprecated function forcats::fct_explicit_na forcats::fct_na_value_to_level. Removed deprecated wrap_text function related files. Started deprecation cycle footnotes functions.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-7-10","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.7.10","text":"Added stratified Newcombe stratified Wilson statistics estimate_proportion estimate_proportion_diff relative tests. Added stat_mean_pval, new summary statistic calculate p-value mean. Added statistic mean_se (mean standard error) summarize_variables related functions. Introduced Rdpack references.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-10","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.10","text":"Redesign data handling tests removing repetitive data loads library calls. Added DescTools::BinomDiffCI function within tern. Added new parameter summarize_logistic specify pivoted value use analysis. Updated s_coxph_pairwise generate log-rank p-value using original log-rank test instead Cox Proportional-Hazards Model. Implemented nestcolor examples adapting g_km, g_ipp, g_waterfall, g_step, g_lineplot, g_forest. Added parameters interaction_y interaction_item ANCOVA make interaction calculations available. Added new parameter footnotes add footnotes g_km.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"migration-from-assertthat-to-checkmate-0-7-10","dir":"Changelog","previous_headings":"","what":"Migration from assertthat to checkmate","title":"tern 0.7.10","text":"Implemented checkmate::assert_vector, checkmate::assert_set_equal, checkmate::assert_int check vector type, length, values. Replaced standard assertions checkmate following functions: all_elements_in_ref, is_df_with_nlevels_factor, is_df_with_no_na_level, is_proportion_vector, is_quantiles_vector, is_character_or_factor, is_nonnegative_count, is_valid_character, assert_character_or_factor, assert_equal_length has_tabletree_colnames. Modified is_proportion, is_equal_length, is_df_with_no_na_level, is_df_with_nlevels_factor, is_variables, is_df_with_variables, is_df_with_factors, is_valid_factor use assertion logic. Added verbose warnings as_factor_keep_attributes. Made assert_df_with_factors assert_proportion_value internal functions. Renamed assertthat.R test-assertthat.R utils_checkmate.R test-utils_checkmate.R.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"documentation-and-namespace-polishing-0-7-10","dir":"Changelog","previous_headings":"","what":"Documentation and NAMESPACE Polishing","title":"tern 0.7.10","text":"count_abnormal_by_marked (reference abnormal_by_marked), count_abnormal_lab_worsen_by_baseline h_adlb_worsen (reference abnormal_by_worst_grade_worsen_from_baseline), count_abnormal_by_worst_grade (reference abnormal_by_worst_grade), to_string_matrix, tidy.summary.coxph, tidy.step, surv_timepoint, (reference survival_timepoint), surv_time (reference survival_time), coxph_pairwise (reference survival_coxph_pairwise), extract_survival_subgroups tabulate_survival_subgroups (reference survival_duration_subgroups), extract_survival_biomarkers tabulate_survival_biomarkers (reference survival_biomarkers_subgroups), control_summarize_vars, s_summary a_summary (reference summarize_variables) kept S3 method tree. summarize_patients_exposure_in_cols, summarize_num_patients s_num_patients, s_num_patients_content, summarize_num_patients. count_cumulative, count_missed_doses, count_patients_events_in_cols, summarize_colvars, summarize_change, summarize_ancova,.rtable, color_palette, add_footnotes. (statistical function controls) control_coxreg, control_coxph, control_incidence_rate, control_lineplot_vars, control_surv_time, control_surv_timepoint, control_logisitic, control_step. stat_mean_ci, stat_median_ci, split_cols_by_groups, explicit_na, sas_na, extract_rsp_subgroups, tabulate_rsp_subgroups, extract_rsp_biomarkers, tabulate_rsp_biomarkers, keep_rows, keep_content_rows, has_count_in_any_col, has_fraction_in_cols, has_fraction_in_any_col, has_fractions_difference, test_proportion_diff, pairwise, logistic_regression, estimate_incidence_rate, control_incidence_rate (reference incidence_rate), cut_quantile_bins, estimate_multinomial_rsp, decorate_grob_set, extreme_format, fit_rsp_step, fit_survival_step, footnotes, footnotes-set, format_count_fraction, format_fraction_threshold, formatting_functions, format_fraction, combination_function (S4 method), compare_variables (S3 method), kaplan_meier. (chain functions, reference abnormal_by_marked) s_count_abnormal_by_marked, a_count_abnormal_by_marked. (chain functions, reference abnormal_by_worst_grade_worsen_from_baseline) a_count_abnormal_lab_worsen_by_baseline, s_count_abnormal_lab_worsen_by_baseline. (chain functions, reference abnormal_by_worst_grade) s_count_abnormal_by_worst_grade, a_count_abnormal_by_worst_grade. (chain functions, reference survival_timepoint) s_surv_timepoint, s_surv_timepoint_diff, a_surv_timepoint, a_surv_timepoint_diff. (chain functions, reference survival_time) s_surv_time, a_surv_time. (chain functions, reference survival_coxph_pairwise) s_coxph_pairwise, a_coxph_pairwise. (chain functions, reference survival_duration_subgroups) a_survival_subgroups. (chain functions, reference count_cumulative) s_count_cumulative, a_count_cumulative. (chain functions, reference count_missed_doses) s_count_nonmissing, s_count_missed_doses, a_count_missed_doses. (chain functions, reference count_patients_events_in_cols) s_count_patients_and_multiple_events, summarize_patients_events_in_cols. (chain functions, reference incidence_rate) s_incidence_rate, a_incidence_rate. (cox regression helper) cox_regression_inter, decorate_grob_factory, draw_grob, estimate_coef. summary_labels, summary_formats, s_count_patients_sum_exposure, a_change_from_baseline s_change_from_baseline, a_ancova, s_ancova, arrange_grobs, as_factor_keep_attributes, combine_levels, split_text_grob, groups_list_to_df, s_cox_multivariate, is_leaf_table, a_response_subgroups, range_noinf, has_count_in_cols, has_counts_difference, prop_chisq, prop_cmh, prop_schouten, prop_fisher, s_test_proportion_diff, a_test_proportion_diff, fct_discard, fct_explicit_na_if.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-7-10","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.10","text":"Fixed retrieval method stats::ancova output due version inconsistency. Fixed tests respect new standard print NA coming rtables. Fixed error tests coming changes formatters::var_labels. Fixed prop_diff functions respect success responses (TRUE values). Fixed error coming comparing factors vector characters vector. Fixed empty vector exception cut_quantile_bins. Fixed exception error empty strings present pivoted columns (rtables split functions) Fixed bug s_ancova causing error first level arm factor control arm. Fixed bug s_abnormal_by_worst_grade one PARAM level. Fixed bug prop_diff_wald selecting responders, updated tests accordingly. Fixed bug h_ancova caused error deselecting covariates.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-10","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.10","text":"Added deprecated badge g_mmrm. Removed internal function calls examples (tern:::) added dontrun internal function examples. Removed warnings messages console occurring examples tests. Deprecated functions color_palette h_set_nest_theme favor nestcolor::color_palette nestcolor::theme_nest, respectively. Removed deprecated functions: color_palette, color_palette_core, h_set_nest_theme, s_cox_univariate. Removed deprecated MMRM functions: fit_mmrm, g_mmrm_diagnostic, g_mmrm_lsmeans, .rtable.mmrm, h_mmrm_fixed, h_mmrm_cov, h_mmrm_diagnostic, tidy.mmrm, s_mmrm_lsmeans, s_mmrm_lsmeans_single, summarize_lsmeans. Renamed functions arm study_arm extract extract_by_name. Renamed rtables.R utils_rtables.R. Extracted cox_regression_inter separate file cox_regression. Renamed estimate_incidence_rate.R incidence_rate.R match documentation grouping name. Extracted control_incidence_rate separate file produces separate documentation file. Added @md removed @order incidence_rate.R. Modified examples accordingly. Removed hyperlink prop_schouten function documentation. Exported draw_grob function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"fix-0-7-8","dir":"Changelog","previous_headings":"","what":"Fix","title":"tern 0.7.8","text":"h_split_by_subgroups documentation warning fix wrong placing example block","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"documentation-and-namespace-polishing-0-7-8","dir":"Changelog","previous_headings":"","what":"Documentation and NAMESPACE polishing","title":"tern 0.7.8","text":"Adopting standard badges @description instead every @descriptionIn function. Corrected accordingly summarize_variables_in_cols Added stable badge g_lineplot, g_step, g_waterfall, cox_regression, score_occurrences, add_rowcounts, odds_ratio, count_occurrences, count_occurrences_by_grade, explicit_na, df_explicit_na, count_patients_with_event, decorate_grob, combine_groups, append_varlabels, univariate, stack_grobs, count_abnormal (reference abnormal), count_abnormal_by_baseline (reference abnormal_by_baseline). (helper functions) h_format_row, h_map_for_count_abnormal (utils functions) make_names, month2day, day2month empty_vector_if_na, aesi_label, n_available, format_xx, arm. count_values_funs, prop_difference, combine_counts. (chain functions) s_count_abnormal, a_count_abnormal. (chain functions) s_count_abnormal_by_baseline, a_count_abnormal_by_baseline, d_count_abnormal_by_baseline. Deprecated s_cox_univariate function now deprecated badge.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-8","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.8","text":"Enhanced g_lineplot table automatically scale table height return ggplot object. Enhanced g_ipp caption argument adjust position. Enhanced prop_diff, tern function related functions able apply continuity correction Newcombe method. Enhanced summarize_numeric_in_columns summarize_variables allow factor/character summary able summarize number BLQs AVALC ADPC dataset. Updated order summarize variables stats manual order consistency. Added sum option summarize_variables. Use consistent color palette plotting (stream default). Enhanced h_pkparam_sort function argument key_var allow data different column names.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-8","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.8","text":"Updated test-table_aet02.R variant 12. Changed scda data version ‘2022-02-28’. Added template pkgdown site. Removed package dependencies grDevices, stringr, viridisLite. Renaming summarize_numeric_in_columns summarize_variables_in_columns. Renaming summarize_vars_numeric_in_cols summarize_vars_in_cols. Fixed bug points g_lineplot plot connected missing values. Updated package authors.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"breaking-changes-0-7-7","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tern 0.7.7","text":"Move MMRM separate package tern.mmrm.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-7-7","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.7","text":"Added h_pkparam_sort order PK PARAM value based order dataset generated d_pkparam(). Added d_pkparam generate PK parameter map sorting.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-7","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.7","text":"Changed nudge_y argument h_g_ipp dependent data, fixing issue whereby baseline labels offset incorrectly. Enhanced stat_mean_ci s_summary.numeric calculate geometric mean confidence intervals.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-7","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.7","text":"Updated dependencies internal adjustments rtables package refactor. Removed with_label, var_labels, var_labels<- resolve conflict formatters package, new dependency. Added new “Introduction tern” “tern tabulation” vignettes.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-7-6","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.6","text":"Added h_map_for_count_abnormal create map used trim_levels_to_map split function calling helper function. supports two methods: one observed mapping, one least low limit zero least one non missing high limit. Added s_summary_numeric_in_cols summarize_vars_numeric_in_cols functions generate summary statistics columns, mainly used PK datasets. Added five statistics s_summary.numeric use s_summary_numeric_in_cols.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-6","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.6","text":"Enhanced functions tabulate_survival_subgroups tabulate_rsp_subgroups (Survival Duration Best Response analyses) calculate N-s based records considered create model. Enhanced function estimate_proportion related functions able apply continuity correction Wilson method. Refactored count_abnormal_by_marked related statistics formatting functions use efficient layout .spl_context argument used determining denominators trim_levels_to_map split function split_rows_by show desired levels table. breaking change. Refactored count_abnormal_by_worst_grade related statistics formatting functions use efficient layout .spl_context argument used determining denominators trim_levels_to_map split function split_rows_by show desired levels table. breaking change. Refactored count_abnormal function related statistics formatting functions use efficient layout trim_levels_to_map split function split_rows_by show desired levels table. Also updated abnormal argument able consider one level direction. breaking change. Enhanced function estimate_incidence_rate related functions consider week time unit data input.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-7-6","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tern 0.7.6","text":"Fixed bug assertthat functions output wrong data frame names limited length failure message outputs.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-6","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.6","text":"Removed dependency utils.nest using checkmate purrr packages validation moved get_free_cores skip_if_too_deep functions utils.nest tern.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-7-5","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.5","text":"Added functions estimate continuous biomarker effects across subgroups survival binary response endpoints, used produce corresponding forest plots, see survival_biomarkers_subgroups response_biomarkers_subgroups. Added g_lineplot plot function, including new h_format_row helper function control_lineplot_vars function. Removed g_summary_by. Added new safety helper function h_stack_by_baskets stack events SMQ /CQ basket flag ADAE data set.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.5","text":"Added couple new statistics s_summary.numeric. Added names attribute element final list returned s_summary.numeric function. Added summary_formats summary_labels helper functions. Added option also convert logical variables factor variables df_explicit_na. Refactored h_append_grade_groups improve flexibility, robustness clearness, make sure result ordering according order grade_groups. Also, added remove_single argument controls whether elements one-element grade groups output removed. Added var_labels show_labels arguments count_occurrences count_patients_with_flags allow creation title row. Added na_level argument count_abnormal_by_baseline. Updated h_append_grade_groups longer fill-empty grade groups zeros.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-7-5","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.5","text":"Fixed prop_diff_cmh handle edge case FALSE (TRUE) responses. Enhanced g_mmrm_diagnostic improve error handling data amenable Locally Weighted Scatterplot Smoothing. Plot can now display combination annotation tables number patients risk, median survival time, Cox-PH summary. Function return warning instead error arm variable includes single level annot_coxph = TRUE. Lines plot now start time 0 probability 1. Category labels can include equals sign.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-5","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.5","text":"Fixed day2month month2day work NA data. Added parameters stat_mean_ci stat_median_ci may return different outputs. Added functionality h_row_counts handle analysis rows NULL cells. Updated LICENCE README new package references. Added error_on_lint: TRUE .lintr.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-7-4","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.4","text":"count_abnormal_by_marked tabulates marked laboratory abnormalities. summarize_patients_exposure_in_cols tabulates patient counts sum exposure across patients.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.4","text":"Enhanced MMRM-related functions fitting models without arm variable. Updated cox_regression work without covariates. Also case interaction model summary, p-values main effect coefficients longer displayed. Descriptive statistics returned summarize_vars now include quantiles. summarize_vars now accepts control function control_summarize_vars specify details confidence level mean median quantile details. control argument replaces conf_level. Added var_labels show_labels arguments count_occurrences_by_grade. Changed indent argument append_varlabels accept non-negative integer represent indent space defined user. Previous calls Boolean indent integer conversion produce warning.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-7-4","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.4","text":"Corrected tabulate_survival_subgroups related survival forest plot functions use total number events, instead observations, default scaling symbol sizes plot. (user might still use total number observations manually wish .) Helper function h_adsl_adlb_merge_using_worst_flag now impute BTOXGR missing visits.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-4","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.4","text":"Deleted count_abnormal_by_worst_grade_by_baseline related statistic analysis functions simpler design create lab abnormality tables. Switched data examples use scda instead random.cdisc.data package.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-features-0-7-3","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.7.3","text":"Added Subgroup Treatment Effect Pattern (STEP) model fitting functions fit_rsp_step fit_survival_step, corresponding tidy method tidy.step well graph function g_step. Added new layout function compare_vars compares variables different types columns produces p-value comparison reference column. Function built top summarize_vars functionality. cut_quantile_bins cuts numeric vector quantile bins. fct_collapse_only collapses levels factor keeps order provided. fct_explicit_na_if inserts explicit missings factor based condition. range_noinf kind wrapper function base::range. returns c(NA, NA) instead c(-Inf, Inf) zero-length data.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"enhancements-0-7-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.3","text":"Cox regression via fit_coxreg_univar fit_coxreg_multivar now also possible without treatment arm. univariate case means fits separate univariate models provided covariates tabulation corresponding effect estimates can later occur. Added fraction result returned s_count_occurrences. contains list numerators denominators one element per occurrence. Updated sum_num_patients count_occurrences result unique count_fraction return (0, 0) input empty. Added new argument groups_lists extract_survival_subgroups, extract_rsp_subgroups associated helper functions allows group factor levels subgroup variables manually defined groups, enhancing flexibility resulting forest graphs. Forest graph function g_forest now extracts default arguments attributes input table produced tabulate_rsp_subgroups tabulate_survival_subgroups user manually anymore. Remove arm variable name arm labels plot legend annotation tables. Show symbol used mark censored cases match order arm variable factor levels legend. Display hazard ratio confidence interval two decimal places. Updated default position hazard ratio table stay left bottom corner x-axis. Use arm value strata name treatment arm variable single level. Updated s_surv_time function use newly created function range_noinf instead base::range. New argument no_fillin_visits added h_adsl_adlb_merge_using_worst_flag specify excluded visits post-baseline worst toxicity grade output. Improved h_adsl_adlb_merge_using_worst_flag include variables shared adsl adlb, along PARAM, PARAMCD, ATOXGR, BTOXGR optionally AVISIT, AVISITN by_visit = TRUE. Prior output contained USUBJID, ARMCD, PARAMCD, ATOXGR, BTOXGR.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"bug-fixes-0-7-3","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.3","text":"Fix bug s_surv_timepoint cases zero patients risk. Modified stat_median_ci function passing empty var empty name, row names contain missing values error show.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"miscellaneous-0-7-3","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.3","text":"Deprecated s_cox_univariate function, use fit_coxreg_univar function instead. Updated default formats hr hr_ci a_coxph_pairwise median s_surv_time align STREAM. Updated pre-processing code files test-table_ttet01.R test-table_dort01.R make sure analysis variable EVNT1 levels factor defined. Improved error message number levels factor variable data frame expected.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-072","dir":"Changelog","previous_headings":"","what":"tern 0.7.2","title":"tern 0.7.2","text":"Fixed column label internal test errors.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-071","dir":"Changelog","previous_headings":"","what":"tern 0.7.1","title":"tern 0.7.1","text":"New argument position_surv_med added g_km move position annotation table median survival times. Fixed bug g_km related ignored arguments pch size passed helper function h_ggkm. Updated xticks max_time arguments g_km greater functionality. max_time added argument h_xticks allow . Fixed bug prop_diff_cmh led NaN weighted proportion difference estimates missing confidence intervals. change, including patients one treatment arm least one stratum estimation lead numeric results. Fixed bug prop_cmh giving error case least one stratum containing less two observations. New argument n_events added estimate_incidence_rate. New argument denom added count_occurrences. New arguments yval ci_ribbon added g_km. Add new individual patient plot function g_ipp along helpers h_g_ipp h_set_nest_theme. Fixed bug count_patients_with_events, now shows zero counts without percentage. Fixed bug get_mmrm_lsmeans allow MMRM analysis 3000 observations. Updated stat_mean_ci stat_median_ci handle edge cases number elements input series equal 1. cases, NA_real_ now returned, instead NA +/-Inf confidence interval (CI) estimates. Rename n_lim argument stat_mean_ci n_min better reflect desired meaning.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-070","dir":"Changelog","previous_headings":"","what":"tern 0.7.0","title":"tern 0.7.0","text":"version tern introduces major rewriting tern due change layout based tabulation rtables. tern now build tables directly anymore, instead provides analysis functions build tables, see examples. * Counting patients abnormal values post-baseline count_abnormal. * Counting patients graded abnormal values count_abnormal_by_worst_grade. * Counting patients abnormal values baseline status count_abnormal_by_baseline. * Counting patients missed doses s_count_missed_doses count_missed_doses. * Counting patients event flags count_patients_with_event count_patients_with_flags. * Summarizing variables summarize_vars (supports numeric, factor, character logical variables). Note factors need NAs converted na_level use. * Summarizing change baseline summarize_change. * Summarizing variables columns summarize_colvars. * Estimating difference responder proportions estimate_proportion_diff. * Estimating difference Odds Ratio estimate_odds_ratio. * Testing difference responder proportions test_proportion_diff. * Estimating responder proportion level factor estimate_multinomial_response. * Fitting tabulating results Cox regressions fit_coxreg_univar, fit_coxreg_multivar summarize_coxreg, respectively. * Pruning occurrence tables (tables counts fractions) flexible rules, see ?prune_occurrences details. * Sorting occurrence tables using different options, see ?score_occurrences details. * Fitting tabulating MMRM models fit_mmrm .rtable summarize_lsmeans, see ?tabulate_mmrm details. * Counting number unique non-unique patients summarize_num_patients. * Counting occurrences count_occurrences. * Counting occurrences grade summarize_occurrences_by_grade count_occurrences_by_grade. * Counting patients events columns summarize_patients_events_in_cols. * Tabulating binary outcome response subgroup extract_rsp_subgroups tabulate_rsp_subgroups. * Tabulating survival duration subgroup extract_survival_subgroups tabulate_survival_subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-069","dir":"Changelog","previous_headings":"","what":"tern 0.6.9","title":"tern 0.6.9","text":"Removing used imports.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-068","dir":"Changelog","previous_headings":"","what":"tern 0.6.8","title":"tern 0.6.8","text":"Improved handling missing data aggregation functions: a_mean_sd, a_median, a_n_true_and_freq, a_count, a_q1q3, a_iqr, a_range. New default p-value method s_test_proportion_diff: Chi-Squared Test Schouten Correction. Add new function t_contingency contingency tables. Renamed class splitText dynamicSplitText resolve name conflict package ggpubr. Add rreplace_format tabulation post-processing. Add new tern function t_ancova create ANCOVA tables, well corresponding elementary table function t_el_ancova summary function s_ancova. Add new tern function s_odds_ratio estimate Odds Ratio response categories, well corresponding elementary table function t_el_odds_ratio. Added new CI methods (agresti-coull, jeffreys) s_proportion. Added new CI methods anderson-hauck newcombe s_proportion_diff. Added new p-value methods (Fisher’s Exact, Chi-Squared Test Schouten Correction) s_test_proportion_diff. binary summary table function t_binary_outcome takes now lists (instead character vectors) specified helper function control_binary_comparison arguments strat_analysis unstrat_analysis. Odds Ratio estimates CIs now removable included default, similarly subsections arm comparison analyses. Also added argument rsp_multinomial. Add new table function t_el_multinomial_proportion. Add new table function t_abn_shift. Add new MMRM analysis function s_mmrm, well corresponding table functions t_mmrm_lsmeans, t_mmrm_cov, t_mmrm_diagnostic, t_mmrm_fixed, plot functions g_mmrm_lsmeans, g_mmrm_diagnostic. results match SAS results (numeric precision). Deprecated old MMRM functions a_mmrm t_mmrm (give deprecation warning still work) remove next release. reason results functions don’t match SAS results. Fix bug g_km related numbers patients risk table correct numbers integer time--event variable inputs.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-067","dir":"Changelog","previous_headings":"","what":"tern 0.6.7","title":"tern 0.6.7","text":"functions row_by argument, inputs longer require use nested_by. Add stat_mean_ci stat_median_ci error bars ggplot2. Add new tern function t_coxreg single interface diverse cox regression types. Add compound table binary endpoint: t_binary_endpoint elementary functions: t_el_proportion, t_el_proportion_diff t_el_test_proportion_diff. supporting summary functions added : s_proportion, s_adj_proportion_diff, s_proportion_diff s_test_proportion_diff. Added new tern function t_events_patyear create event table adjusted person-years. Added new tern function t_abnormality elementary table function t_el_abnormality. Removed grade_levels argument t_events_term_grade_id functions. Post-processing reordering leaves table tree creates different ordering rows required. Creating helper function occur later time. Added prune_zero_rows argument t_events_per_term_grade_id t_max_grade_per_id show rows zeros can clutter visualization Shiny app make slower. Fixed position (N=xx) t_summary_by output summarizing numeric columns parallel compare_in_header. Rename t_coxph t_coxph_pairwise reflect model process, add details documentation. Remove test.nest dependency. Keep column labels splitting data tree.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-066","dir":"Changelog","previous_headings":"","what":"tern 0.6.6","title":"tern 0.6.6","text":"Remove test.nest dependency.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-065","dir":"Changelog","previous_headings":"","what":"tern 0.6.5","title":"tern 0.6.5","text":"Change default option denominator N t_summary. Fix IQR bug: IQR Q3 minus Q1. Add new function t_logistic multi-variable logistic regression table. Add new function df_explicit_na replace NA explicit values. Added possibility t_tte specify confidence level independent survfit, coxph, ztest, see manual. Fixed bug t_rsp showing p-value, odds ratio CIs strata_data NULL. Added stratified analysis t_forest_rsp t_forest_tte, footnotes g_forest. Added footnotes, footnotes<- add_footnotes<- functions deal footnotes. Added argument conf_int confidence interval level t_el_forest_rps, t_forest_rsp, t_el_forest_tte, t_forest_tte. Added argument col_symbol_size g_forest control relative size symbols used plot. Added s_coxph_pairwise function perform pairwise testing, used t_tte t_coxph. Added methods t_count_true replacing t_summary_true. Updated t_count_unique create analysis subsets, added t_el_count_unique vectors. Fixed bug t_events_term_id table sort order decreasing frequency instead alphabetical. Added function color_palette new nest color palette.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-064","dir":"Changelog","previous_headings":"","what":"tern 0.6.4","title":"tern 0.6.4","text":"Refactored renaming functions utils.nest. Added event_type argument t_events_per_term_grade_id. Added one/two-arm t-test functions. Improvements t_summary_by. Internal code refactoring.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-063","dir":"Changelog","previous_headings":"","what":"tern 0.6.3","title":"tern 0.6.3","text":"related tree functions see reference trees. Moved label functions rtables. Deleted keys keys<- functions. Exported tabulate_pairwise. get_N, col_N_add_total, check_id. na_as_level. as_factor_keep_attributes. r_by. Disposition elementary table t_el_disposition. t_el_forest_tte, t_el_forest_rsp. Added table_tree argument returns node object. Added f_numeric choose statistics calculate. denominator now also allows omit wanting omit percentages. Renamed row_by. Changed functionality group_data using row_by_list. Removed na_omit_group. Removed indent argument, use indent function rtables. instead","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-062","dir":"Changelog","previous_headings":"","what":"tern 0.6.2","title":"tern 0.6.2","text":"Use cached data random.cdisc.data speed testing. Added t_summary.Date method. Added save_join.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-061","dir":"Changelog","previous_headings":"","what":"tern 0.6.1","title":"tern 0.6.1","text":"Fixed colors Kaplan-Meier Plot Changed width_row.names argument g_forest function width_row_names. Changed censor.show argument g_km function censor_show. Changed col.legend.title argument g_waterfall function col_legend_title. Changed na.rm argument t_count_unique function na_rm. Changed row.name argument t_count_unique function row_name. Changed na.omit.group argument t_forest_rsp function na_omit_group. Changed na.omit.group argument t_forest_tte function na_omit_group. Changed row.name.TRUE row.name.FALSE arguments t_summary.logical row_name_true row_name_false respectively. Rename splotTextGrob split_text_grob. Fix examples. Refactor internal functions code.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-060","dir":"Changelog","previous_headings":"","what":"tern 0.6.0","title":"tern 0.6.0","text":"Removed functions addTable, t_summarize_by_visit, t_summarize_variables. Added t_summary_by function. Refactor g_km function, renamed kmGrob kmCurveGrob. Refactor t_events_* family functions. Updated examples.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-tlgs-0-5-0-3","dir":"Changelog","previous_headings":"","what":"New TLGs","title":"tern 0.5.0.3","text":"t_summary methods data.frame, numeric, logical, character, factor, Date objects. t_events_per_term_id, t_events_per_term_grade_id: Adverse Events & Concomitant Treatment Tables. t_max_grade_per_id, t_count_unique, t_events_summary elementary tables used Adverse Events & Concomitant Treatment Tables. g_waterfall: Horizontal Waterfall Plot.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"new-helper-functions-0-5-0-3","dir":"Changelog","previous_headings":"","what":"New Helper Functions","title":"tern 0.5.0.3","text":"decorate_grob, decorate_grob_set, decorate_grob_factory, splitTextGrob. stack_grobs, arrange_grobs, draw_grob.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tlg-changes-0-5-0-3","dir":"Changelog","previous_headings":"","what":"TLG changes","title":"tern 0.5.0.3","text":"t_tte now shows two rows ranges event censored times, respectively. g_km works one arm survfit objects. forest plot functions, added formatting display extreme values “>999.9”. t_summarise_variables uses now n instead N denominator calculating percentages factors default. t_rsp now works response values TRUE FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"deprecated-functions-0-5-0-3","dir":"Changelog","previous_headings":"","what":"Deprecated Functions","title":"tern 0.5.0.3","text":"Deprecated t_summarize_variables t_summary powerful. Replacing t_summarize_by_visit t_summary_by occur upcoming release.","code":""},{"path":"https://insightsengineering.github.io/tern/news/index.html","id":"tern-050","dir":"Changelog","previous_headings":"","what":"tern 0.5.0","title":"tern 0.5.0","text":"First version harmonized analysis functions names arguments.","code":""}] +[{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement [INSERT CONTACT METHOD]. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired Mozilla’s code conduct enforcement ladder. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contribution Guidelines","title":"Contribution Guidelines","text":"🙏 Thank taking time contribute! input deeply valued, whether issue, pull request, even feedback, regardless size, content scope.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"table-of-contents","dir":"","previous_headings":"","what":"Table of contents","title":"Contribution Guidelines","text":"👶 Getting started 📔 Code Conduct 🗃 License 📜 Issues 🚩 Pull requests 💻 Coding guidelines 🏆 Recognition model ❓ Questions","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Contribution Guidelines","text":"Please refer project documentation brief introduction. Please also see articles within project documentation additional information.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contribution Guidelines","text":"Code Conduct governs project. Participants contributors expected follow rules outlined therein.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"license","dir":"","previous_headings":"","what":"License","title":"Contribution Guidelines","text":"contributions covered project’s license.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"issues","dir":"","previous_headings":"","what":"Issues","title":"Contribution Guidelines","text":"use GitHub track issues, feature requests, bugs. submitting new issue, please check issue already reported. issue already exists, please upvote existing issue 👍. new feature requests, please elaborate context benefit feature users, developers, relevant personas.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"github-flow","dir":"","previous_headings":"Pull requests","what":"GitHub Flow","title":"Contribution Guidelines","text":"repository uses GitHub Flow model collaboration. submit pull request: Create branch Please see branch naming convention . don’t write access repository, please fork . Make changes Make sure code passes checks imposed GitHub Actions well documented well tested unit tests sufficiently covering changes introduced Create pull request (PR) pull request description, please link relevant issue (), provide detailed description change, include assumptions. Address review comments, Post approval Merge PR write access. Otherwise, reviewer merge PR behalf. Pat back Congratulations! 🎉 now official contributor project! grateful contribution.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"branch-naming-convention","dir":"","previous_headings":"Pull requests","what":"Branch naming convention","title":"Contribution Guidelines","text":"Suppose changes related current issue current project; please name branch follows: _. Please use underscore (_) delimiter word separation. example, 420_fix_ui_bug suitable branch name change resolving UI-related bug reported issue number 420 current project. change affects multiple repositories, please name branches follows: __. example, 69_awesomeproject_fix_spelling_error reference issue 69 reported project awesomeproject aims resolve one spelling errors multiple (likely related) repositories.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"monorepo-and-stageddependencies","dir":"","previous_headings":"Pull requests","what":"monorepo and staged.dependencies","title":"Contribution Guidelines","text":"Sometimes might need change upstream dependent package(s) able submit meaningful change. using staged.dependencies functionality simulate monorepo behavior. dependency configuration already specified project’s staged_dependencies.yaml file. need name feature branches appropriately. exception branch naming convention described . Please refer staged.dependencies package documentation details.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"coding-guidelines","dir":"","previous_headings":"","what":"Coding guidelines","title":"Contribution Guidelines","text":"repository follows unified processes standards adopted maintainers ensure software development carried consistently within teams cohesively across repositories.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"style-guide","dir":"","previous_headings":"Coding guidelines","what":"Style guide","title":"Contribution Guidelines","text":"repository follows standard tidyverse style guide uses lintr lint checks. Customized lint configurations available repository’s .lintr file.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"dependency-management","dir":"","previous_headings":"Coding guidelines","what":"Dependency management","title":"Contribution Guidelines","text":"Lightweight right weight. repository follows tinyverse recommedations limiting dependencies minimum.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"dependency-version-management","dir":"","previous_headings":"Coding guidelines","what":"Dependency version management","title":"Contribution Guidelines","text":"code compatible (!) historical versions given dependenct package, required specify minimal version DESCRIPTION file. particular: development version requires (imports) development version another package - required put abc (>= 1.2.3.9000).","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"r--package-versions","dir":"","previous_headings":"Coding guidelines > Recommended development environment & tools","what":"R & package versions","title":"Contribution Guidelines","text":"continuously test packages newest R version along recent dependencies CRAN BioConductor. recommend working environment also set way. can find details R version packages used R CMD check GitHub Action execution log - step prints R sessionInfo(). discover bugs older R versions older set dependencies, please create relevant bug reports.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"pre-commit","dir":"","previous_headings":"Coding guidelines > Recommended development environment & tools","what":"pre-commit","title":"Contribution Guidelines","text":"highly recommend use pre-commit tool combined R hooks pre-commit execute checks committing pushing changes. Pre-commit hooks already available repository’s .pre-commit-config.yaml file.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"recognition-model","dir":"","previous_headings":"","what":"Recognition model","title":"Contribution Guidelines","text":"mentioned previously, contributions deeply valued appreciated. contribution data available part repository insights, recognize significant contribution hence add contributor package authors list, following rules enforced: Minimum 5% lines code authored* (determined git blame query) top 5 contributors terms number commits lines added lines removed* *Excluding auto-generated code, including limited roxygen comments renv.lock files. package maintainer also reserves right adjust criteria recognize contributions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/CONTRIBUTING.html","id":"questions","dir":"","previous_headings":"","what":"Questions","title":"Contribution Guidelines","text":"questions regarding contribution guidelines, please contact package/repository maintainer.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/SECURITY.html","id":"reporting-security-issues","dir":"","previous_headings":"","what":"Reporting Security Issues","title":"Security Policy","text":"believe found security vulnerability repositories organization, please report us coordinated disclosure. Please report security vulnerabilities public GitHub issues, discussions, pull requests. Instead, please send email vulnerability.management[@]roche.com. Please include much information listed can help us better understand resolve issue: type issue (e.g., buffer overflow, SQL injection, cross-site scripting) Full paths source file(s) related manifestation issue location affected source code (tag/branch/commit direct URL) special configuration required reproduce issue Step--step instructions reproduce issue Proof--concept exploit code (possible) Impact issue, including attacker might exploit issue information help us triage report quickly.","code":""},{"path":"https://insightsengineering.github.io/tern/main/SECURITY.html","id":"data-security-standards-dss","dir":"","previous_headings":"","what":"Data Security Standards (DSS)","title":"Security Policy","text":"Please make sure reporting issues form bug, feature, pull request, sensitive information PII, PHI, PCI completely removed text attachments, including pictures videos.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/missing_values.html","id":"variable-class-conversion","dir":"Articles","previous_headings":"","what":"Variable Class Conversion","title":"Missing Values in Tern","text":"rtables requires split variables factors. try split variable isn’t, warning message appear. purposefully convert SEX variable character demonstrate happens try splitting rows variable. fix , df_explict_na convert factor resulting table generated.","code":"adsl <- tern_ex_adsl adsl$SEX <- as.character(adsl$SEX) vars <- c(\"AGE\", \"SEX\", \"RACE\", \"BMRKR1\") var_labels <- c( \"Age (yr)\", \"Sex\", \"Race\", \"Continous Level Biomarker 1\" ) result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures #> Warning in as_factor_keep_attributes(x, verbose = verbose): automatically #> converting character variable x to factor, better manually convert to factor to #> avoid failures result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 69 73 58 200 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) 35.3 (7.1) #> Median 32.8 35.4 36.2 34.8 #> Min - Max 22.4 - 48.0 23.3 - 57.5 23.0 - 58.3 22.4 - 58.3 #> Sex #> n 69 73 58 200 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) 110 (55%) #> M 31 (44.9%) 33 (45.2%) 26 (44.8%) 90 (45%) #> Race #> n 69 73 58 200 #> ASIAN 38 (55.1%) 43 (58.9%) 29 (50%) 110 (55%) #> BLACK OR AFRICAN AMERICAN 15 (21.7%) 13 (17.8%) 12 (20.7%) 40 (20%) #> WHITE 11 (15.9%) 12 (16.4%) 11 (19%) 34 (17%) #> AMERICAN INDIAN OR ALASKA NATIVE 4 (5.8%) 3 (4.1%) 6 (10.3%) 13 (6.5%) #> MULTIPLE 1 (1.4%) 1 (1.4%) 0 2 (1%) #> NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (1.4%) 0 1 (0.5%) #> OTHER 0 0 0 0 #> UNKNOWN 0 0 0 0 #> Continous Level Biomarker 1 #> n 69 73 58 200 #> Mean (SD) 6.3 (3.6) 6.7 (3.5) 6.2 (3.3) 6.4 (3.5) #> Median 5.4 6.3 5.4 5.6 #> Min - Max 0.4 - 17.8 1.0 - 18.5 2.4 - 19.1 0.4 - 19.1"},{"path":"https://insightsengineering.github.io/tern/main/articles/missing_values.html","id":"including-missing-values-in-rtables","dir":"Articles","previous_headings":"","what":"Including Missing Values in rtables","title":"Missing Values in Tern","text":"purposefully convert M values NA SEX variable. running df_explicit_na NA values encoded included table. well, missing values included n count included denominator value calculating percent values. want Na values displayed table included n count denominator calculating percent values, use na_level argument.","code":"adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl) vars <- c(\"AGE\", \"SEX\") var_labels <- c( \"Age (yr)\", \"Sex\" ) result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ——————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 69 73 58 200 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) 35.3 (7.1) #> Median 32.8 35.4 36.2 34.8 #> Min - Max 22.4 - 48.0 23.3 - 57.5 23.0 - 58.3 22.4 - 58.3 #> Sex #> n 38 40 32 110 #> F 38 (100%) 40 (100%) 32 (100%) 110 (100%) #> M 0 0 0 0 adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl, na_level = \"Missing Values\") result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ———————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 69 73 58 200 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) 35.3 (7.1) #> Median 32.8 35.4 36.2 34.8 #> Min - Max 22.4 - 48.0 23.3 - 57.5 23.0 - 58.3 22.4 - 58.3 #> Sex #> n 69 73 58 200 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) 110 (55%) #> M 0 0 0 0 #> Missing Values 31 (44.9%) 33 (45.2%) 26 (44.8%) 90 (45%)"},{"path":"https://insightsengineering.github.io/tern/main/articles/missing_values.html","id":"missing-values-in-numeric-variables","dir":"Articles","previous_headings":"","what":"Missing Values in Numeric Variables","title":"Missing Values in Tern","text":"Numeric variables missing values altered. means NA value numeric variable included summary statistics, included denominator value calculating percent values. make value less 30 missing AGE variable valued greater 30 included table .","code":"adsl <- tern_ex_adsl adsl$AGE[adsl$AGE < 30] <- NA adsl <- df_explicit_na(adsl) vars <- c(\"AGE\", \"SEX\") var_labels <- c( \"Age (yr)\", \"Sex\" ) result <- basic_table(show_colcounts = TRUE) %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) result #> A: Drug X B: Placebo C: Combination All Patients #> (N=69) (N=73) (N=58) (N=200) #> ——————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 46 56 44 146 #> Mean (SD) 37.8 (5.2) 38.3 (6.3) 39.1 (5.9) 38.3 (5.8) #> Median 37.2 37.3 37.5 37.5 #> Min - Max 30.3 - 48.0 30.0 - 57.5 30.5 - 58.3 30.0 - 58.3 #> Sex #> n 69 73 58 200 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) 110 (55%) #> M 31 (44.9%) 33 (45.2%) 26 (44.8%) 90 (45%)"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"tern-tabulation","dir":"Articles","previous_headings":"","what":"tern Tabulation","title":"Tabulation","text":"tern R package provides functions create common analyses clinical trials R. core functionality tabulation built general purpose rtables package. New users first begin reading “Introduction tern” “Introduction rtables” vignettes. packages used vignette : datasets used vignette :","code":"library(rtables) library(tern) library(dplyr) adsl <- ex_adsl adae <- ex_adae adrs <- ex_adrs"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"tern-analyze-functions","dir":"Articles","previous_headings":"","what":"tern Analyze Functions","title":"Tabulation","text":"Analyze functions used combination rtables layout functions, pipeline creates rtables table. apply statistical logic layout rtables table. table layout materialized rtables::build_table function data. tern analyze functions wrappers around rtables::analyze function, offer various methods useful perspective clinical trials statistical projects. Examples tern analyze functions count_occurrences, summarize_ancova analyze_vars. one prefix identify tern analyze functions recommended use tern website functions reference.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"internals-of-tern-analyze-functions","dir":"Articles","previous_headings":"tern Analyze Functions","what":"Internals of tern Analyze Functions","title":"Tabulation","text":"Please skip subsection interested internals tern analyze functions. Internally tern analyze functions like summarize_ancova mainly built 4 elements chain: descriptions function type: analysis helper functions h_*. functions useful help define analysis. statistics function s_*. Statistics functions computation numbers tabulated later. order separate computation formatting, take care rcell type formatting . formatted analysis functions a_*. arguments corresponding statistics functions, can customized calling rtables::make_afun() . used afun rtables::analyze(). analyze functions rtables::analyze(..., afun = make_afun(tern::a_*)). Analyze functions used combination rtables layout functions, pipeline creates table. last element chain. use native rtables::analyze function tern formatted analysis functions afun parameter. rtables::make_afun function helpful somebody wants attach format formatted analysis function.","code":"h_ancova() -> tern:::s_ancova() -> tern:::a_ancova() -> summarize_ancova() l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze(vars = \"AVAL\", afun = a_summary) build_table(l, df = adrs) afun <- make_afun( a_summary, .stats = NULL, .formats = c(median = \"xx.\"), .labels = c(median = \"My median\"), .indent_mods = c(median = 1L) ) l2 <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze(vars = \"AVAL\", afun = afun) build_table(l2, df = adrs)"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"tabulation-examples","dir":"Articles","previous_headings":"","what":"Tabulation Examples","title":"Tabulation","text":"going create 3 different tables using tern analyze functions rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"demographic-table","dir":"Articles","previous_headings":"Tabulation Examples","what":"Demographic Table","title":"Tabulation","text":"Demographic tables provide summary characteristics patients enrolled clinical trial. Typically table columns represent treatment arms variables summarized table demographic properties age, sex, race, etc. example function tern analyze_vars() remaining layout functions rtables. change display order categorical variables table use factor variables explicitly set order levels. case display order columns rows. Note forcats package many useful functions help types data processing steps (used ). tern package includes many functions similar analyze_vars(). functions called layout creating functions used combination rtables layout functions just like examples . Layout creating functions wrapping calls rtables analyze(), analyze_colvars() summarize_row_groups() provide options easy formatting analysis modifications. customize display demographics table, can via arguments analyze_vars(). layout creating functions tern include standard arguments .stats, .formats, .labels .indent_mods control statistics displayed numbers formatted. Refer package help help(\"analyze_vars\") ?analyze_vars see full set options. example change default summary numeric variables include number records, mean standard deviation (single statistic, .e. within single cell). categorical variables modify summary include number records counts categories. also modify display format mean standard deviation print two decimal places instead just one. One feature layout can used different datasets create different summaries. example, can easily create summary demographics Brazil China subgroups, respectively:","code":"# Select variables to include in table. vars <- c(\"AGE\", \"SEX\") var_labels <- c(\"Age (yr)\", \"Sex\") basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 134 134 132 400 #> Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) #> Median 33.0 35.0 35.0 34.0 #> Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 #> Sex #> n 134 134 132 400 #> F 79 (59%) 77 (57.5%) 66 (50%) 222 (55.5%) #> M 51 (38.1%) 55 (41%) 60 (45.5%) 166 (41.5%) #> U 3 (2.2%) 2 (1.5%) 4 (3%) 9 (2.2%) #> UNDIFFERENTIATED 1 (0.7%) 0 2 (1.5%) 3 (0.8%) # Reorder the levels in the ARM variable. adsl$ARM <- factor(adsl$ARM, levels = c(\"B: Placebo\", \"A: Drug X\", \"C: Combination\")) # Reorder the levels in the SEX variable. adsl$SEX <- factor(adsl$SEX, levels = c(\"M\", \"F\", \"U\", \"UNDIFFERENTIATED\")) basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels ) %>% build_table(adsl) #> B: Placebo A: Drug X C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 134 134 132 400 #> Mean (SD) 35.4 (7.9) 33.8 (6.6) 35.4 (7.7) 34.9 (7.4) #> Median 35.0 33.0 35.0 34.0 #> Min - Max 21.0 - 62.0 21.0 - 50.0 20.0 - 69.0 20.0 - 69.0 #> Sex #> n 134 134 132 400 #> M 55 (41%) 51 (38.1%) 60 (45.5%) 166 (41.5%) #> F 77 (57.5%) 79 (59%) 66 (50%) 222 (55.5%) #> U 2 (1.5%) 3 (2.2%) 4 (3%) 9 (2.2%) #> UNDIFFERENTIATED 0 1 (0.7%) 2 (1.5%) 3 (0.8%) # Select statistics and modify default formats. basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels, .stats = c(\"n\", \"mean_sd\", \"count\"), .formats = c(mean_sd = \"xx.xx (xx.xx)\") ) %>% build_table(adsl) #> B: Placebo A: Drug X C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ———————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 134 134 132 400 #> Mean (SD) 35.43 (7.90) 33.77 (6.55) 35.43 (7.72) 34.88 (7.44) #> Sex #> n 134 134 132 400 #> M 55 51 60 166 #> F 77 79 66 222 #> U 2 3 4 9 #> UNDIFFERENTIATED 0 1 2 3 lyt <- basic_table() %>% split_cols_by(var = \"ARM\") %>% add_overall_col(\"All Patients\") %>% add_colcounts() %>% analyze_vars( vars = vars, var_labels = var_labels ) build_table(lyt, df = adsl %>% dplyr::filter(COUNTRY == \"BRA\")) #> B: Placebo A: Drug X C: Combination All Patients #> (N=7) (N=13) (N=10) (N=30) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 7 13 10 30 #> Mean (SD) 32.0 (6.1) 36.7 (6.4) 38.3 (10.6) 36.1 (8.1) #> Median 32.0 37.0 35.0 35.5 #> Min - Max 25.0 - 42.0 24.0 - 47.0 25.0 - 64.0 24.0 - 64.0 #> Sex #> n 7 13 10 30 #> M 4 (57.1%) 8 (61.5%) 5 (50%) 17 (56.7%) #> F 3 (42.9%) 5 (38.5%) 5 (50%) 13 (43.3%) #> U 0 0 0 0 #> UNDIFFERENTIATED 0 0 0 0 build_table(lyt, df = adsl %>% dplyr::filter(COUNTRY == \"CHN\")) #> B: Placebo A: Drug X C: Combination All Patients #> (N=81) (N=74) (N=64) (N=219) #> —————————————————————————————————————————————————————————————————————————————— #> Age (yr) #> n 81 74 64 219 #> Mean (SD) 35.7 (7.3) 33.0 (6.4) 35.2 (6.4) 34.6 (6.8) #> Median 36.0 32.0 35.0 34.0 #> Min - Max 21.0 - 58.0 23.0 - 48.0 21.0 - 49.0 21.0 - 58.0 #> Sex #> n 81 74 64 219 #> M 35 (43.2%) 27 (36.5%) 30 (46.9%) 92 (42%) #> F 45 (55.6%) 44 (59.5%) 29 (45.3%) 118 (53.9%) #> U 1 (1.2%) 2 (2.7%) 3 (4.7%) 6 (2.7%) #> UNDIFFERENTIATED 0 1 (1.4%) 2 (3.1%) 3 (1.4%)"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"adverse-event-table","dir":"Articles","previous_headings":"Tabulation Examples","what":"Adverse Event Table","title":"Tabulation","text":"standard table adverse events summary system organ class preferred term. frequency counts preferred term, multiple occurrences AE individual count . create table need use combination several layout creating functions tabulation pipeline. start creating high-level summary. layout creating function tern can summarize_num_patients(): Note table, denominator used percentages shown header table (N = xx) defined based subject-level dataset adsl. done using alt_df_counts argument build_table(), provides alternative data set deriving counts header. often required work data sets include multiple records per patient df, adae .","code":"basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) #> Overall total number of events 609 622 703 1934"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"statistics-functions","dir":"Articles","previous_headings":"Tabulation Examples > Adverse Event Table","what":"Statistics Functions","title":"Tabulation","text":"building rest AE table helpful introduce tern package design conventions. layout creating function tern wrapper Statistics function. Statistics functions ones actual computation numbers table. functions always return named lists whose elements statistics available include layout via .stats argument layout creating function level. Statistics functions follow naming convention always begin s_* ease use documented page layout creating function counterpart. helpful review Statistic function understand logic used calculate numbers table see options may available modify analysis. example, Statistics function calculating numbers summarize_num_patients() s_num_patients(). results Statistics function list elements unique, nonunique unique_count: results can see unique nonunique statistics displayed “Patients” column initial AE table output . Also can see raw numbers formatted way. formatting functionality handled layout creating function level .formats argument. Now know types statistics can derived s_num_patients(), can try modifying default layout returned summarize_num_patients(). Instead reporting unique nonqunie statistics, specify analysis include unique_count statistic. result show counts unique patients. Note make update .stats .labels argument summarize_num_patients(). Let’s now continue building layout adverse event table. top-level summary, can repeat summary system organ class level. split analysis data split_rows_by() calling summarize_num_patients(). table looks almost ready. final step, need layout creating function can produce count table event frequencies. layout creating function count_occurrences(). Let’s first try using function simpler layout without row splits: Putting everything together, final AE table looks like :","code":"s_num_patients(x = adae$USUBJID, labelstr = \"\", .N_col = nrow(adae)) #> $unique #> [1] 365.000000 0.188728 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 1934 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 365 #> attr(,\"label\") #> [1] \"(n)\" basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = \"unique_count\", .labels = c(unique_count = \"Total number of patients with at least one AE\") ) %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> —————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 123 120 365 basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% split_rows_by( \"AEBODSYS\", child_labels = \"visible\", nested = FALSE, indent_mod = -1L, split_fun = drop_split_levels ) %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) #> Overall total number of events 609 622 703 1934 #> cl A.1 #> Total number of patients with at least one AE 78 (58.2%) 75 (56.0%) 89 (67.4%) 242 (60.5%) #> Overall total number of events 132 130 160 422 #> cl B.1 #> Total number of patients with at least one AE 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> Overall total number of events 56 60 62 178 #> cl B.2 #> Total number of patients with at least one AE 79 (59.0%) 74 (55.2%) 85 (64.4%) 238 (59.5%) #> Overall total number of events 129 138 143 410 #> cl C.1 #> Total number of patients with at least one AE 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> Overall total number of events 55 63 64 182 #> cl C.2 #> Total number of patients with at least one AE 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> Overall total number of events 48 53 65 166 #> cl D.1 #> Total number of patients with at least one AE 79 (59.0%) 67 (50.0%) 80 (60.6%) 226 (56.5%) #> Overall total number of events 127 106 135 368 #> cl D.2 #> Total number of patients with at least one AE 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) #> Overall total number of events 62 72 74 208 basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% count_occurrences(vars = \"AEDECOD\") %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ——————————————————————————————————————————————————————————————————————— #> dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) #> dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) #> dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) #> dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) #> dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) #> dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) #> dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) basic_table() %>% split_cols_by(var = \"ACTARM\") %>% add_colcounts() %>% add_overall_col(label = \"All Patients\") %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% split_rows_by( \"AEBODSYS\", child_labels = \"visible\", nested = FALSE, indent_mod = -1L, split_fun = drop_split_levels ) %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( unique = \"Total number of patients with at least one AE\", nonunique = \"Overall total number of events\" ) ) %>% count_occurrences(vars = \"AEDECOD\") %>% build_table( df = adae, alt_counts_df = adsl ) #> A: Drug X B: Placebo C: Combination All Patients #> (N=134) (N=134) (N=132) (N=400) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one AE 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) #> Overall total number of events 609 622 703 1934 #> cl A.1 #> Total number of patients with at least one AE 78 (58.2%) 75 (56.0%) 89 (67.4%) 242 (60.5%) #> Overall total number of events 132 130 160 422 #> dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) #> dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) #> cl B.1 #> Total number of patients with at least one AE 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> Overall total number of events 56 60 62 178 #> dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) #> cl B.2 #> Total number of patients with at least one AE 79 (59.0%) 74 (55.2%) 85 (64.4%) 238 (59.5%) #> Overall total number of events 129 138 143 410 #> dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) #> dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) #> cl C.1 #> Total number of patients with at least one AE 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> Overall total number of events 55 63 64 182 #> dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) #> cl C.2 #> Total number of patients with at least one AE 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> Overall total number of events 48 53 65 166 #> dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) #> cl D.1 #> Total number of patients with at least one AE 79 (59.0%) 67 (50.0%) 80 (60.6%) 226 (56.5%) #> Overall total number of events 127 106 135 368 #> dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) #> dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) #> cl D.2 #> Total number of patients with at least one AE 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) #> Overall total number of events 62 72 74 208 #> dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%)"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"response-table","dir":"Articles","previous_headings":"Tabulation Examples","what":"Response Table","title":"Tabulation","text":"typical response table binary clinical trial endpoint may composed several different analyses: Proportion responders treatment group Difference proportion responders comparison groups vs. control group Chi-Square test difference response rates comparison groups vs. control group can build table layout like following approach used AE table: table section produced using different layout creating function tern. First start data preparation steps set analysis dataset. select endpoint analyze PARAMCD define logical variable is_rsp indicates whether patient classified responder . create summary proportion responders treatment group, use estimate_proportion() layout creating function: specify arm table used reference, use argument ref_group split_cols_by(). change reference arm “B: Placebo” arm displayed first column: customize analysis, can use method conf_level arguments modify type confidence interval calculated: next table section needed summarize difference response rates reference arm comparison arm. Use estimate_proportion_diff() layout creating function : final section needed complete table includes statistical test difference response rates. Use test_proportion_diff() layout creating function : customize output, use method argument select Chi-Squared test Schouten correction. Now can put table sections together one layout pipeline. Note one small change needed. Since primary analysis variable table sections (is_rsp), need give sub-table unique name. done adding table_names argument providing unique names :","code":"# Preprocessing to select an analysis endpoint. anl <- adrs %>% dplyr::filter(PARAMCD == \"BESRSPI\") %>% dplyr::mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) basic_table() %>% split_cols_by(var = \"ARM\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\", table_names = \"est_prop\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ————————————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 95% CI (Wald, with correction) (78.7, 91.5) (58.8, 75.5) (85.6, 96.2) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ————————————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 95% CI (Wald, with correction) (78.7, 91.5) (58.8, 75.5) (85.6, 96.2) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\", method = \"clopper-pearson\", conf_level = 0.9 ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ——————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 90% CI (Clopper-Pearson) (79.1, 89.9) (59.9, 73.9) (85.7, 94.7) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion_diff( vars = \"is_rsp\", show_labels = \"visible\", var_labels = \"Unstratified Analysis\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> —————————————————————————————————————————————————————————————————————————————— #> Unstratified Analysis #> Difference in Response rate (%) 17.9 23.7 #> 95% CI (Wald, with correction) (7.2, 28.6) (13.7, 33.8) basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% test_proportion_diff(vars = \"is_rsp\") %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> —————————————————————————————————————————————————————————————————————— #> p-value (Chi-Squared Test) 0.0006 <0.0001 basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% test_proportion_diff( vars = \"is_rsp\", method = \"schouten\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> p-value (Chi-Squared Test with Schouten Correction) 0.0008 <0.0001 basic_table() %>% split_cols_by(var = \"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% estimate_proportion( vars = \"is_rsp\", method = \"clopper-pearson\", conf_level = 0.9, table_names = \"est_prop\" ) %>% estimate_proportion_diff( vars = \"is_rsp\", show_labels = \"visible\", var_labels = \"Unstratified Analysis\", table_names = \"est_prop_diff\" ) %>% test_proportion_diff( vars = \"is_rsp\", method = \"schouten\", table_names = \"test_prop_diff\" ) %>% build_table(anl) #> A: Drug X B: Placebo C: Combination #> (N=134) (N=134) (N=132) #> ———————————————————————————————————————————————————————————————————————————————————————————————————— #> Responders 114 (85.1%) 90 (67.2%) 120 (90.9%) #> 90% CI (Clopper-Pearson) (79.1, 89.9) (59.9, 73.9) (85.7, 94.7) #> Unstratified Analysis #> Difference in Response rate (%) 17.9 23.7 #> 95% CI (Wald, with correction) (7.2, 28.6) (13.7, 33.8) #> p-value (Chi-Squared Test with Schouten Correction) 0.0008 <0.0001"},{"path":"https://insightsengineering.github.io/tern/main/articles/tables.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Tabulation","text":"Tabulation tern builds top layout tabulation framework rtables. Complex tables built step step pipeline combining layout creating functions perform specific type analysis. tern analyze functions introduced vignette : analyze_vars() summarize_num_patients() count_occurrences() estimate_proportion() estimate_proportion_diff() test_proportion_diff() Layout creating functions build formatted layout controlling features labels, numerical display formats indentation. functions wrappers Statistics functions calculate raw summaries analysis. can easily spot Statistics functions documentation always begin prefix s_. can helpful inspect run Statistics functions understand ways analysis can customized.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern.html","id":"common-clinical-trials-analyses","dir":"Articles","previous_headings":"","what":"Common Clinical Trials Analyses","title":"Introduction to tern","text":"package provides large range functionality create tables graphs used clinical trial statistical analysis. rtables tabulation extended clinical trials specific functions: demographics unique patients exposure across patients change baseline parameters statistical model fits: MMRM, logistic regression, Cox regression, … … rtables tabulation helper functions: pre-processing conversions transformations … data visualizations connected clinical trials: Kaplan-Meier plots forest plots line plots … data visualizations helper functions: arrange/stack multiple graphs embellishing graphs/tables metadata details, adding titles, footnotes, page number, etc. … reference tern functions available tern website functions reference.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern.html","id":"analytical-functions-for-rtables","dir":"Articles","previous_headings":"","what":"Analytical Functions for rtables","title":"Introduction to tern","text":"Analytical functions used combination rtables layout functions, pipeline creates rtables table. apply statistical logic layout rtables table. table layout materialized rtables::build_table function data. tern analytical functions wrappers around rtables::analyze function; offer various methods useful perspective clinical trials statistical projects. Examples tern analytical functions count_occurrences, summarize_ancova analyze_vars. one prefix identify tern analytical functions recommended use reference subsection tern website. rtables code first describe two tables assign descriptions variables lyt lyt2. built tables using actual data rtables::build_table. description table called table layout. analyze instruction adds layout ARM variable analyzed mean analysis function result rounded 1 decimal place. Hence, layout “pre-data”; , ’s description build table get data. Defining table layout pure rtables code: , tern function used analyze_vars replaces rtables::analyze function used . see tern offers advanced analysis extending rtables function calls one additional function call. examples tabulation analyze functions presented Tabulation vignette.","code":"library(tern) library(dplyr) # Create table layout pure rtables lyt <- rtables::basic_table() %>% rtables::split_cols_by(var = \"ARM\") %>% rtables::split_rows_by(var = \"AVISIT\") %>% rtables::analyze(vars = \"AVAL\", mean, format = \"xx.x\") # Create table layout with tern analyze_vars analyze function lyt2 <- rtables::basic_table() %>% rtables::split_cols_by(var = \"ARM\") %>% rtables::split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\", .formats = c(\"mean_sd\" = \"(xx.xx, xx.xx)\")) # Apply table layout to data and produce `rtables` object adrs <- formatters::ex_adrs rtables::build_table(lyt, df = adrs) #> A: Drug X B: Placebo C: Combination #> —————————————————————————————————————————————————————————— #> SCREENING #> mean 3.0 3.0 3.0 #> BASELINE #> mean 2.5 2.8 2.5 #> END OF INDUCTION #> mean 1.7 2.1 1.6 #> FOLLOW UP #> mean 2.2 2.9 2.0 rtables::build_table(lyt2, df = adrs) #> A: Drug X B: Placebo C: Combination #> ——————————————————————————————————————————————————————————————— #> SCREENING #> n 154 178 144 #> Mean (SD) (3.00, 0.00) (3.00, 0.00) (3.00, 0.00) #> Median 3.0 3.0 3.0 #> Min - Max 3.0 - 3.0 3.0 - 3.0 3.0 - 3.0 #> BASELINE #> n 136 146 124 #> Mean (SD) (2.46, 0.88) (2.77, 1.00) (2.46, 1.08) #> Median 3.0 3.0 3.0 #> Min - Max 1.0 - 4.0 1.0 - 5.0 1.0 - 5.0 #> END OF INDUCTION #> n 218 205 217 #> Mean (SD) (1.75, 0.90) (2.14, 1.28) (1.65, 1.06) #> Median 2.0 2.0 1.0 #> Min - Max 1.0 - 4.0 1.0 - 5.0 1.0 - 5.0 #> FOLLOW UP #> n 164 153 167 #> Mean (SD) (2.23, 1.26) (2.89, 1.29) (1.97, 1.01) #> Median 2.0 4.0 2.0 #> Min - Max 1.0 - 4.0 1.0 - 4.0 1.0 - 4.0"},{"path":"https://insightsengineering.github.io/tern/main/articles/tern.html","id":"clinical-trial-visualizations","dir":"Articles","previous_headings":"","what":"Clinical Trial Visualizations","title":"Introduction to tern","text":"Clinical trial related plots complement rich palette tern tabulation analysis functions. Thus tern package delivers full-featured tool clinical trial reporting. tern plot functions return graphs ggplot2 objects. nestcolor package can loaded apply standardized NEST color palette tern plots. Line plot without table generated g_lineplot function. Line plot table generated g_lineplot function. tern functions used plot generation g_ prefixed listed tern website functions reference.","code":"adsl <- formatters::ex_adsl adlb <- formatters::ex_adlb adlb <- dplyr::filter(adlb, PARAMCD == \"ALT\", AVISIT != \"SCREENING\") library(nestcolor) # Mean with CI g_lineplot(adlb, adsl, subtitle = \"Laboratory Test:\") # Mean with CI, table, and customized confidence level g_lineplot( adlb, adsl, table = c(\"n\", \"mean\", \"mean_ci\"), title = \"Plot of Mean and 80% Confidence Limits by Visit\" )"},{"path":"https://insightsengineering.github.io/tern/main/articles/tern.html","id":"interactive-apps","dir":"Articles","previous_headings":"","what":"Interactive Apps","title":"Introduction to tern","text":"tern outputs can easily converted shiny apps. recommend building apps using teal package, shiny-based interactive exploration framework analyzing data. variety pre-made teal shiny apps tern outputs available teal.modules.clinical package.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Introduction to tern","text":"summary, tern contains many additional functions creating tables, listings, graphs used clinical trials statistical analyses. design package gives users flexibility meet analysis needs regulatory exploratory reporting contexts. information please explore tern website.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"tern-formatting-functions-overview","dir":"Articles","previous_headings":"","what":"tern Formatting Functions Overview","title":"Formatting Functions","text":"tern R package provides functions create common analyses clinical trials R functions default formatting arguments displaying values output specific way. tern formatting differs compared formatting available formatters package tern formats capable handling logical statements, allowing fine-tuning output displayed. Depending type value displayed, value , format output change. Whereas using formatters package, specified format applied regardless value. see available formatting functions available tern see ?formatting_functions. see available format strings available formatters see formatters::list_valid_format_labels().","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"comparing-tern-formatters-formats","dir":"Articles","previous_headings":"","what":"Comparing tern & formatters Formats","title":"Formatting Functions","text":"packages used vignette : example demonstrates use tern formatting count_abnormal() function. example “low” category non-zero numerator value fraction percentage value displayed, “high” value numerator value zero fraction value displayed without also displaying redundant zero percentage value. following example count_abnormal() function utilized . time “low” values “high” values non-zero numerator show percentage. following example demonstrates difference formatters used instead format output. choose use \"xx / xx\" value format. “high” value zero numerator value “low” value non-zero numerator, yet displayed format. concept occurs using available formats formatters package. following example displays result using \"xx.x / xx.x\" format instead. Use formatters::list_valid_format_labels() see full list available formats formatters.","code":"library(rtables) library(formatters) library(tern) library(dplyr) df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = format_fraction) ) %>% build_table(df2) #> all obs #> ————————————————— #> low 2/2 (100%) #> high 0/2 df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = format_fraction) ) %>% build_table(df2) #> all obs #> ———————————————— #> low 1/2 (50%) #> high 1/2 (50%) df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = \"xx / xx\") ) %>% build_table(df2) #> all obs #> —————————————— #> low 2 / 2 #> high 0 / 2 df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = \"xx.x / xx.x\") ) %>% build_table(df2) #> all obs #> ———————————————— #> low 2.0 / 2.0 #> high 0.0 / 2.0"},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"formatting-function-basics","dir":"Articles","previous_headings":"","what":"Formatting Function Basics","title":"Formatting Functions","text":"Current tern formatting functions consider following aspects setting custom behaviors: Missing values - custom value string can set display missing values instead NA. 0’s - cell value zero, tern fraction formatting functions exclude accompanying percentage value. Number decimal places display - number decimal places can fixed needed. Value thresholds - different format value can displayed depending whether value within certain threshold.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"number-of-decimal-places-to-display","dir":"Articles","previous_headings":"Formatting Function Basics","what":"Number of Decimal Places to Display","title":"Formatting Functions","text":"Two functions set fixed number decimal places (specifically 1) format_fraction_fixed_dp() format_count_fraction_fixed_dp(). default, formatting functions remove trailing zeros, two functions always one decimal place percentage, even digit zero. See following example:","code":"format_fraction_fixed_dp(x = c(num = 1L, denom = 3L)) #> [1] \"1/3 (33.3%)\" format_fraction_fixed_dp(x = c(num = 1L, denom = 2L)) #> [1] \"1/2 (50.0%)\" format_count_fraction_fixed_dp(x = c(2, 0.6667)) #> [1] \"2 (66.7%)\" format_count_fraction_fixed_dp(x = c(2, 0.25)) #> [1] \"2 (25.0%)\""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"value-thresholds","dir":"Articles","previous_headings":"Formatting Function Basics","what":"Value Thresholds","title":"Formatting Functions","text":"Functions set custom values according certain threshold include format_extreme_values(), format_extreme_values_ci(), format_fraction_threshold(). extreme value formats work similarly allow user specify maximum number digits include, large small values given special string value. example: format_fraction_threshold() function allows user specify lower percentage threshold, values instead assigned special string value. example: See documentation function specific details behavior customize .","code":"extreme_format <- format_extreme_values(digits = 2) extreme_format(0.235) #> [1] \"0.23\" extreme_format(0.001) #> [1] \"<0.01\" extreme_format(Inf) #> [1] \">999.99\" fraction_format <- format_fraction_threshold(0.05) fraction_format(x = c(20, 0.1)) #> [1] 10 fraction_format(x = c(2, 0.01)) #> [1] \"<5\""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"creating-custom-formatting-functions","dir":"Articles","previous_headings":"","what":"Creating Custom Formatting Functions","title":"Formatting Functions","text":"table requires customized output displayed using one pre-existing tern formatting functions, may want consider creating new formatting function. creating formatting function important consider aspects listed Formatting Function Customization section . section create custom formatting function derived format_fraction_fixed_dp() function. First take look function detail customize . see numerator value greater 0, fraction percentage displayed. numerator 0, fraction shown. Percent values always display 1 decimal place. create dummy dataset observe output value behavior formatting function applied. Now modify function make custom formatting function, custom_format. want display 3 decimal places percent value, numerator value 0 want display 0 value (without denominator).","code":"# First we will see how the format_fraction_fixed_dp code works and displays the outputs format_fraction_fixed_dp <- function(x, ...) { attr(x, \"label\") <- NULL checkmate::assert_vector(x) checkmate::assert_count(x[\"num\"]) checkmate::assert_count(x[\"denom\"]) result <- if (x[\"num\"] == 0) { paste0(x[\"num\"], \"/\", x[\"denom\"]) } else { paste0( x[\"num\"], \"/\", x[\"denom\"], \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" ) } return(result) } df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"LOW\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = format_fraction_fixed_dp) ) %>% build_table(df2) #> all obs #> ——————————————————— #> low 2/2 (100.0%) #> high 0/2 custom_format <- function(x, ...) { attr(x, \"label\") <- NULL checkmate::assert_vector(x) checkmate::assert_count(x[\"num\"]) checkmate::assert_count(x[\"denom\"]) result <- if (x[\"num\"] == 0) { paste0(x[\"num\"]) # We remove the denominator on this line so that only a 0 is displayed } else { paste0( x[\"num\"], \"/\", x[\"denom\"], \" (\", sprintf(\"%.3f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" # We include 3 decimal places with %.3f ) } return(result) } basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\"), exclude_base_abn = FALSE, .formats = list(fraction = custom_format) # Here we implement our new custom_format function ) %>% build_table(df2) #> all obs #> ————————————————————— #> low 2/2 (100.000%) #> high 0"},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_formats.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Formatting Functions","text":"tern analysis function pre-specified default format functions implement generating output, taken formatters package custom formatting functions stored tern. tern functions differ compared formatters logical statements can used set value-dependent customized formats. like create custom formatting function use tern, sure carefully consider rules want implement handle different input values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_functions_guide.html","id":"understanding-tern-functions","dir":"Articles","previous_headings":"","what":"Understanding tern functions","title":"Understanding `tern` functions","text":"Every function tern package designed certain structure can cooperate well every user’s need, maintaining consistent predictable behavior. document guide example function package, explaining purpose many building blocks can used. recently worked consider summarize_change() example. function used calculate change baseline value given variable. realistic example can found LBT03 TLG-catalog. summarize_change() main function available user. can find lists functions ?tern::analyze_functions. build around rtables::analyze() function, core analysis function rtables. wrapper functions call specific analysis functions (always written a_*) meant handle statistic functions (always written s_*) format results rtables::in_row() function. can summarize structure follows: summarize_change() (1)-> a_change_from_baseline() (2)-> [s_change_from_baseline() + rtables::in_row()] main questions may arise : Handling NA. Handling formats. Additional statistics. Data set library loading. Classic use summarize_change(). .formats, .labels, .indent_mods depend names .stats. can change default formatting. want something special format? Adding custom statistic (custom format):","code":"library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(tern) #> Loading required package: rtables #> Loading required package: formatters #> #> Attaching package: 'formatters' #> The following object is masked from 'package:base': #> #> %||% #> Loading required package: magrittr #> #> Attaching package: 'rtables' #> The following object is masked from 'package:utils': #> #> str #> Registered S3 method overwritten by 'tern': #> method from #> tidy.glm broom ## Fabricate dataset dta_test <- data.frame( USUBJID = rep(1:6, each = 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)) ) %>% mutate(ABLFLL = AVISIT == \"V1\") %>% group_by(USUBJID) %>% mutate( BLVAL = AVAL[ABLFLL], CHG = AVAL - BLVAL ) %>% ungroup() fix_layout <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") # Dealing with NAs: na_rm = TRUE fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\")) %>% build_table(dta_test) %>% print() #> A B C #> ———————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 (NA) NA #> Median 7.50 3.00 NA #> Min - Max 6.00 - 9.00 3.00 - 3.00 NA #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 (NA) NA #> Median -1.00 -1.00 NA #> Min - Max -1.00 - -1.00 -1.00 - -1.00 NA #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 (NA) NA #> Median -2.00 -2.00 NA #> Min - Max -2.00 - -2.00 -2.00 - -2.00 NA # Dealing with NAs: na_rm = FALSE fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), na_rm = FALSE) %>% build_table(dta_test) %>% print() #> A B C #> ———————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 (NA) NA #> Median 7.50 3.00 NA #> Min - Max 6.00 - 9.00 3.00 - 3.00 NA #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 (NA) NA #> Median -1.00 -1.00 NA #> Min - Max -1.00 - -1.00 -1.00 - -1.00 NA #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 (NA) NA #> Median -2.00 -2.00 NA #> Min - Max -2.00 - -2.00 -2.00 - -2.00 NA # changing the NA string (it is done on all levels) fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), na_str = \"my_na\") %>% build_table(dta_test) %>% print() #> A B C #> ——————————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 (my_na) my_na #> Median 7.50 3.00 my_na #> Min - Max 6.00 - 9.00 3.00 - 3.00 my_na #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 (my_na) my_na #> Median -1.00 -1.00 my_na #> Min - Max -1.00 - -1.00 -1.00 - -1.00 my_na #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 (my_na) my_na #> Median -2.00 -2.00 my_na #> Min - Max -2.00 - -2.00 -2.00 - -2.00 my_na # changing n count format and label and indentation fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), .stats = c(\"n\", \"mean\"), # reducing the number of stats for visual appreciation .formats = c(n = \"xx.xx\"), .labels = c(n = \"NnNn\"), .indent_mods = c(n = 5), na_str = \"nA\" ) %>% build_table(dta_test) %>% print() #> A B C #> ————————————————————————————————————— #> V1 #> NnNn 2.00 1.00 0.00 #> Mean 7.5 3.0 nA #> V2 #> NnNn 2.00 1.00 0.00 #> Mean -1.0 -1.0 nA #> V3 #> NnNn 2.00 1.00 0.00 #> Mean -2.0 -2.0 nA # changing n count format and label and indentation fix_layout %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), .stats = c(\"n\", \"mean\"), # reducing the number of stats for visual appreciation .formats = c(n = function(x, ...) as.character(x * 100)) ) %>% # Note you need ...!!! build_table(dta_test) %>% print() #> A B C #> ————————————————————————— #> V1 #> n 200 100 0 #> Mean 7.5 3.0 NA #> V2 #> n 200 100 0 #> Mean -1.0 -1.0 NA #> V3 #> n 200 100 0 #> Mean -2.0 -2.0 NA # changing n count format and label and indentation fix_layout %>% summarize_change( \"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"), .stats = c(\"n\", \"my_stat\" = function(df, ...) { a <- mean(df$AVAL, na.rm = TRUE) b <- list(...)$.N_row # It has access at all `?rtables::additional_fun_params` a / b }), .formats = c(\"my_stat\" = function(x, ...) sprintf(\"%.2f\", x)) ) %>% build_table(dta_test) #> A B C #> ———————————————————————————— #> V1 #> n 2 1 0 #> my_stat 1.25 0.50 NA #> V2 #> n 2 1 0 #> my_stat 1.08 0.33 NA #> V3 #> n 2 1 0 #> my_stat 0.92 0.17 NA"},{"path":"https://insightsengineering.github.io/tern/main/articles/tern_functions_guide.html","id":"for-developers","dir":"Articles","previous_headings":"","what":"For Developers","title":"Understanding `tern` functions","text":"layers specific parameters need available, , rtables multiple way handle formatting NA values, decide correctly handle additional extra arguments. follow following scheme: Level 1: summarize_change(): parameters without starting dot .* used added extra_args. Specifically, solve NA values using inclNAs option rtables::analyze(). add ... na.rm = inclNAs. Also na_str set. may want statistic dependent future, still need think accomplish . add rtables::additional_fun_params analysis function make available ... next level. Level 2: a_change_from_baseline(): parameters starting dot . used. Mainly .stats, .formats, .labels, .indent_mods used. also add extra_afun_params ... list statistical function. Notice handling additional parameters .call() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Joe Zhu. Author, maintainer. Daniel Sabanés Bové. Author. Jana Stoilova. Author. Davide Garolini. Author. Emily de la Rua. Author. Abinaya Yogasekaram. Author. Heng Wang. Author. Francois Collin. Author. Adrian Waddell. Author. Pawel Rucki. Author. Chendi Liao. Author. Jennifer Li. Author. F. Hoffmann-La Roche AG. Copyright holder, funder.","code":""},{"path":"https://insightsengineering.github.io/tern/main/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Zhu J, Sabanés Bové D, Stoilova J, Garolini D, de la Rua E, Yogasekaram , Wang H, Collin F, Waddell , Rucki P, Liao C, Li J (2024). tern: Create Common TLGs Used Clinical Trials. R package version 0.9.6.9015, https://github.com/insightsengineering/tern/, https://insightsengineering.github.io/tern/main/.","code":"@Manual{, title = {tern: Create Common TLGs Used in Clinical Trials}, author = {Joe Zhu and Daniel {Sabanés Bové} and Jana Stoilova and Davide Garolini and Emily {de la Rua} and Abinaya Yogasekaram and Heng Wang and Francois Collin and Adrian Waddell and Pawel Rucki and Chendi Liao and Jennifer Li}, year = {2024}, note = {R package version 0.9.6.9015, https://github.com/insightsengineering/tern/}, url = {https://insightsengineering.github.io/tern/main/}, }"},{"path":"https://insightsengineering.github.io/tern/main/index.html","id":"tern-","dir":"","previous_headings":"","what":"Create Common TLGs Used in Clinical Trials","title":"Create Common TLGs Used in Clinical Trials","text":"tern R package contains analysis functions create tables graphs used clinical trial reporting. package provides large range functionality, : Data visualizations: Line plots (g_lineplot) Kaplan-Meier plots (g_km) Forest plots (g_forest) STEP graphs (g_step) Individual patient plots (g_ipp) Waterfall plots (g_waterfall) Bland-Altman plots (g_bland_altman) Statistical model fit summaries: Logistic regression (summarize_logistic) Cox regression (summarize_coxreg) Analysis tables: See list available analyze functions See list available summarize functions See list available column-wise analysis functions Many outputs available added teal shiny applications interactive exploration data. teal modules available teal.modules.clinical package. See TLG Catalog extensive catalog example clinical trial tables, listings, graphs created using tern functionality.","code":""},{"path":"https://insightsengineering.github.io/tern/main/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Create Common TLGs Used in Clinical Trials","text":"tern available CRAN can install latest released version : can install latest development version directly GitHub running following:","code":"install.packages(\"tern\") # install.packages(\"pak\") pak::pak(\"insightsengineering/tern\")"},{"path":"https://insightsengineering.github.io/tern/main/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Create Common TLGs Used in Clinical Trials","text":"understand use package, please refer Introduction tern article, provides multiple examples code implementation. See package vignettes browseVignettes(package = \"tern\") usage package.","code":""},{"path":"https://insightsengineering.github.io/tern/main/index.html","id":"related","dir":"","previous_headings":"","what":"Related","title":"Create Common TLGs Used in Clinical Trials","text":"rtables - table engine used tlg-catalog - website showcasing many examples clinical trial tables, listings, graphs teal.modules.clinical - teal modules interactive data analysis","code":""},{"path":"https://insightsengineering.github.io/tern/main/index.html","id":"acknowledgment","dir":"","previous_headings":"","what":"Acknowledgment","title":"Create Common TLGs Used in Clinical Trials","text":"package result joint efforts many developers stakeholders. like thank everyone contributed far!","code":""},{"path":[]},{"path":[]},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with abnormal range values — abnormal","title":"Count patients with abnormal range values — abnormal","text":"analyze function count_abnormal() creates layout element count patients abnormal analysis range values direction. function analyzes primary analysis variable var indicates abnormal range results. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, baseline (defaults BNRIND), variable indicate baseline reference ranges. direction specified via abnormal parameter (e.g. High Low), fraction patient counts returned, numerator denominator calculated follows: num: number patients abnormality recorded treatment. denom: total number patients least one post-baseline assessment. function assumes df filtered include post-baseline records.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with abnormal range values — abnormal","text":"","code":"count_abnormal( lyt, var, abnormal = list(Low = \"LOW\", High = \"HIGH\"), variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), exclude_base_abn = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = var, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal( df, .var, abnormal = list(Low = \"LOW\", High = \"HIGH\"), variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), exclude_base_abn = FALSE ) a_count_abnormal( df, .var, abnormal = list(Low = \"LOW\", High = \"HIGH\"), variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), exclude_base_abn = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with abnormal range values — abnormal","text":"lyt (PreDataTableLayouts) layout analyses added . abnormal (named list) list identifying abnormal range level(s) var. Defaults list(Low = \"LOW\", High = \"HIGH\") can also group different levels named list, example, abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")). variables (named list string) list additional analysis variables. exclude_base_abn (flag) whether exclude subjects baseline abnormality numerator denominator. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with abnormal range values — abnormal","text":"count_abnormal() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal() table layout. s_count_abnormal() returns statistic fraction vector num denom counts patients. a_count_abnormal() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with abnormal range values — abnormal","text":"count_abnormal(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal(): Statistics function counts patients abnormal range values single abnormal level. a_count_abnormal(): Formatted analysis function used afun count_abnormal().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count patients with abnormal range values — abnormal","text":"count_abnormal() considers single variable contains multiple abnormal levels. df filtered include post-baseline records. denominator includes patients may abnormal levels baseline, patients missing baseline records. Patients abnormalities baseline can optionally excluded numerator denominator via exclude_base_abn parameter.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with abnormal range values — abnormal","text":"","code":"library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following object is masked from ‘package:testthat’: #> #> matches #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union df <- data.frame( USUBJID = as.character(c(1, 1, 2, 2)), ANRIND = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BNRIND = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) # Select only post-baseline records. df <- df %>% filter(ONTRTFL == \"Y\") # Layout creating function. basic_table() %>% count_abnormal(var = \"ANRIND\", abnormal = list(high = \"HIGH\", low = \"LOW\")) %>% build_table(df) #> all obs #> ———————————————— #> high 1/2 (50%) #> low 1/2 (50%) # Passing of statistics function and formatting arguments. df2 <- data.frame( ID = as.character(c(1, 1, 2, 2)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BL_RANGE = factor(c(\"NORMAL\", \"NORMAL\", \"HIGH\", \"HIGH\")), ONTRTFL = c(\"\", \"Y\", \"\", \"Y\"), stringsAsFactors = FALSE ) # Select only post-baseline records. df2 <- df2 %>% filter(ONTRTFL == \"Y\") basic_table() %>% count_abnormal( var = \"RANGE\", abnormal = list(low = \"LOW\", high = \"HIGH\"), variables = list(id = \"ID\", baseline = \"BL_RANGE\") ) %>% build_table(df2) #> all obs #> ———————————————— #> low 1/2 (50%) #> high 1/2 (50%)"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"analyze function count_abnormal_by_baseline() creates layout element count patients abnormal analysis range values, categorized baseline status. function analyzes primary analysis variable var indicates abnormal range results. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, baseline (defaults BNRIND), variable indicate baseline reference ranges. direction specified via abnormal parameter (e.g. High Low), condition baseline range result count patients numerator denominator follows following categories: num: number patients without abnormality baseline (excluding missing baseline) least one abnormality post-baseline. denom: number patients without abnormality baseline (excluding missing baseline). num: number patients abnormality baseline least one abnormality post-baseline. denom: number patients abnormality baseline. Total num: number patients least one post-baseline record least one abnormality post-baseline. denom: number patients least one post-baseline record. function assumes df filtered include post-baseline records.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"","code":"count_abnormal_by_baseline( lyt, var, abnormal, variables = list(id = \"USUBJID\", baseline = \"BNRIND\"), na_str = \"\", nested = TRUE, ..., table_names = abnormal, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_by_baseline( df, .var, abnormal, na_str = \"\", variables = list(id = \"USUBJID\", baseline = \"BNRIND\") ) a_count_abnormal_by_baseline( df, .var, abnormal, na_str = \"\", variables = list(id = \"USUBJID\", baseline = \"BNRIND\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"lyt (PreDataTableLayouts) layout analyses added . abnormal (character) values identifying abnormal range level(s) .var. variables (named list string) list additional analysis variables. na_str (string) explicit na_level argument used pre-processing steps (maybe df_explicit_na()). default \"\". nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"count_abnormal_by_baseline() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_by_baseline() table layout. s_count_abnormal_by_baseline() returns statistic fraction named list 3 labeled elements: not_abnormal, abnormal, total. element contains vector num denom patient counts. a_count_abnormal_by_baseline() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"count_abnormal_by_baseline(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_by_baseline(): Statistics function single abnormal level. a_count_abnormal_by_baseline(): Formatted analysis function used afun count_abnormal_by_baseline().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"df filtered include post-baseline records. baseline variable analysis variable contains NA records, expected df pre-processed using df_explicit_na() explicit_na().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_baseline.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with abnormal analysis range values by baseline status — abnormal_by_baseline","text":"","code":"df <- data.frame( USUBJID = as.character(c(1:6)), ANRIND = factor(c(rep(\"LOW\", 4), \"NORMAL\", \"HIGH\")), BNRIND = factor(c(\"LOW\", \"NORMAL\", \"HIGH\", NA, \"LOW\", \"NORMAL\")) ) df <- df_explicit_na(df) # Layout creating function. basic_table() %>% count_abnormal_by_baseline(var = \"ANRIND\", abnormal = c(High = \"HIGH\")) %>% build_table(df) #> all obs #> ———————————————————————— #> High #> Not high 1/4 (25%) #> High 0/1 #> Total 1/6 (16.7%) # Passing of statistics function and formatting arguments. df2 <- data.frame( ID = as.character(c(1, 2, 3, 4)), RANGE = factor(c(\"NORMAL\", \"LOW\", \"HIGH\", \"HIGH\")), BLRANGE = factor(c(\"LOW\", \"HIGH\", \"HIGH\", \"NORMAL\")) ) basic_table() %>% count_abnormal_by_baseline( var = \"RANGE\", abnormal = c(Low = \"LOW\"), variables = list(id = \"ID\", baseline = \"BLRANGE\"), .formats = c(fraction = \"xx / xx\"), .indent_mods = c(fraction = 2L) ) %>% build_table(df2) #> all obs #> ——————————————————————— #> Low #> Not low 1 / 3 #> Low 0 / 1 #> Total 1 / 4"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with marked laboratory abnormalities — abnormal_by_marked","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"analyze function count_abnormal_by_marked() creates layout element count patients marked laboratory abnormalities direction abnormality, categorized parameter value. function analyzes primary analysis variable var indicates whether single, replicated, last marked laboratory abnormality observed. Levels var include marked lab abnormality (single last_replicated) can supplied via category parameter. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, param (defaults PARAM), variable indicate parameter values, direction (defaults abn_dir), variable indicate abnormality directions. combination param direction levels, marked lab abnormality counts calculated follows: Single, last & Last replicated: number patients Single, last Last replicated values, respectively. : number patients either single replicated marked abnormalities. Fractions calculated dividing counts number patients least one valid measurement recorded analysis. Prior using function table layout must use rtables::split_rows_by() create two row splits, one variable param one variable direction.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"","code":"count_abnormal_by_marked( lyt, var, category = list(single = \"SINGLE\", last_replicated = c(\"LAST\", \"REPLICATED\")), variables = list(id = \"USUBJID\", param = \"PARAM\", direction = \"abn_dir\"), na_str = default_na_str(), nested = TRUE, ..., .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_by_marked( df, .var = \"AVALCAT1\", .spl_context, category = list(single = \"SINGLE\", last_replicated = c(\"LAST\", \"REPLICATED\")), variables = list(id = \"USUBJID\", param = \"PARAM\", direction = \"abn_dir\") ) a_count_abnormal_by_marked( df, .var = \"AVALCAT1\", .spl_context, category = list(single = \"SINGLE\", last_replicated = c(\"LAST\", \"REPLICATED\")), variables = list(id = \"USUBJID\", param = \"PARAM\", direction = \"abn_dir\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"lyt (PreDataTableLayouts) layout analyses added . category (list) list different marked category names single last replicated. variables (named list string) list additional analysis variables. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function. .spl_context (data.frame) gives information ancestor split states passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"count_abnormal_by_marked() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_by_marked() table layout. s_count_abnormal_by_marked() returns statistic count_fraction Single, last, Last replicated, results. a_count_abnormal_by_marked() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"count_abnormal_by_marked(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_by_marked(): Statistics function patients marked lab abnormalities. a_count_abnormal_by_marked(): Formatted analysis function used afun count_abnormal_by_marked().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"Single, last Last replicated levels mutually exclusive. patient abnormalities meet Single, last Last replicated criteria, patient counted Last replicated category.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_marked.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with marked laboratory abnormalities — abnormal_by_marked","text":"","code":"library(dplyr) df <- data.frame( USUBJID = as.character(c(rep(1, 5), rep(2, 5), rep(1, 5), rep(2, 5))), ARMCD = factor(c(rep(\"ARM A\", 5), rep(\"ARM B\", 5), rep(\"ARM A\", 5), rep(\"ARM B\", 5))), ANRIND = factor(c( \"NORMAL\", \"HIGH\", \"HIGH\", \"HIGH HIGH\", \"HIGH\", \"HIGH\", \"HIGH\", \"HIGH HIGH\", \"NORMAL\", \"HIGH HIGH\", \"NORMAL\", \"LOW\", \"LOW\", \"LOW LOW\", \"LOW\", \"LOW\", \"LOW\", \"LOW LOW\", \"NORMAL\", \"LOW LOW\" )), ONTRTFL = rep(c(\"\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\", \"Y\"), 2), PARAMCD = factor(c(rep(\"CRP\", 10), rep(\"ALT\", 10))), AVALCAT1 = factor(rep(c(\"\", \"\", \"\", \"SINGLE\", \"REPLICATED\", \"\", \"\", \"LAST\", \"\", \"SINGLE\"), 2)), stringsAsFactors = FALSE ) df <- df %>% mutate(abn_dir = factor( case_when( ANRIND == \"LOW LOW\" ~ \"Low\", ANRIND == \"HIGH HIGH\" ~ \"High\", TRUE ~ \"\" ), levels = c(\"Low\", \"High\") )) # Select only post-baseline records. df <- df %>% filter(ONTRTFL == \"Y\") df_crp <- df %>% filter(PARAMCD == \"CRP\") %>% droplevels() full_parent_df <- list(df_crp, \"not_needed\") cur_col_subset <- list(rep(TRUE, nrow(df_crp)), \"not_needed\") spl_context <- data.frame( split = c(\"PARAMCD\", \"GRADE_DIR\"), full_parent_df = I(full_parent_df), cur_col_subset = I(cur_col_subset) ) map <- unique( df[df$abn_dir %in% c(\"Low\", \"High\") & df$AVALCAT1 != \"\", c(\"PARAMCD\", \"abn_dir\")] ) %>% lapply(as.character) %>% as.data.frame() %>% arrange(PARAMCD, abn_dir) basic_table() %>% split_cols_by(\"ARMCD\") %>% split_rows_by(\"PARAMCD\") %>% summarize_num_patients( var = \"USUBJID\", .stats = \"unique_count\" ) %>% split_rows_by( \"abn_dir\", split_fun = trim_levels_to_map(map) ) %>% count_abnormal_by_marked( var = \"AVALCAT1\", variables = list( id = \"USUBJID\", param = \"PARAMCD\", direction = \"abn_dir\" ) ) %>% build_table(df = df) #> ARM A ARM B #> ———————————————————————————————————————————— #> ALT (n) 1 1 #> Low #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%) #> CRP (n) 1 1 #> High #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%) basic_table() %>% split_cols_by(\"ARMCD\") %>% split_rows_by(\"PARAMCD\") %>% summarize_num_patients( var = \"USUBJID\", .stats = \"unique_count\" ) %>% split_rows_by( \"abn_dir\", split_fun = trim_levels_in_group(\"abn_dir\") ) %>% count_abnormal_by_marked( var = \"AVALCAT1\", variables = list( id = \"USUBJID\", param = \"PARAMCD\", direction = \"abn_dir\" ) ) %>% build_table(df = df) #> ARM A ARM B #> ———————————————————————————————————————————— #> ALT (n) 1 1 #> Low #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%) #> CRP (n) 1 1 #> High #> Single, not last 1 (100%) 0 #> Last or replicated 0 1 (100%) #> Any Abnormality 1 (100%) 1 (100%)"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"analyze function count_abnormal_by_worst_grade() creates layout element count patients highest (worst) analysis toxicity grade post-baseline direction, categorized parameter value. function analyzes primary analysis variable var indicates toxicity grades. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, param (defaults PARAM), variable indicate parameter values, grade_dir (defaults GRADE_DIR), variable indicate directions (e.g. High Low) toxicity grade supplied var. combination param grade_dir levels, patient counts worst grade calculated follows: 1 4: number patients worst grades 1-4, respectively. : number patients least one abnormality (.e. grade 0). Fractions calculated dividing counts number patients least one valid measurement recorded treatment. Pre-processing crucial using function can done automatically using h_adlb_abnormal_by_worst_grade() helper function. See description function details necessary pre-processing steps. Prior using function table layout must use rtables::split_rows_by() create two row splits, one variable param one variable grade_dir.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"","code":"count_abnormal_by_worst_grade( lyt, var, variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\"), na_str = default_na_str(), nested = TRUE, ..., .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_by_worst_grade( df, .var = \"GRADE_ANL\", .spl_context, variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\") ) a_count_abnormal_by_worst_grade( df, .var = \"GRADE_ANL\", .spl_context, variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"lyt (PreDataTableLayouts) layout analyses added . variables (named list string) list additional analysis variables. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function. .spl_context (data.frame) gives information ancestor split states passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"count_abnormal_by_worst_grade() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_by_worst_grade() table layout. s_count_abnormal_by_worst_grade() returns single statistic count_fraction grades 1 4 \"\" results. a_count_abnormal_by_worst_grade() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"count_abnormal_by_worst_grade(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_by_worst_grade(): Statistics function counts patients worst grade. a_count_abnormal_by_worst_grade(): Formatted analysis function used afun count_abnormal_by_worst_grade().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients by most extreme post-baseline toxicity grade per direction of abnormality — abnormal_by_worst_grade","text":"","code":"library(dplyr) library(forcats) adlb <- tern_ex_adlb # Data is modified in order to have some parameters with grades only in one direction # and simulate the real data. adlb$ATOXGR[adlb$PARAMCD == \"ALT\" & adlb$ATOXGR %in% c(\"1\", \"2\", \"3\", \"4\")] <- \"-1\" adlb$ANRIND[adlb$PARAMCD == \"ALT\" & adlb$ANRIND == \"HIGH\"] <- \"LOW\" adlb$WGRHIFL[adlb$PARAMCD == \"ALT\"] <- \"\" adlb$ATOXGR[adlb$PARAMCD == \"IGA\" & adlb$ATOXGR %in% c(\"-1\", \"-2\", \"-3\", \"-4\")] <- \"1\" adlb$ANRIND[adlb$PARAMCD == \"IGA\" & adlb$ANRIND == \"LOW\"] <- \"HIGH\" adlb$WGRLOFL[adlb$PARAMCD == \"IGA\"] <- \"\" # Pre-processing adlb_f <- adlb %>% h_adlb_abnormal_by_worst_grade() # Map excludes records without abnormal grade since they should not be displayed # in the table. map <- unique(adlb_f[adlb_f$GRADE_DIR != \"ZERO\", c(\"PARAM\", \"GRADE_DIR\", \"GRADE_ANL\")]) %>% lapply(as.character) %>% as.data.frame() %>% arrange(PARAM, desc(GRADE_DIR), GRADE_ANL) basic_table() %>% split_cols_by(\"ARMCD\") %>% split_rows_by(\"PARAM\") %>% split_rows_by(\"GRADE_DIR\", split_fun = trim_levels_to_map(map)) %>% count_abnormal_by_worst_grade( var = \"GRADE_ANL\", variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\") ) %>% build_table(df = adlb_f) #> ARM A ARM B ARM C #> ——————————————————————————————————————————————————————————————————————————— #> Alanine Aminotransferase Measurement #> LOW #> 1 12 (17.4%) 5 (6.8%) 8 (13.8%) #> 2 9 (13%) 13 (17.8%) 6 (10.3%) #> 3 6 (8.7%) 4 (5.5%) 6 (10.3%) #> 4 7 (10.1%) 7 (9.6%) 6 (10.3%) #> Any 34 (49.3%) 29 (39.7%) 26 (44.8%) #> C-Reactive Protein Measurement #> LOW #> 1 11 (15.9%) 12 (16.4%) 7 (12.1%) #> 2 8 (11.6%) 2 (2.7%) 6 (10.3%) #> 3 4 (5.8%) 9 (12.3%) 6 (10.3%) #> 4 7 (10.1%) 6 (8.2%) 4 (6.9%) #> Any 30 (43.5%) 29 (39.7%) 23 (39.7%) #> HIGH #> 1 8 (11.6%) 11 (15.1%) 2 (3.4%) #> 2 9 (13%) 11 (15.1%) 11 (19%) #> 3 14 (20.3%) 10 (13.7%) 5 (8.6%) #> 4 2 (2.9%) 4 (5.5%) 6 (10.3%) #> Any 33 (47.8%) 36 (49.3%) 24 (41.4%) #> Immunoglobulin A Measurement #> HIGH #> 1 7 (10.1%) 7 (9.6%) 6 (10.3%) #> 2 8 (11.6%) 6 (8.2%) 8 (13.8%) #> 3 7 (10.1%) 5 (6.8%) 9 (15.5%) #> 4 6 (8.7%) 2 (2.7%) 3 (5.2%) #> Any 28 (40.6%) 20 (27.4%) 26 (44.8%)"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade_worsen.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"analyze function count_abnormal_lab_worsen_by_baseline() creates layout element count patients analysis toxicity grades worsened baseline, categorized highest (worst) grade post-baseline. function analyzes primary analysis variable var indicates analysis toxicity grades. Additional analysis variables can supplied list via variables parameter id (defaults USUBJID), variable indicate unique subject identifiers, baseline_var (defaults BTOXGR), variable indicate baseline toxicity grades, direction_var (defaults GRADDIR), variable indicate toxicity grade directions interest include (e.g. \"H\" (high), \"L\" (low), \"B\" ()). direction(s) specified direction_var, patient counts worst grade patients worsened baseline calculated follows: 1 4: number patients worsened baseline grades worst grades 1-4, respectively. : total number patients worsened baseline grades. Fractions calculated dividing counts number patients analysis toxicity grades worsened baseline toxicity grades treatment. Prior using function table layout must use rtables::split_rows_by() create row split variable direction_var.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade_worsen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"","code":"count_abnormal_lab_worsen_by_baseline( lyt, var, variables = list(id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\"), na_str = default_na_str(), nested = TRUE, ..., table_names = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_abnormal_lab_worsen_by_baseline( df, .var = \"ATOXGR\", variables = list(id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\") ) a_count_abnormal_lab_worsen_by_baseline( df, .var = \"ATOXGR\", variables = list(id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade_worsen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"lyt (PreDataTableLayouts) layout analyses added . variables (named list string) list additional analysis variables including: id (string) subject variable name. baseline_var (string) name data column containing baseline toxicity variable. direction_var (string) see direction_var details. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade_worsen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"count_abnormal_lab_worsen_by_baseline() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_abnormal_lab_worsen_by_baseline() table layout. s_count_abnormal_lab_worsen_by_baseline() returns counts fraction patients whose worst post-baseline lab grades worse baseline grades, post-baseline worst grades \"1\", \"2\", \"3\", \"4\" \"\". a_count_abnormal_lab_worsen_by_baseline() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade_worsen.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"count_abnormal_lab_worsen_by_baseline(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_abnormal_lab_worsen_by_baseline(): Statistics function patients whose worst post-baseline lab grades worse baseline grades. a_count_abnormal_lab_worsen_by_baseline(): Formatted analysis function used afun count_abnormal_lab_worsen_by_baseline().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/abnormal_by_worst_grade_worsen.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline — abnormal_by_worst_grade_worsen","text":"","code":"library(dplyr) # The direction variable, GRADDR, is based on metadata adlb <- tern_ex_adlb %>% mutate( GRADDR = case_when( PARAMCD == \"ALT\" ~ \"B\", PARAMCD == \"CRP\" ~ \"L\", PARAMCD == \"IGA\" ~ \"H\" ) ) %>% filter(SAFFL == \"Y\" & ONTRTFL == \"Y\" & GRADDR != \"\") df <- h_adlb_worsen( adlb, worst_flag_low = c(\"WGRLOFL\" = \"Y\"), worst_flag_high = c(\"WGRHIFL\" = \"Y\"), direction_var = \"GRADDR\" ) basic_table() %>% split_cols_by(\"ARMCD\") %>% add_colcounts() %>% split_rows_by(\"PARAMCD\") %>% split_rows_by(\"GRADDR\") %>% count_abnormal_lab_worsen_by_baseline( var = \"ATOXGR\", variables = list( id = \"USUBJID\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\" ) ) %>% append_topleft(\"Direction of Abnormality\") %>% build_table(df = df, alt_counts_df = tern_ex_adsl) #> ARM A ARM B ARM C #> Direction of Abnormality (N=69) (N=73) (N=58) #> ———————————————————————————————————————————————————————————————————————— #> IGA #> High #> 1 6/63 (9.5%) 6/64 (9.4%) 4/50 (8%) #> 2 8/64 (12.5%) 5/67 (7.5%) 8/53 (15.1%) #> 3 7/66 (10.6%) 5/68 (7.4%) 9/57 (15.8%) #> 4 6/68 (8.8%) 2/72 (2.8%) 3/58 (5.2%) #> Any 27/68 (39.7%) 18/72 (25%) 24/58 (41.4%) #> ALT #> High #> 1 7/63 (11.1%) 6/62 (9.7%) 2/48 (4.2%) #> 2 12/63 (19%) 4/67 (6%) 11/50 (22%) #> 3 4/65 (6.2%) 11/71 (15.5%) 7/56 (12.5%) #> 4 1/67 (1.5%) 8/71 (11.3%) 4/57 (7%) #> Any 24/67 (35.8%) 29/71 (40.8%) 24/57 (42.1%) #> Low #> 1 12/67 (17.9%) 4/66 (6.1%) 7/52 (13.5%) #> 2 9/68 (13.2%) 12/69 (17.4%) 6/55 (10.9%) #> 3 6/69 (8.7%) 4/71 (5.6%) 5/56 (8.9%) #> 4 7/69 (10.1%) 7/73 (9.6%) 6/58 (10.3%) #> Any 34/69 (49.3%) 27/73 (37%) 24/58 (41.4%) #> CRP #> Low #> 1 11/66 (16.7%) 10/67 (14.9%) 4/47 (8.5%) #> 2 8/66 (12.1%) 1/70 (1.4%) 6/50 (12%) #> 3 4/68 (5.9%) 9/70 (12.9%) 5/53 (9.4%) #> 4 7/69 (10.1%) 6/72 (8.3%) 4/55 (7.3%) #> Any 30/69 (43.5%) 26/72 (36.1%) 19/55 (34.5%)"},{"path":"https://insightsengineering.github.io/tern/main/reference/add_riskdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Split function to configure risk difference column — add_riskdiff","title":"Split function to configure risk difference column — add_riskdiff","text":"Wrapper function rtables::add_combo_levels() configures settings risk difference column added rtables object. add risk difference column table, function used split_fun calls rtables::split_cols_by(), followed setting argument riskdiff TRUE following analyze function calls.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/add_riskdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split function to configure risk difference column — add_riskdiff","text":"","code":"add_riskdiff( arm_x, arm_y, col_label = paste0(\"Risk Difference (%) (95% CI)\", if (length(arm_y) > 1) paste0(\"\\n\", arm_x, \" vs. \", arm_y)), pct = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/add_riskdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split function to configure risk difference column — add_riskdiff","text":"arm_x (string) name reference arm use risk difference calculations. arm_y (character) names one arms compare reference arm risk difference calculations. new column added value arm_y. col_label (character) labels use rendering risk difference column within table. one comparison arm specified arm_y, default labels specify two arms compared (reference arm vs. comparison arm). pct (flag) whether output returned percentages. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/add_riskdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split function to configure risk difference column — add_riskdiff","text":"closure suitable use split function (split_fun) within rtables::split_cols_by() creating table layout.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/add_riskdiff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split function to configure risk difference column — add_riskdiff","text":"","code":"adae <- tern_ex_adae adae$AESEV <- factor(adae$AESEV) lyt <- basic_table() %>% split_cols_by(\"ARMCD\", split_fun = add_riskdiff(arm_x = \"ARM A\", arm_y = c(\"ARM B\", \"ARM C\"))) %>% count_occurrences_by_grade( var = \"AESEV\", riskdiff = TRUE ) tbl <- build_table(lyt, df = adae) tbl #> Risk Difference (%) (95% CI) Risk Difference (%) (95% CI) #> ARM A ARM B ARM C ARM A vs. ARM B ARM A vs. ARM C #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> MILD 6 (3.0%) 4 (2.3%) 2 (1.2%) 0.7 (-2.5 - 3.9) 1.7 (-1.2 - 4.6) #> MODERATE 19 (9.4%) 15 (8.5%) 14 (8.6%) 0.9 (-4.8 - 6.7) 0.8 (-5.1 - 6.7) #> SEVERE 34 (16.8%) 38 (21.5%) 32 (19.8%) -4.6 (-12.6 - 3.3) -2.9 (-10.9 - 5.1)"},{"path":"https://insightsengineering.github.io/tern/main/reference/add_rowcounts.html","id":null,"dir":"Reference","previous_headings":"","what":"Layout-creating function to add row total counts — add_rowcounts","title":"Layout-creating function to add row total counts — add_rowcounts","text":"works analogously rtables::add_colcounts() rows. function wrapper rtables::summarize_row_groups().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/add_rowcounts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Layout-creating function to add row total counts — add_rowcounts","text":"","code":"add_rowcounts(lyt, alt_counts = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/add_rowcounts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Layout-creating function to add row total counts — add_rowcounts","text":"lyt (PreDataTableLayouts) layout analyses added . alt_counts (flag) whether row counts taken alt_counts_df (TRUE) df (FALSE). Defaults FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/add_rowcounts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Layout-creating function to add row total counts — add_rowcounts","text":"modified layout latest row split labels now row-wise total counts (.e. without column-based subsetting) attached parentheses.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/add_rowcounts.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Layout-creating function to add row total counts — add_rowcounts","text":"Row count values contained row count rows displayed considered zero rows default pruning.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/add_rowcounts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Layout-creating function to add row total counts — add_rowcounts","text":"","code":"basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% split_rows_by(\"RACE\", split_fun = drop_split_levels) %>% add_rowcounts() %>% analyze(\"AGE\", afun = list_wrap_x(summary), format = \"xx.xx\") %>% build_table(DM) #> A: Drug X B: Placebo C: Combination #> (N=121) (N=106) (N=129) #> —————————————————————————————————————————————————————————————————————————— #> ASIAN (N=231) #> Min. 20.00 21.00 22.00 #> 1st Qu. 29.00 28.00 30.00 #> Median 33.00 32.50 33.50 #> Mean 34.20 32.68 34.63 #> 3rd Qu. 38.50 36.00 38.00 #> Max. 58.00 55.00 53.00 #> BLACK OR AFRICAN AMERICAN (N=79) #> Min. 23.00 21.00 24.00 #> 1st Qu. 29.00 28.75 29.00 #> Median 33.00 30.00 32.00 #> Mean 34.68 31.71 34.00 #> 3rd Qu. 37.25 36.25 39.00 #> Max. 60.00 42.00 51.00 #> WHITE (N=46) #> Min. 30.00 25.00 28.00 #> 1st Qu. 38.00 31.00 30.25 #> Median 40.50 37.50 35.00 #> Mean 39.36 36.93 35.11 #> 3rd Qu. 43.50 40.00 37.50 #> Max. 47.00 55.00 47.00"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/aesi_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for adverse event baskets — aesi_label","text":"","code":"aesi_label(aesi, scope = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/aesi_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for adverse event baskets — aesi_label","text":"aesi (character) vector standardized MedDRA query name (e.g. SMQxxNAM) customized query name (e.g. CQxxNAM). scope (character) vector scope query (e.g. SMQxxSC).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/aesi_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for adverse event baskets — aesi_label","text":"string standard label AE basket.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/aesi_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Labels for adverse event baskets — aesi_label","text":"","code":"adae <- tern_ex_adae # Standardized query label includes scope. aesi_label(adae$SMQ01NAM, scope = adae$SMQ01SC) #> [1] \"C.1.1.1.3/B.2.2.3.1 aesi (BROAD)\" # Customized query label. aesi_label(adae$CQ01NAM) #> [1] \"D.2.1.5.3/A.1.1.1.1 aesi\""},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_riskdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Analysis function to calculate risk difference column values — afun_riskdiff","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"risk difference column, function uses statistics function associated afun calculates risk difference values arm X (reference group) arm Y. arms specified configuring risk difference column done using add_riskdiff() split function previous call rtables::split_cols_by(). columns, applies afun usual. function utilizes stat_propdiff_ci() function perform risk difference calculations.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_riskdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"","code":"afun_riskdiff( df, labelstr = \"\", .var, .N_col, .N_row, .df_row, .spl_context, .all_col_counts, .stats, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str(), afun, s_args = list() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_riskdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .var (string) single variable name passed rtables requested statistics function. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .df_row (data.frame) data frame across columns given row split. .spl_context (data.frame) gives information ancestor split states passed rtables. .all_col_counts (integer) vector value represents global count column. Values taken alt_counts_df specified (see rtables::build_table()). .stats (character) statistics select table. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. na_str (string) string used replace NA empty values output. afun (named list) named list containing one name-value pair name corresponds name statistics function used calculations value corresponding analysis function. s_args (named list) additional arguments passed statistics function analysis function supplied afun.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_riskdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Analysis function to calculate risk difference column values — afun_riskdiff","text":"list formatted rtables::CellValue().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_selected_stats.html","id":null,"dir":"Reference","previous_headings":"","what":"Get selected statistics names — afun_selected_stats","title":"Get selected statistics names — afun_selected_stats","text":"Helper function used creating afun.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_selected_stats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get selected statistics names — afun_selected_stats","text":"","code":"afun_selected_stats(.stats, all_stats)"},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_selected_stats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get selected statistics names — afun_selected_stats","text":".stats (vector NULL) input layout creating function. Note NULL means context default statistics used. all_stats (character) statistics can selected potentially.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/afun_selected_stats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get selected statistics names — afun_selected_stats","text":"character vector selected statistics.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_colvars_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze functions in columns — analyze_colvars_functions","title":"Analyze functions in columns — analyze_colvars_functions","text":"functions wrappers rtables::analyze_colvars() apply corresponding tern statistics functions add analysis given table layout. particular, functions designed analysis methods split different columns. analyze_vars_in_cols(): fundamental tabulation analysis methods onto columns. words, analysis methods defined column space, .e. become column labels. changing variable vector, list functions can applied different variables, caveat number statistical functions. tabulate_rsp_subgroups(): similarly analyze_vars_in_cols, function combines analyze_colvars summarize_row_groups compact way produce standard tables show analysis methods columns. tabulate_survival_subgroups(): function similar , used tables. analyze_patients_exposure_in_cols(): based analyze_colvars. needs summarize_patients_exposure_in_cols() leverage nesting label rows analysis rtables::summarize_row_groups(). summarize_coxreg(): generally based rtables::summarize_row_groups(), behaves similarly tabulate_* functions described designed provide specific standard tables may contain nested structure combination summarize_row_groups() rtables::analyze_colvars().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze functions — analyze_functions","title":"Analyze functions — analyze_functions","text":"functions wrappers rtables::analyze() apply corresponding tern statistics functions add analysis given table layout: analyze_num_patients() analyze_vars() compare_vars() count_abnormal() count_abnormal_by_baseline() count_abnormal_by_marked() count_abnormal_by_worst_grade() count_cumulative() count_missed_doses() count_occurrences() count_occurrences_by_grade() count_patients_events_in_cols() count_patients_with_event() count_patients_with_flags() count_values() coxph_pairwise() estimate_incidence_rate() estimate_multinomial_rsp() estimate_odds_ratio() estimate_proportion() estimate_proportion_diff() summarize_ancova() summarize_colvars(): even function uses rtables::analyze_colvars(), applies analysis methods different rows one variables split different columns. comparison, analyze_colvars_functions leverage analyze_colvars context split rows analysis methods columns. summarize_change() surv_time() surv_timepoint() test_proportion_diff()","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze variables — analyze_variables","title":"Analyze variables — analyze_variables","text":"analyze function analyze_vars() creates layout element summarize one variables, using S3 generic function s_summary() calculate list summary statistics. list available statistics numeric variables can viewed running get_stats(\"analyze_vars_numeric\") non-numeric variables running get_stats(\"analyze_vars_counts\"). Use .stats parameter specify statistics include output summary table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analyze variables — analyze_variables","text":"","code":"analyze_vars( lyt, vars, var_labels = vars, na_str = default_na_str(), nested = TRUE, ..., na.rm = TRUE, show_labels = \"default\", table_names = vars, section_div = NA_character_, .stats = c(\"n\", \"mean_sd\", \"median\", \"range\", \"count_fraction\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_summary(x, na.rm = TRUE, denom, .N_row, .N_col, .var, ...) # S3 method for class 'numeric' s_summary( x, na.rm = TRUE, denom, .N_row, .N_col, .var, control = control_analyze_vars(), ... ) # S3 method for class 'factor' s_summary( x, na.rm = TRUE, denom = c(\"n\", \"N_col\", \"N_row\"), .N_row, .N_col, ... ) # S3 method for class 'character' s_summary( x, na.rm = TRUE, denom = c(\"n\", \"N_col\", \"N_row\"), .N_row, .N_col, .var, verbose = TRUE, ... ) # S3 method for class 'logical' s_summary( x, na.rm = TRUE, denom = c(\"n\", \"N_col\", \"N_row\"), .N_row, .N_col, ... ) a_summary( x, .N_col, .N_row, .var = NULL, .df_row = NULL, .ref_group = NULL, .in_ref_col = FALSE, compare = FALSE, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na.rm = TRUE, na_str = default_na_str(), ... )"},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analyze variables — analyze_variables","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... arguments passed s_summary(). na.rm (flag) whether NA values removed x prior analysis. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. .stats (character) statistics select table. Options numeric variables : 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d' Options non-numeric variables : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. x (numeric) vector numbers want analyze. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .var (string) single variable name passed rtables requested statistics function. control (list) parameters descriptive statistics details, specified using helper function control_analyze_vars(). possible parameter options : conf_level (proportion) confidence level interval mean median. quantiles (numeric(2)) vector length two specify quantiles. quantile_type (numeric(1)) 1 9 selecting quantile algorithms used. See type stats::quantile(). test_mean (numeric(1)) value test mean null hypothesis calculating p-value. verbose (flag) defaults TRUE, prints warnings messages. mainly used print information factor casting. .df_row (data.frame) data frame across columns given row split. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. compare (flag) whether comparison statistics analyzed instead summary statistics (compare = TRUE adds pval statistic comparing reference group).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Analyze variables — analyze_variables","text":"analyze_vars() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_summary() table layout. s_summary() returns different statistics depending class x. x class numeric, returns list following named numeric items: n: length() x. sum: sum() x. mean: mean() x. sd: stats::sd() x. se: standard error x mean, .e.: (sd(x) / sqrt(length(x))). mean_sd: mean() stats::sd() x. mean_se: mean() x standard error (see ). mean_ci: CI mean x (stat_mean_ci()). mean_sei: SE interval mean x, .e.: (mean() -/+ stats::sd() / sqrt()). mean_sdi: SD interval mean x, .e.: (mean() -/+ stats::sd()). mean_pval: two-sided p-value mean x (stat_mean_pval()). median: stats::median() x. mad: median absolute deviation x, .e.: (stats::median() xc, xc = x - stats::median()). median_ci: CI median x (stat_median_ci()). quantiles: Two sample quantiles x (stats::quantile()). iqr: stats::IQR() x. range: range_noinf() x. min: max() x. max: min() x. median_range: median() range_noinf() x. cv: coefficient variation x, .e.: (stats::sd() / mean() * 100). geom_mean: geometric mean x, .e.: (exp(mean(log(x)))). geom_cv: geometric coefficient variation x, .e.: (sqrt(exp(sd(log(x)) ^ 2) - 1) * 100). x class factor converted character, returns list named numeric items: n: length() x. count: list number cases level factor x. count_fraction: Similar count also includes proportion cases level factor x relative denominator, NA denominator zero. x class logical, returns list named numeric items: n: length() x (possibly removing NAs). count: Count TRUE x. count_fraction: Count proportion TRUE x relative denominator, NA denominator zero. Note NAs x never counted leading NA . a_summary() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Analyze variables — analyze_variables","text":"Automatic digit formatting: number digits display can automatically determined analyzed variable(s) (vars) certain statistics setting statistic format \"auto\" .formats. utilizes format_auto() formatting function. Note data current row & variable (columns) considered (.df_row[[.var]], see rtables::additional_fun_params) whole dataset.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Analyze variables — analyze_variables","text":"analyze_vars(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_summary(): S3 generic function produces variable summary. s_summary(numeric): Method numeric class. s_summary(factor): Method factor class. s_summary(character): Method character class. makes automatic conversion factor (warning) forwards method factors. s_summary(logical): Method logical class. a_summary(): Formatted analysis function used afun analyze_vars() compare_vars() cfun summarize_colvars().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Analyze variables — analyze_variables","text":"x empty vector, NA returned. expected feature return rcell content rtables intersection column row delimits empty data selection. mean function applied empty vector, NA returned instead NaN, latter standard behavior R. x empty factor, list still returned counts one element per factor level. levels x, function fails. factor variables contain NA, NA values excluded default. include NA values set na.rm = FALSE missing values displayed NA level. Alternatively, explicit factor level can defined NA values pre-processing via df_explicit_na() - default na_level (\"\") also excluded na.rm set TRUE. Automatic conversion character factor guarantee table can generated correctly. particular sparse tables likely can fail. therefore better always pre-process dataset factors manually created character variables passing dataset rtables::build_table(). use comparison (additional p-value statistic), parameter compare must set TRUE. Ensure either NA values converted explicit NA level NA values left .","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_variables.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Analyze variables — analyze_variables","text":"","code":"## Fabricated dataset. dta_test <- data.frame( USUBJID = rep(1:6, each = 3), PARAMCD = rep(\"lab\", 6 * 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)) ) # `analyze_vars()` in `rtables` pipelines ## Default output within a `rtables` pipeline. l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\") build_table(l, df = dta_test) #> A B C #> ———————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.5 (2.1) 3.0 (NA) NA #> Median 7.5 3.0 NA #> Min - Max 6.0 - 9.0 3.0 - 3.0 NA #> V2 #> n 2 1 0 #> Mean (SD) 6.5 (2.1) 2.0 (NA) NA #> Median 6.5 2.0 NA #> Min - Max 5.0 - 8.0 2.0 - 2.0 NA #> V3 #> n 2 1 0 #> Mean (SD) 5.5 (2.1) 1.0 (NA) NA #> Median 5.5 1.0 NA #> Min - Max 4.0 - 7.0 1.0 - 1.0 NA ## Select and format statistics output. l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars( vars = \"AVAL\", .stats = c(\"n\", \"mean_sd\", \"quantiles\"), .formats = c(\"mean_sd\" = \"xx.x, xx.x\"), .labels = c(n = \"n\", mean_sd = \"Mean, SD\", quantiles = c(\"Q1 - Q3\")) ) build_table(l, df = dta_test) #> A B C #> ——————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean, SD 7.5, 2.1 3.0, NA NA #> Q1 - Q3 6.0 - 9.0 3.0 - 3.0 NA #> V2 #> n 2 1 0 #> Mean, SD 6.5, 2.1 2.0, NA NA #> Q1 - Q3 5.0 - 8.0 2.0 - 2.0 NA #> V3 #> n 2 1 0 #> Mean, SD 5.5, 2.1 1.0, NA NA #> Q1 - Q3 4.0 - 7.0 1.0 - 1.0 NA ## Use arguments interpreted by `s_summary`. l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\", na.rm = FALSE) build_table(l, df = dta_test) #> A B C #> ————————————————————————————————— #> V1 #> n 2 2 2 #> Mean (SD) 7.5 (2.1) NA NA #> Median 7.5 NA NA #> Min - Max 6.0 - 9.0 NA NA #> V2 #> n 2 2 2 #> Mean (SD) 6.5 (2.1) NA NA #> Median 6.5 NA NA #> Min - Max 5.0 - 8.0 NA NA #> V3 #> n 2 2 2 #> Mean (SD) 5.5 (2.1) NA NA #> Median 5.5 NA NA #> Min - Max 4.0 - 7.0 NA NA ## Handle `NA` levels first when summarizing factors. dta_test$AVISIT <- NA_character_ dta_test <- df_explicit_na(dta_test) l <- basic_table() %>% split_cols_by(var = \"ARM\") %>% analyze_vars(vars = \"AVISIT\", na.rm = FALSE) build_table(l, df = dta_test) #> A B C #> —————————————————————————————————————————— #> n 6 6 6 #> 6 (100%) 6 (100%) 6 (100%) # auto format dt <- data.frame(\"VAR\" = c(0.001, 0.2, 0.0011000, 3, 4)) basic_table() %>% analyze_vars( vars = \"VAR\", .stats = c(\"n\", \"mean\", \"mean_sd\", \"range\"), .formats = c(\"mean_sd\" = \"auto\", \"range\" = \"auto\") ) %>% build_table(dt) #> all obs #> ————————————————————————————— #> n 5 #> Mean 1.4 #> Mean (SD) 1.44042 (1.91481) #> Min - Max 0.0010 - 4.0000 # `s_summary.numeric` ## Basic usage: empty numeric returns NA-filled items. s_summary(numeric()) #> $n #> n #> 0 #> #> $sum #> sum #> NA #> #> $mean #> mean #> NA #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> NA NA #> #> $mean_se #> mean se #> NA NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> NA #> #> $mad #> mad #> NA #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> NA #> #> $range #> min max #> NA NA #> #> $min #> min #> NA #> #> $max #> max #> NA #> #> $median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> NaN #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> ## Management of NA values. x <- c(NA_real_, 1) s_summary(x, na.rm = TRUE) #> $n #> n #> 1 #> #> $sum #> sum #> 1 #> #> $mean #> mean #> 1 #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> 1 NA #> #> $mean_se #> mean se #> 1 NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 1 NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 1 #> #> $mad #> mad #> 0 #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 1 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 1 1 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 0 #> #> $range #> min max #> 1 1 #> #> $min #> min #> 1 #> #> $max #> max #> 1 #> #> $median_range #> median min max #> 1 1 1 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> 1 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 1 NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> s_summary(x, na.rm = FALSE) #> $n #> n #> 2 #> #> $sum #> sum #> NA #> #> $mean #> mean #> NA #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> NA NA #> #> $mean_se #> mean se #> NA NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> NA #> #> $mad #> mad #> NA #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> NA #> #> $range #> min max #> NA NA #> #> $min #> min #> NA #> #> $max #> max #> NA #> #> $median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> NA #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> x <- c(NA_real_, 1, 2) s_summary(x, stats = NULL) #> $n #> n #> 2 #> #> $sum #> sum #> 3 #> #> $mean #> mean #> 1.5 #> #> $sd #> sd #> 0.7071068 #> #> $se #> se #> 0.5 #> #> $mean_sd #> mean sd #> 1.5000000 0.7071068 #> #> $mean_se #> mean se #> 1.5 0.5 #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> 1 2 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 0.7928932 2.2071068 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 1.500000 -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> 0.2048328 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 1.5 #> #> $mad #> mad #> 0 #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 1.5 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 1 2 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 1 #> #> $range #> min max #> 1 2 #> #> $min #> min #> 1 #> #> $max #> max #> 2 #> #> $median_range #> median min max #> 1.5 1.0 2.0 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> 47.14045 #> #> $geom_mean #> geom_mean #> 1.414214 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> 52.10922 #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 1.41421356 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> ## Benefits in `rtables` contructions: dta_test <- data.frame( Group = rep(LETTERS[1:3], each = 2), sub_group = rep(letters[1:2], each = 3), x = 1:6 ) ## The summary obtained in with `rtables`: basic_table() %>% split_cols_by(var = \"Group\") %>% split_rows_by(var = \"sub_group\") %>% analyze(vars = \"x\", afun = s_summary) %>% build_table(df = dta_test) #> A B C #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> a #> n 2 1 0 #> sum 3 3 NA #> mean 1.5 3 NA #> sd 0.707106781186548 NA NA #> se 0.5 NA NA #> mean_sd 1.5, 0.707106781186548 3, NA NA #> mean_se 1.5, 0.5 3, NA NA #> Mean 95% CI -4.85310236808735, 7.85310236808735 NA NA #> Mean -/+ 1xSE 1, 2 NA NA #> Mean -/+ 1xSD 0.792893218813452, 2.20710678118655 NA NA #> Mean (95% CI) 1.5, -4.85310236808735, 7.85310236808735 3, NA, NA NA #> Mean p-value (H0: mean = 0) 0.204832764699133 NA NA #> median 1.5 3 NA #> mad 0 0 NA #> Median 95% CI NA NA NA #> Median (95% CI) 1.5, NA, NA 3, NA, NA NA #> 25% and 75%-ile 1, 2 3, 3 NA #> iqr 1 0 NA #> range 1, 2 3, 3 NA #> min 1 3 NA #> max 2 3 NA #> Median (Min - Max) 1.5, 1, 2 3, 3, 3 NA #> cv 47.1404520791032 NA NA #> geom_mean 1.41421356237309 3 NA #> Geometric Mean 95% CI 0.0172997815631007, 115.608396135236 NA NA #> geom_cv 52.1092246837487 NA NA #> Geometric Mean (95% CI) 1.41421356237309, 0.0172997815631007, 115.608396135236 3, NA, NA NA #> b #> n 0 1 2 #> sum NA 4 11 #> mean NA 4 5.5 #> sd NA NA 0.707106781186548 #> se NA NA 0.5 #> mean_sd NA 4, NA 5.5, 0.707106781186548 #> mean_se NA 4, NA 5.5, 0.5 #> Mean 95% CI NA NA -0.853102368087347, 11.8531023680873 #> Mean -/+ 1xSE NA NA 5, 6 #> Mean -/+ 1xSD NA NA 4.79289321881345, 6.20710678118655 #> Mean (95% CI) NA 4, NA, NA 5.5, -0.853102368087347, 11.8531023680873 #> Mean p-value (H0: mean = 0) NA NA 0.0577158767526089 #> median NA 4 5.5 #> mad NA 0 0 #> Median 95% CI NA NA NA #> Median (95% CI) NA 4, NA, NA 5.5, NA, NA #> 25% and 75%-ile NA 4, 4 5, 6 #> iqr NA 0 1 #> range NA 4, 4 5, 6 #> min NA 4 5 #> max NA 4 6 #> Median (Min - Max) NA 4, 4, 4 5.5, 5, 6 #> cv NA NA 12.8564869306645 #> geom_mean NA 4 5.47722557505166 #> Geometric Mean 95% CI NA NA 1.71994304449266, 17.4424380482025 #> geom_cv NA NA 12.945835316564 #> Geometric Mean (95% CI) NA 4, NA, NA 5.47722557505166, 1.71994304449266, 17.4424380482025 ## By comparison with `lapply`: X <- split(dta_test, f = with(dta_test, interaction(Group, sub_group))) lapply(X, function(x) s_summary(x$x)) #> $A.a #> $A.a$n #> n #> 2 #> #> $A.a$sum #> sum #> 3 #> #> $A.a$mean #> mean #> 1.5 #> #> $A.a$sd #> sd #> 0.7071068 #> #> $A.a$se #> se #> 0.5 #> #> $A.a$mean_sd #> mean sd #> 1.5000000 0.7071068 #> #> $A.a$mean_se #> mean se #> 1.5 0.5 #> #> $A.a$mean_ci #> mean_ci_lwr mean_ci_upr #> -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $A.a$mean_sei #> mean_sei_lwr mean_sei_upr #> 1 2 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $A.a$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 0.7928932 2.2071068 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $A.a$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 1.500000 -4.853102 7.853102 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $A.a$mean_pval #> p_value #> 0.2048328 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $A.a$median #> median #> 1.5 #> #> $A.a$mad #> mad #> 0 #> #> $A.a$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $A.a$median_ci_3d #> median median_ci_lwr median_ci_upr #> 1.5 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $A.a$quantiles #> quantile_0.25 quantile_0.75 #> 1 2 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $A.a$iqr #> iqr #> 1 #> #> $A.a$range #> min max #> 1 2 #> #> $A.a$min #> min #> 1 #> #> $A.a$max #> max #> 2 #> #> $A.a$median_range #> median min max #> 1.5 1.0 2.0 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $A.a$cv #> cv #> 47.14045 #> #> $A.a$geom_mean #> geom_mean #> 1.414214 #> #> $A.a$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $A.a$geom_cv #> geom_cv #> 52.10922 #> #> $A.a$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 1.41421356 0.01729978 115.60839614 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $B.a #> $B.a$n #> n #> 1 #> #> $B.a$sum #> sum #> 3 #> #> $B.a$mean #> mean #> 3 #> #> $B.a$sd #> sd #> NA #> #> $B.a$se #> se #> NA #> #> $B.a$mean_sd #> mean sd #> 3 NA #> #> $B.a$mean_se #> mean se #> 3 NA #> #> $B.a$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $B.a$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $B.a$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $B.a$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 3 NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $B.a$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $B.a$median #> median #> 3 #> #> $B.a$mad #> mad #> 0 #> #> $B.a$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $B.a$median_ci_3d #> median median_ci_lwr median_ci_upr #> 3 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $B.a$quantiles #> quantile_0.25 quantile_0.75 #> 3 3 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $B.a$iqr #> iqr #> 0 #> #> $B.a$range #> min max #> 3 3 #> #> $B.a$min #> min #> 3 #> #> $B.a$max #> max #> 3 #> #> $B.a$median_range #> median min max #> 3 3 3 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $B.a$cv #> cv #> NA #> #> $B.a$geom_mean #> geom_mean #> 3 #> #> $B.a$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $B.a$geom_cv #> geom_cv #> NA #> #> $B.a$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 3 NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $C.a #> $C.a$n #> n #> 0 #> #> $C.a$sum #> sum #> NA #> #> $C.a$mean #> mean #> NA #> #> $C.a$sd #> sd #> NA #> #> $C.a$se #> se #> NA #> #> $C.a$mean_sd #> mean sd #> NA NA #> #> $C.a$mean_se #> mean se #> NA NA #> #> $C.a$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $C.a$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $C.a$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $C.a$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $C.a$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $C.a$median #> median #> NA #> #> $C.a$mad #> mad #> NA #> #> $C.a$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $C.a$median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $C.a$quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $C.a$iqr #> iqr #> NA #> #> $C.a$range #> min max #> NA NA #> #> $C.a$min #> min #> NA #> #> $C.a$max #> max #> NA #> #> $C.a$median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $C.a$cv #> cv #> NA #> #> $C.a$geom_mean #> geom_mean #> NaN #> #> $C.a$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $C.a$geom_cv #> geom_cv #> NA #> #> $C.a$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $A.b #> $A.b$n #> n #> 0 #> #> $A.b$sum #> sum #> NA #> #> $A.b$mean #> mean #> NA #> #> $A.b$sd #> sd #> NA #> #> $A.b$se #> se #> NA #> #> $A.b$mean_sd #> mean sd #> NA NA #> #> $A.b$mean_se #> mean se #> NA NA #> #> $A.b$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $A.b$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $A.b$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $A.b$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $A.b$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $A.b$median #> median #> NA #> #> $A.b$mad #> mad #> NA #> #> $A.b$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $A.b$median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $A.b$quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $A.b$iqr #> iqr #> NA #> #> $A.b$range #> min max #> NA NA #> #> $A.b$min #> min #> NA #> #> $A.b$max #> max #> NA #> #> $A.b$median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $A.b$cv #> cv #> NA #> #> $A.b$geom_mean #> geom_mean #> NaN #> #> $A.b$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $A.b$geom_cv #> geom_cv #> NA #> #> $A.b$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $B.b #> $B.b$n #> n #> 1 #> #> $B.b$sum #> sum #> 4 #> #> $B.b$mean #> mean #> 4 #> #> $B.b$sd #> sd #> NA #> #> $B.b$se #> se #> NA #> #> $B.b$mean_sd #> mean sd #> 4 NA #> #> $B.b$mean_se #> mean se #> 4 NA #> #> $B.b$mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $B.b$mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $B.b$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $B.b$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 4 NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $B.b$mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $B.b$median #> median #> 4 #> #> $B.b$mad #> mad #> 0 #> #> $B.b$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $B.b$median_ci_3d #> median median_ci_lwr median_ci_upr #> 4 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $B.b$quantiles #> quantile_0.25 quantile_0.75 #> 4 4 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $B.b$iqr #> iqr #> 0 #> #> $B.b$range #> min max #> 4 4 #> #> $B.b$min #> min #> 4 #> #> $B.b$max #> max #> 4 #> #> $B.b$median_range #> median min max #> 4 4 4 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $B.b$cv #> cv #> NA #> #> $B.b$geom_mean #> geom_mean #> 4 #> #> $B.b$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $B.b$geom_cv #> geom_cv #> NA #> #> $B.b$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 4 NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> #> $C.b #> $C.b$n #> n #> 2 #> #> $C.b$sum #> sum #> 11 #> #> $C.b$mean #> mean #> 5.5 #> #> $C.b$sd #> sd #> 0.7071068 #> #> $C.b$se #> se #> 0.5 #> #> $C.b$mean_sd #> mean sd #> 5.5000000 0.7071068 #> #> $C.b$mean_se #> mean se #> 5.5 0.5 #> #> $C.b$mean_ci #> mean_ci_lwr mean_ci_upr #> -0.8531024 11.8531024 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $C.b$mean_sei #> mean_sei_lwr mean_sei_upr #> 5 6 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $C.b$mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 4.792893 6.207107 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $C.b$mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 5.5000000 -0.8531024 11.8531024 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $C.b$mean_pval #> p_value #> 0.05771588 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $C.b$median #> median #> 5.5 #> #> $C.b$mad #> mad #> 0 #> #> $C.b$median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $C.b$median_ci_3d #> median median_ci_lwr median_ci_upr #> 5.5 NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $C.b$quantiles #> quantile_0.25 quantile_0.75 #> 5 6 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $C.b$iqr #> iqr #> 1 #> #> $C.b$range #> min max #> 5 6 #> #> $C.b$min #> min #> 5 #> #> $C.b$max #> max #> 6 #> #> $C.b$median_range #> median min max #> 5.5 5.0 6.0 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $C.b$cv #> cv #> 12.85649 #> #> $C.b$geom_mean #> geom_mean #> 5.477226 #> #> $C.b$geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 1.719943 17.442438 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $C.b$geom_cv #> geom_cv #> 12.94584 #> #> $C.b$geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 5.477226 1.719943 17.442438 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> # `s_summary.factor` ## Basic usage: s_summary(factor(c(\"a\", \"a\", \"b\", \"c\", \"a\"))) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> # Empty factor returns zero-filled items. s_summary(factor(levels = c(\"a\", \"b\", \"c\"))) #> $n #> [1] 0 #> #> $count #> $count$a #> [1] 0 #> #> $count$b #> [1] 0 #> #> $count$c #> [1] 0 #> #> #> $count_fraction #> $count_fraction$a #> [1] 0 0 #> #> $count_fraction$b #> [1] 0 0 #> #> $count_fraction$c #> [1] 0 0 #> #> #> $fraction #> $fraction$a #> num denom #> 0 0 #> #> $fraction$b #> num denom #> 0 0 #> #> $fraction$c #> num denom #> 0 0 #> #> #> $n_blq #> [1] 0 #> ## Management of NA values. x <- factor(c(NA, \"Female\")) x <- explicit_na(x) s_summary(x, na.rm = TRUE) #> $n #> [1] 1 #> #> $count #> $count$Female #> [1] 1 #> #> #> $count_fraction #> $count_fraction$Female #> [1] 1 1 #> #> #> $fraction #> $fraction$Female #> num denom #> 1 1 #> #> #> $n_blq #> [1] 0 #> s_summary(x, na.rm = FALSE) #> $n #> [1] 2 #> #> $count #> $count$Female #> [1] 1 #> #> $count$`` #> [1] 1 #> #> #> $count_fraction #> $count_fraction$Female #> [1] 1.0 0.5 #> #> $count_fraction$`` #> [1] 1.0 0.5 #> #> #> $fraction #> $fraction$Female #> num denom #> 1 2 #> #> $fraction$`` #> num denom #> 1 2 #> #> #> $n_blq #> [1] 0 #> ## Different denominators. x <- factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")) s_summary(x, denom = \"N_row\", .N_row = 10L) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.3 #> #> $count_fraction$b #> [1] 1.0 0.1 #> #> $count_fraction$c #> [1] 1.0 0.1 #> #> #> $fraction #> $fraction$a #> num denom #> 3 10 #> #> $fraction$b #> num denom #> 1 10 #> #> $fraction$c #> num denom #> 1 10 #> #> #> $n_blq #> [1] 0 #> s_summary(x, denom = \"N_col\", .N_col = 20L) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.00 0.15 #> #> $count_fraction$b #> [1] 1.00 0.05 #> #> $count_fraction$c #> [1] 1.00 0.05 #> #> #> $fraction #> $fraction$a #> num denom #> 3 20 #> #> $fraction$b #> num denom #> 1 20 #> #> $fraction$c #> num denom #> 1 20 #> #> #> $n_blq #> [1] 0 #> # `s_summary.character` ## Basic usage: s_summary(c(\"a\", \"a\", \"b\", \"c\", \"a\"), .var = \"x\", verbose = FALSE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> s_summary(c(\"a\", \"a\", \"b\", \"c\", \"a\", \"\"), .var = \"x\", na.rm = FALSE, verbose = FALSE) #> $n #> [1] 6 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> $count$`NA` #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.5 #> #> $count_fraction$b #> [1] 1.0000000 0.1666667 #> #> $count_fraction$c #> [1] 1.0000000 0.1666667 #> #> $count_fraction$`NA` #> [1] 1.0000000 0.1666667 #> #> #> $fraction #> $fraction$a #> num denom #> 3 6 #> #> $fraction$b #> num denom #> 1 6 #> #> $fraction$c #> num denom #> 1 6 #> #> $fraction$`NA` #> num denom #> 1 6 #> #> #> $n_blq #> [1] 0 #> # `s_summary.logical` ## Basic usage: s_summary(c(TRUE, FALSE, TRUE, TRUE)) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.00 0.75 #> #> $n_blq #> [1] 0 #> # Empty factor returns zero-filled items. s_summary(as.logical(c())) #> $n #> [1] 0 #> #> $count #> [1] 0 #> #> $count_fraction #> [1] 0 0 #> #> $n_blq #> [1] 0 #> ## Management of NA values. x <- c(NA, TRUE, FALSE) s_summary(x, na.rm = TRUE) #> $n #> [1] 2 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0 0.5 #> #> $n_blq #> [1] 0 #> s_summary(x, na.rm = FALSE) #> $n #> [1] 3 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0000000 0.3333333 #> #> $n_blq #> [1] 0 #> ## Different denominators. x <- c(TRUE, FALSE, TRUE, TRUE) s_summary(x, denom = \"N_row\", .N_row = 10L) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.0 0.3 #> #> $n_blq #> [1] 0 #> s_summary(x, denom = \"N_col\", .N_col = 20L) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.00 0.15 #> #> $n_blq #> [1] 0 #> a_summary(factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")), .N_row = 10, .N_col = 10) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 5 0 n #> 2 count.a 3 0 a #> 3 count.b 1 0 b #> 4 count.c 1 0 c #> 5 count_fraction.a 3 (60%) 0 a #> 6 count_fraction.b 1 (20%) 0 b #> 7 count_fraction.c 1 (20%) 0 c #> 8 count_fraction_fixed_dp.a 3 (60.0%) 0 a #> 9 count_fraction_fixed_dp.b 1 (20.0%) 0 b #> 10 count_fraction_fixed_dp.c 1 (20.0%) 0 c #> 11 fraction.a 3/5 (60.0%) 0 a #> 12 fraction.b 1/5 (20.0%) 0 b #> 13 fraction.c 1/5 (20.0%) 0 c #> 14 n_blq 0 0 n_blq a_summary( factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")), .ref_group = factor(c(\"a\", \"a\", \"b\", \"c\")), compare = TRUE ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 n 5 0 #> 2 count.a 3 0 #> 3 count.b 1 0 #> 4 count.c 1 0 #> 5 count_fraction.a 3 (60%) 0 #> 6 count_fraction.b 1 (20%) 0 #> 7 count_fraction.c 1 (20%) 0 #> 8 count_fraction_fixed_dp.a 3 (60.0%) 0 #> 9 count_fraction_fixed_dp.b 1 (20.0%) 0 #> 10 count_fraction_fixed_dp.c 1 (20.0%) 0 #> 11 fraction.a 3/5 (60.0%) 0 #> 12 fraction.b 1/5 (20.0%) 0 #> 13 fraction.c 1/5 (20.0%) 0 #> 14 n_blq 0 0 #> 15 pval_counts 0.9560 0 #> row_label #> 1 n #> 2 a #> 3 b #> 4 c #> 5 a #> 6 b #> 7 c #> 8 a #> 9 b #> 10 c #> 11 a #> 12 b #> 13 c #> 14 n_blq #> 15 p-value (chi-squared test) a_summary(c(\"A\", \"B\", \"A\", \"C\"), .var = \"x\", .N_col = 10, .N_row = 10, verbose = FALSE) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 4 0 n #> 2 count.A 2 0 A #> 3 count.B 1 0 B #> 4 count.C 1 0 C #> 5 count_fraction.A 2 (50%) 0 A #> 6 count_fraction.B 1 (25%) 0 B #> 7 count_fraction.C 1 (25%) 0 C #> 8 count_fraction_fixed_dp.A 2 (50.0%) 0 A #> 9 count_fraction_fixed_dp.B 1 (25.0%) 0 B #> 10 count_fraction_fixed_dp.C 1 (25.0%) 0 C #> 11 fraction.A 2/4 (50.0%) 0 A #> 12 fraction.B 1/4 (25.0%) 0 B #> 13 fraction.C 1/4 (25.0%) 0 C #> 14 n_blq 0 0 n_blq a_summary( c(\"A\", \"B\", \"A\", \"C\"), .ref_group = c(\"B\", \"A\", \"C\"), .var = \"x\", compare = TRUE, verbose = FALSE ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 n 4 0 #> 2 count.A 2 0 #> 3 count.B 1 0 #> 4 count.C 1 0 #> 5 count_fraction.A 2 (50%) 0 #> 6 count_fraction.B 1 (25%) 0 #> 7 count_fraction.C 1 (25%) 0 #> 8 count_fraction_fixed_dp.A 2 (50.0%) 0 #> 9 count_fraction_fixed_dp.B 1 (25.0%) 0 #> 10 count_fraction_fixed_dp.C 1 (25.0%) 0 #> 11 fraction.A 2/4 (50.0%) 0 #> 12 fraction.B 1/4 (25.0%) 0 #> 13 fraction.C 1/4 (25.0%) 0 #> 14 n_blq 0 0 #> 15 pval_counts 0.9074 0 #> row_label #> 1 n #> 2 A #> 3 B #> 4 C #> 5 A #> 6 B #> 7 C #> 8 A #> 9 B #> 10 C #> 11 A #> 12 B #> 13 C #> 14 n_blq #> 15 p-value (chi-squared test) a_summary(c(TRUE, FALSE, FALSE, TRUE, TRUE), .N_row = 10, .N_col = 10) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 5 0 n #> 2 count 3 0 count #> 3 count_fraction 3 (60%) 0 count_fraction #> 4 count_fraction_fixed_dp 3 (60.0%) 0 count_fraction #> 5 fraction 0 fraction #> 6 n_blq 0 0 n_blq a_summary( c(TRUE, FALSE, FALSE, TRUE, TRUE), .ref_group = c(TRUE, FALSE), .in_ref_col = TRUE, compare = TRUE ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 5 0 n #> 2 count 3 0 count #> 3 count_fraction 3 (60%) 0 count_fraction #> 4 count_fraction_fixed_dp 3 (60.0%) 0 count_fraction #> 5 fraction 0 fraction #> 6 n_blq 0 0 n_blq #> 7 pval_counts 0 p-value (chi-squared test) a_summary(rnorm(10), .N_col = 10, .N_row = 20, .var = \"bla\") #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 10 0 n #> 2 sum -4.4 0 Sum #> 3 mean -0.4 0 Mean #> 4 sd 1.1 0 SD #> 5 se 0.4 0 SE #> 6 mean_sd -0.4 (1.1) 0 Mean (SD) #> 7 mean_se -0.4 (0.4) 0 Mean (SE) #> 8 mean_ci (-1.24, 0.36) 0 Mean 95% CI #> 9 mean_sei (-0.79, -0.09) 0 Mean -/+ 1xSE #> 10 mean_sdi (-1.56, 0.68) 0 Mean -/+ 1xSD #> 11 mean_pval 0.2432 0 Mean p-value (H0: mean = 0) #> 12 median -0.2 0 Median #> 13 mad 0.0 0 Median Absolute Deviation #> 14 median_ci (-1.82, 0.62) 0 Median 95% CI #> 15 quantiles -1.4 - 0.3 0 25% and 75%-ile #> 16 iqr 1.7 0 IQR #> 17 range -2.4 - 1.1 0 Min - Max #> 18 min -2.4 0 Minimum #> 19 max 1.1 0 Maximum #> 20 median_range -0.2 (-2.4 - 1.1) 0 Median (Min - Max) #> 21 cv -253.2 0 CV (%) #> 22 geom_mean NA 0 Geometric Mean #> 23 geom_mean_ci NA 0 Geometric Mean 95% CI #> 24 geom_cv NA 0 CV % Geometric Mean #> 25 median_ci_3d -0.25 (-1.82 - 0.62) 0 Median (95% CI) #> 26 mean_ci_3d -0.44 (-1.24 - 0.36) 0 Mean (95% CI) #> 27 geom_mean_ci_3d NA 0 Geometric Mean (95% CI) a_summary(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .var = \"bla\", compare = TRUE) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 10 0 n #> 2 sum 48.2 0 Sum #> 3 mean 4.8 0 Mean #> 4 sd 1.2 0 SD #> 5 se 0.4 0 SE #> 6 mean_sd 4.8 (1.2) 0 Mean (SD) #> 7 mean_se 4.8 (0.4) 0 Mean (SE) #> 8 mean_ci (3.98, 5.66) 0 Mean 95% CI #> 9 mean_sei (4.45, 5.19) 0 Mean -/+ 1xSE #> 10 mean_sdi (3.65, 6.00) 0 Mean -/+ 1xSD #> 11 mean_pval <0.0001 0 Mean p-value (H0: mean = 0) #> 12 median 4.7 0 Median #> 13 mad 0.0 0 Median Absolute Deviation #> 14 median_ci (3.37, 5.63) 0 Median 95% CI #> 15 quantiles 4.1 - 5.5 0 25% and 75%-ile #> 16 iqr 1.5 0 IQR #> 17 range 3.1 - 7.1 0 Min - Max #> 18 min 3.1 0 Minimum #> 19 max 7.1 0 Maximum #> 20 median_range 4.7 (3.1 - 7.1) 0 Median (Min - Max) #> 21 cv 24.4 0 CV (%) #> 22 geom_mean 4.7 0 Geometric Mean #> 23 geom_mean_ci (3.93, 5.60) 0 Geometric Mean 95% CI #> 24 geom_cv 25.2 0 CV % Geometric Mean #> 25 median_ci_3d 4.71 (3.37 - 5.63) 0 Median (95% CI) #> 26 mean_ci_3d 4.82 (3.98 - 5.66) 0 Mean (95% CI) #> 27 geom_mean_ci_3d 4.69 (3.93 - 5.60) 0 Geometric Mean (95% CI) #> 28 pval <0.0001 0 p-value (t-test)"},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_vars_in_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze numeric variables in columns — analyze_vars_in_cols","title":"Analyze numeric variables in columns — analyze_vars_in_cols","text":"layout-creating function analyze_vars_in_cols() creates layout element generate column-wise analysis table. function sets analysis methods column labels wrapper rtables::analyze_colvars(). designed principally PK tables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_vars_in_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analyze numeric variables in columns — analyze_vars_in_cols","text":"","code":"analyze_vars_in_cols( lyt, vars, ..., .stats = c(\"n\", \"mean\", \"sd\", \"se\", \"cv\", \"geom_cv\"), .labels = c(n = \"n\", mean = \"Mean\", sd = \"SD\", se = \"SE\", cv = \"CV (%)\", geom_cv = \"CV % Geometric Mean\"), row_labels = NULL, do_summarize_row_groups = FALSE, split_col_vars = TRUE, imp_rule = NULL, avalcat_var = \"AVALCAT1\", cache = FALSE, .indent_mods = NULL, na_str = default_na_str(), nested = TRUE, .formats = NULL, .aligns = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/analyze_vars_in_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analyze numeric variables in columns — analyze_vars_in_cols","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . ... additional arguments lower level functions. .stats (character) statistics select table. .labels (named character) labels statistics (without indent). row_labels (character) function works columns space, usually .labels character vector applies column space. can change row labels defining parameter named character vector names corresponding split values. defaults NULL contains one string, duplicate row label. do_summarize_row_groups (flag) defaults FALSE applies analysis current label rows. wrapper rtables::summarize_row_groups() can accept labelstr define row labels. behavior supported never need overload row labels. split_col_vars (flag) defaults TRUE puts analysis results onto columns. option allows add multiple instances functions, also nested fashion, without adding splits. split must happen one time single layout. imp_rule (string NULL) imputation rule setting. Defaults NULL imputation rule. Can also \"1/3\" implement 1/3 imputation rule \"1/2\" implement 1/2 imputation rule. order use imputation rule, avalcat_var argument must specified. See imputation_rule() details imputation. avalcat_var (string) imp_rule NULL, name variable indicates whether row data corresponds analysis value category \"BLQ\", \"LTR\", \"% h_pkparam_sort() lyt <- basic_table() %>% split_rows_by(var = \"STRATA1\", label_pos = \"topleft\") %>% split_rows_by( var = \"SEX\", label_pos = \"topleft\", child_labels = \"hidden\" ) %>% # Removes duplicated labels analyze_vars_in_cols(vars = \"AGE\") result <- build_table(lyt = lyt, df = adpp) result #> STRATA1 #> SEX n Mean SD SE CV (%) CV % Geometric Mean #> ———————————————————————————————————————————————————————————————— #> A #> F 81 38.8 5.4 0.6 13.8 14.3 #> M 81 38.9 5.9 0.7 15.1 14.9 #> B #> F 90 36.0 6.4 0.7 17.7 17.9 #> M 81 36.4 6.5 0.7 17.9 17.8 #> C #> F 117 34.1 6.2 0.6 18.2 18.3 #> M 72 33.2 11.5 1.4 34.6 31.6 # By selecting just some statistics and ad-hoc labels lyt <- basic_table() %>% split_rows_by(var = \"ARM\", label_pos = \"topleft\") %>% split_rows_by( var = \"SEX\", label_pos = \"topleft\", child_labels = \"hidden\", split_fun = drop_split_levels ) %>% analyze_vars_in_cols( vars = \"AGE\", .stats = c(\"n\", \"cv\", \"geom_mean\"), .labels = c( n = \"aN\", cv = \"aCV\", geom_mean = \"aGeomMean\" ) ) result <- build_table(lyt = lyt, df = adpp) result #> ARM #> SEX aN aCV aGeomMean #> ——————————————————————————————————————— #> A: Drug X #> B: Placebo #> C: Combination #> F 288 17.6 35.5 #> M 234 23.4 35.3 # Changing row labels lyt <- basic_table() %>% analyze_vars_in_cols( vars = \"AGE\", row_labels = \"some custom label\" ) result <- build_table(lyt, df = adpp) result #> n Mean SD SE CV (%) CV % Geometric Mean #> ————————————————————————————————————————————————————————————————————————— #> some custom label 522 36.1 7.4 0.3 20.4 20.6 # Pharmacokinetic parameters lyt <- basic_table() %>% split_rows_by( var = \"TLG_DISPLAY\", split_label = \"PK Parameter\", label_pos = \"topleft\", child_labels = \"hidden\" ) %>% analyze_vars_in_cols( vars = \"AVAL\" ) result <- build_table(lyt, df = adpp) result #> PK Parameter n Mean SD SE CV (%) CV % Geometric Mean #> ————————————————————————————————————————————————————————————————————— #> Cmax 58 29.7 5.6 0.7 19.0 19.3 #> AUCinf obs 58 207.5 34.9 4.6 16.8 17.3 #> CL obs 58 5.1 1.0 0.1 20.6 22.7 #> Ae 58 1.5 0.3 0.0 21.3 24.1 #> Fe 58 15.7 3.6 0.5 22.7 24.0 #> CLR 58 0.0 0.0 0.0 19.9 22.2 #> Rmax 58 9.6 2.0 0.3 21.1 21.6 #> Tonset 58 3.0 0.7 0.1 22.4 23.3 #> RENALCLD 58 0.0 0.0 0.0 19.0 19.4 # Multiple calls (summarize label and analyze underneath) lyt <- basic_table() %>% split_rows_by( var = \"TLG_DISPLAY\", split_label = \"PK Parameter\", label_pos = \"topleft\" ) %>% analyze_vars_in_cols( vars = \"AVAL\", do_summarize_row_groups = TRUE # does a summarize level ) %>% split_rows_by(\"SEX\", child_labels = \"hidden\", label_pos = \"topleft\" ) %>% analyze_vars_in_cols( vars = \"AVAL\", split_col_vars = FALSE # avoids re-splitting the columns ) result <- build_table(lyt, df = adpp) result #> PK Parameter #> SEX n Mean SD SE CV (%) CV % Geometric Mean #> ————————————————————————————————————————————————————————————————————— #> Cmax 58 29.7 5.6 0.7 19.0 19.3 #> F 32 30.1 6.1 1.1 20.4 21.0 #> M 26 29.2 5.0 1.0 17.2 17.2 #> AUCinf obs 58 207.5 34.9 4.6 16.8 17.3 #> F 32 209.5 43.3 7.7 20.7 21.6 #> M 26 205.0 20.9 4.1 10.2 10.4 #> CL obs 58 5.1 1.0 0.1 20.6 22.7 #> F 32 5.1 1.1 0.2 20.8 23.2 #> M 26 5.1 1.1 0.2 20.7 22.5 #> Ae 58 1.5 0.3 0.0 21.3 24.1 #> F 32 1.5 0.3 0.1 19.3 20.8 #> M 26 1.5 0.4 0.1 23.9 27.9 #> Fe 58 15.7 3.6 0.5 22.7 24.0 #> F 32 16.3 3.4 0.6 20.9 22.3 #> M 26 15.0 3.7 0.7 24.7 25.6 #> CLR 58 0.0 0.0 0.0 19.9 22.2 #> F 32 0.0 0.0 0.0 20.5 24.8 #> M 26 0.0 0.0 0.0 19.5 18.9 #> Rmax 58 9.6 2.0 0.3 21.1 21.6 #> F 32 9.6 2.2 0.4 22.4 23.5 #> M 26 9.6 1.9 0.4 19.7 19.5 #> Tonset 58 3.0 0.7 0.1 22.4 23.3 #> F 32 3.0 0.7 0.1 24.7 25.9 #> M 26 3.0 0.6 0.1 19.8 20.0 #> RENALCLD 58 0.0 0.0 0.0 19.0 19.4 #> F 32 0.0 0.0 0.0 19.6 20.4 #> M 26 0.0 0.0 0.0 18.0 17.6"},{"path":"https://insightsengineering.github.io/tern/main/reference/append_varlabels.html","id":null,"dir":"Reference","previous_headings":"","what":"Add variable labels to top left corner in table — append_varlabels","title":"Add variable labels to top left corner in table — append_varlabels","text":"Helper layout-creating function append variable labels given variables vector given dataset top left corner. variable label found variable name used instead. Multiple variable labels concatenated slashes.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/append_varlabels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add variable labels to top left corner in table — append_varlabels","text":"","code":"append_varlabels(lyt, df, vars, indent = 0L)"},{"path":"https://insightsengineering.github.io/tern/main/reference/append_varlabels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add variable labels to top left corner in table — append_varlabels","text":"lyt (PreDataTableLayouts) layout analyses added . df (data.frame) data set containing analysis variables. vars (character) variable names labels looked df. indent (integer(1)) non-negative number nested indent space, default 0L means indent. 1L means two spaces indent, 2L means four spaces indent .","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/append_varlabels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add variable labels to top left corner in table — append_varlabels","text":"modified layout new variable label(s) added top-left material.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/append_varlabels.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Add variable labels to top left corner in table — append_varlabels","text":"optimal implementation course, since using data set layout creation. mature rtables implementation also improved necessary anymore.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/append_varlabels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add variable labels to top left corner in table — append_varlabels","text":"","code":"lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% split_rows_by(\"SEX\") %>% append_varlabels(DM, \"SEX\") %>% analyze(\"AGE\", afun = mean) %>% append_varlabels(DM, \"AGE\", indent = 1) build_table(lyt, DM) #> SEX A: Drug X B: Placebo C: Combination #> Age (N=121) (N=106) (N=129) #> ————————————————————————————————————————————————————————————————————————— #> F #> mean 33.7142857142857 33.8392857142857 34.8852459016393 #> M #> mean 36.5490196078431 32.1 34.2794117647059 #> U #> mean NA NA NA #> UNDIFFERENTIATED #> mean NA NA NA lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"SEX\") %>% analyze(\"AGE\", afun = mean) %>% append_varlabels(DM, c(\"SEX\", \"AGE\")) build_table(lyt, DM) #> SEX / Age A: Drug X B: Placebo C: Combination #> ————————————————————————————————————————————————————————————————————————— #> F #> mean 33.7142857142857 33.8392857142857 34.8852459016393 #> M #> mean 36.5490196078431 32.1 34.2794117647059 #> U #> mean NA NA NA #> UNDIFFERENTIATED #> mean NA NA NA"},{"path":"https://insightsengineering.github.io/tern/main/reference/apply_auto_formatting.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply automatic formatting — apply_auto_formatting","title":"Apply automatic formatting — apply_auto_formatting","text":"Checks listed formats .formats \"auto\", replaces \"auto\" correct implementation format_auto given statistics, data, variable.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/apply_auto_formatting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply automatic formatting — apply_auto_formatting","text":"","code":"apply_auto_formatting(.formats, x_stats, .df_row, .var)"},{"path":"https://insightsengineering.github.io/tern/main/reference/apply_auto_formatting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply automatic formatting — apply_auto_formatting","text":".formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. x_stats (named list) named list statistics element corresponds element .formats, matching names. .df_row (data.frame) data frame across columns given row split. .var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/argument_convention.html","id":null,"dir":"Reference","previous_headings":"","what":"Standard arguments — argument_convention","title":"Standard arguments — argument_convention","text":"documentation function lists arguments tern used repeatedly express analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/argument_convention.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Standard arguments — argument_convention","text":"... additional arguments lower level functions. .aligns (character NULL) alignment table contents (including labels). NULL, \"center\" applied. See formatters::list_valid_aligns() list currently supported alignments. .all_col_counts (integer) vector value represents global count column. Values taken alt_counts_df specified (see rtables::build_table()). .df_row (data.frame) data frame across columns given row split. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. .labels (named character) labels statistics (without indent). .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .ref_group (data.frame vector) data corresponding reference group. .spl_context (data.frame) gives information ancestor split states passed rtables. .stats (character) statistics select table. .var (string) single variable name passed rtables requested statistics function. add_total_level (flag) adds \"total\" level others includes levels constitute split. custom label can set level via custom_label argument. col_by (factor) defining column groups. conf_level (proportion) confidence level interval. data (data.frame) dataset containing variables summarize. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. df (data.frame) data set containing analysis variables. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. id (string) subject variable name. is_event (flag)TRUE event, FALSE time event censored. label_all (string) label total population analysis. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. lyt (PreDataTableLayouts) layout analyses added . method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed. na.rm (flag) whether NA values removed x prior analysis. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. prune_zero_rows (flag) whether prune zero rows. riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. rsp (logical) vector indicating whether subject responder . show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. tte (numeric) vector time--event duration values. var_labels (character) variable labels. variables (named list string) list additional analysis variables. vars (character) variable names primary analysis variable iterated . var (string) single variable name primary analysis variable. x (numeric) vector numbers want analyze. xlim (numeric(2)) vector containing lower upper limits x-axis, respectively. NULL (default), default scale range used. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/argument_convention.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Standard arguments — argument_convention","text":"Although function just returns NULL two uses, tern users provides documentation arguments commonly consistently used framework. developer adds single reference point import roxygen argument description : @inheritParams argument_convention","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/arrange_grobs.html","id":null,"dir":"Reference","previous_headings":"","what":"Arrange multiple grobs — arrange_grobs","title":"Arrange multiple grobs — arrange_grobs","text":"Arrange grobs new grob n * m (rows * cols) layout.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/arrange_grobs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Arrange multiple grobs — arrange_grobs","text":"","code":"arrange_grobs( ..., grobs = list(...), ncol = NULL, nrow = NULL, padding_ht = grid::unit(2, \"line\"), padding_wt = grid::unit(2, \"line\"), vp = NULL, gp = NULL, name = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/arrange_grobs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Arrange multiple grobs — arrange_grobs","text":"... grobs. grobs (list grob) list grobs. ncol (integer(1)) number columns layout. nrow (integer(1)) number rows layout. padding_ht (grid::unit) unit length 1, vertical space grob. padding_wt (grid::unit) unit length 1, horizontal space grob. vp (viewport NULL) viewport() object (NULL). gp (gpar) gpar() object. name (string) character identifier grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/arrange_grobs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Arrange multiple grobs — arrange_grobs","text":"grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/arrange_grobs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Arrange multiple grobs — arrange_grobs","text":"","code":"library(grid) # \\donttest{ num <- lapply(1:9, textGrob) grid::grid.newpage() grid.draw(arrange_grobs(grobs = num, ncol = 2)) #> Warning: `arrange_grobs()` was deprecated in tern 0.9.4. #> ℹ `tern` plotting functions no longer generate `grob` objects. showViewport() g1 <- circleGrob(gp = gpar(col = \"blue\")) g2 <- circleGrob(gp = gpar(col = \"red\")) g3 <- textGrob(\"TEST TEXT\") grid::grid.newpage() grid.draw(arrange_grobs(g1, g2, g3, nrow = 2)) showViewport() grid::grid.newpage() grid.draw(arrange_grobs(g1, g2, g3, ncol = 3)) grid::grid.newpage() grid::pushViewport(grid::viewport(layout = grid::grid.layout(1, 2))) vp1 <- grid::viewport(layout.pos.row = 1, layout.pos.col = 2) grid.draw(arrange_grobs(g1, g2, g3, ncol = 2, vp = vp1)) showViewport() # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/as.rtable.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert to rtable — as.rtable","title":"Convert to rtable — as.rtable","text":"new generic function convert objects rtable tables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/as.rtable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert to rtable — as.rtable","text":"","code":"as.rtable(x, ...) # S3 method for class 'data.frame' as.rtable(x, format = \"xx.xx\", ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/as.rtable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert to rtable — as.rtable","text":"x (data.frame) object converted rtable. ... additional arguments methods. format (string function) format used columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/as.rtable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert to rtable — as.rtable","text":"rtables table object. Note concrete class depend method used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/as.rtable.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Convert to rtable — as.rtable","text":".rtable(data.frame): Method converting data.frame contains numeric columns rtable.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/as.rtable.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert to rtable — as.rtable","text":"","code":"x <- data.frame( a = 1:10, b = rnorm(10) ) as.rtable(x) #> a b #> —————————————————— #> 1 1.00 0.07 #> 2 2.00 -0.64 #> 3 3.00 -0.05 #> 4 4.00 -0.25 #> 5 5.00 0.44 #> 6 6.00 2.76 #> 7 7.00 0.05 #> 8 8.00 0.58 #> 9 9.00 0.12 #> 10 10.00 -1.91"},{"path":"https://insightsengineering.github.io/tern/main/reference/as_factor_keep_attributes.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion of a vector to a factor — as_factor_keep_attributes","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"Converts x factor keeps attributes. Warns appropriately user can decide whether prefer converting factor manually (e.g. full control factor levels).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/as_factor_keep_attributes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"","code":"as_factor_keep_attributes( x, x_name = deparse(substitute(x)), na_level = \"\", verbose = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/as_factor_keep_attributes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"x (vector) object convert. x_name (string) name x. na_level (string) explicit missing level used converting character vector. verbose (flag) defaults TRUE. prints warnings messages.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/as_factor_keep_attributes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conversion of a vector to a factor — as_factor_keep_attributes","text":"factor attributes (except class) x. modify x already factor.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/assertions.html","id":null,"dir":"Reference","previous_headings":"","what":"Additional assertions to use with checkmate — assertions","title":"Additional assertions to use with checkmate — assertions","text":"Additional assertion functions can used together checkmate package.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/assertions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Additional assertions to use with checkmate — assertions","text":"","code":"assert_list_of_variables(x, .var.name = checkmate::vname(x), add = NULL) assert_df_with_variables( df, variables, na_level = NULL, .var.name = checkmate::vname(df), add = NULL ) assert_valid_factor( x, min.levels = 1, max.levels = NULL, null.ok = TRUE, any.missing = TRUE, n.levels = NULL, len = NULL, .var.name = checkmate::vname(x), add = NULL ) assert_df_with_factors( df, variables, min.levels = 1, max.levels = NULL, any.missing = TRUE, na_level = NULL, .var.name = checkmate::vname(df), add = NULL ) assert_proportion_value(x, include_boundaries = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/assertions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Additional assertions to use with checkmate — assertions","text":"x () object test. .var.name [character(1)] Name checked object print assertions. Defaults heuristic implemented vname. add [AssertCollection] Collection store assertion messages. See AssertCollection. df (data.frame) data set test. variables (named list character) list variables test. na_level (string) string using represent NA missing data. NA values please consider using directly .na() similar approaches. min.levels [integer(1)] Minimum number factor levels. Default NULL (check). max.levels [integer(1)] Maximum number factor levels. Default NULL (check). null.ok [logical(1)] set TRUE, x may also NULL. case type check x performed, additional checks disabled. .missing [logical(1)] vectors missing values allowed? Default TRUE. n.levels [integer(1)] Exact number factor levels. Default NULL (check). len [integer(1)] Exact expected length x. include_boundaries (flag) whether include boundaries testing proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/assertions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Additional assertions to use with checkmate — assertions","text":"Nothing assertion passes, otherwise prints error message.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/assertions.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Additional assertions to use with checkmate — assertions","text":"assert_list_of_variables(): Checks whether x valid list variable names. NULL elements list x dropped Filter(Negate(.null), x). assert_df_with_variables(): Check whether df data frame analysis variables. Please notice produces error variables present data.frame opposite required. assert_valid_factor(): Check whether x valid factor (.e. levels empty string levels). Note NULL NA elements allowed. assert_df_with_factors(): Check whether df data frame analysis variables factors. Note creation NA direct call factor() trim NA levels vector list . assert_proportion_value(): Check whether x proportion: number 0 1.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/bins_percent_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels for bins in percent — bins_percent_labels","title":"Labels for bins in percent — bins_percent_labels","text":"creates labels quantile based bins percent. assumes right-closed intervals produced cut_quantile_bins().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/bins_percent_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for bins in percent — bins_percent_labels","text":"","code":"bins_percent_labels(probs, digits = 0)"},{"path":"https://insightsengineering.github.io/tern/main/reference/bins_percent_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for bins in percent — bins_percent_labels","text":"probs (numeric) probabilities identifying quantiles. sorted vector unique proportion values, .e. 0 1, boundaries 0 1 must included. digits (integer(1)) number decimal places round percent numbers.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/bins_percent_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for bins in percent — bins_percent_labels","text":"character vector labels format [0%,20%], (20%,50%], etc.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Content row function to add row total to labels — c_label_n","title":"Content row function to add row total to labels — c_label_n","text":"takes label latest row split level adds row total df parentheses. function differs c_label_n_alt() taking row counts df rather alt_counts_df, used add_rowcounts() alt_counts set FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Content row function to add row total to labels — c_label_n","text":"","code":"c_label_n(df, labelstr, .N_row)"},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Content row function to add row total to labels — c_label_n","text":"df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Content row function to add row total to labels — c_label_n","text":"list formatted rtables::CellValue() row count value correct label.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Content row function to add row total to labels — c_label_n","text":"important use df rather .N_row implementation, former already split columns refer first column data .","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n_alt.html","id":null,"dir":"Reference","previous_headings":"","what":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"takes label latest row split level adds row total alt_counts_df parentheses. function differs c_label_n() taking row counts alt_counts_df rather df, used add_rowcounts() alt_counts set TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n_alt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"","code":"c_label_n_alt(df, labelstr, .alt_df_row)"},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n_alt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/c_label_n_alt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Content row function to add alt_counts_df row total to labels — c_label_n_alt","text":"list formatted rtables::CellValue() row count value correct label.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/cfun_by_flag.html","id":null,"dir":"Reference","previous_headings":"","what":"Constructor for content functions given a data frame with flag input — cfun_by_flag","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"can useful tabulating model results.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cfun_by_flag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"","code":"cfun_by_flag(analysis_var, flag_var, format = \"xx\", .indent_mods = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/cfun_by_flag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"analysis_var (string) variable name column containing values returned content function. flag_var (string) variable name logical column identifying row returned. format (string)rtables format use.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cfun_by_flag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Constructor for content functions given a data frame with flag input — cfun_by_flag","text":"content function gives df$analysis_var row identified .df_row$flag given format.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/check_diff_prop_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Check proportion difference arguments — check_diff_prop_ci","title":"Check proportion difference arguments — check_diff_prop_ci","text":"Verifies /convert arguments valid values used estimation difference responder proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/check_diff_prop_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check proportion difference arguments — check_diff_prop_ci","text":"","code":"check_diff_prop_ci(rsp, grp, strata = NULL, conf_level, correct = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/check_diff_prop_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check proportion difference arguments — check_diff_prop_ci","text":"rsp (logical) vector indicating whether subject responder . grp (factor) vector assigning observations one two groups (e.g. reference treatment group). strata (factor) variable one level per stratum length rsp. conf_level (proportion) confidence level interval. correct (flag) whether include continuity correction. information, see stats::prop.test().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/check_same_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Check element dimension — check_same_n","title":"Check element dimension — check_same_n","text":"Checks elements ... dimension.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/check_same_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check element dimension — check_same_n","text":"","code":"check_same_n(..., omit_null = TRUE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/check_same_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check element dimension — check_same_n","text":"... (data.frame vector) data frames vectors. omit_null (flag) whether NULL elements ... omitted check.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/check_same_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check element dimension — check_same_n","text":"logical value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combination_function.html","id":null,"dir":"Reference","previous_headings":"","what":"Class for CombinationFunction — combination_function","title":"Class for CombinationFunction — combination_function","text":"CombinationFunction S4 class extends standard functions. special functions can combined negated logical operators.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combination_function.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Class for CombinationFunction — combination_function","text":"","code":"# S4 method for class 'CombinationFunction,CombinationFunction' e1 & e2 # S4 method for class 'CombinationFunction,CombinationFunction' e1 | e2 # S4 method for class 'CombinationFunction' !x"},{"path":"https://insightsengineering.github.io/tern/main/reference/combination_function.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Class for CombinationFunction — combination_function","text":"e1 (CombinationFunction) left hand side logical operator. e2 (CombinationFunction) right hand side logical operator. x (CombinationFunction) function negated.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combination_function.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Class for CombinationFunction — combination_function","text":"logical value indicating whether left hand side equation equals right hand side.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combination_function.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Class for CombinationFunction — combination_function","text":"e1 & e2: Logical \"\" combination CombinationFunction functions. resulting object class, evaluates two argument functions. result \"\" two individual results. e1 | e2: Logical \"\" combination CombinationFunction functions. resulting object class, evaluates two argument functions. result \"\" two individual results. `!`(CombinationFunction): Logical negation CombinationFunction functions. resulting object class, evaluates original function. result opposite results.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combination_function.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Class for CombinationFunction — combination_function","text":"","code":"higher <- function(a) { force(a) CombinationFunction( function(x) { x > a } ) } lower <- function(b) { force(b) CombinationFunction( function(x) { x < b } ) } c1 <- higher(5) c2 <- lower(10) c3 <- higher(5) & lower(10) c3(7) #> [1] TRUE"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_counts.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine counts — combine_counts","title":"Combine counts — combine_counts","text":"Simplifies estimation column counts, especially group combination required.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_counts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine counts — combine_counts","text":"","code":"combine_counts(fct, groups_list = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_counts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine counts — combine_counts","text":"fct (factor) variable levels needs grouped. groups_list (named list character) specifies new group levels via names levels belong character vectors elements list.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_counts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine counts — combine_counts","text":"vector column counts.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_counts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine counts — combine_counts","text":"","code":"ref <- c(\"A: Drug X\", \"B: Placebo\") groups <- combine_groups(fct = DM$ARM, ref = ref) col_counts <- combine_counts( fct = DM$ARM, groups_list = groups ) basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze_vars(\"AGE\") %>% build_table(DM, col_counts = col_counts) #> A: Drug X/B: Placebo C: Combination #> (N=227) (N=129) #> ————————————————————————————————————————————————— #> n 227 129 #> Mean (SD) 34.0 (7.2) 34.6 (6.5) #> Median 33.0 33.0 #> Min - Max 20.0 - 60.0 22.0 - 53.0 ref <- \"A: Drug X\" groups <- combine_groups(fct = DM$ARM, ref = ref) col_counts <- combine_counts( fct = DM$ARM, groups_list = groups ) basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze_vars(\"AGE\") %>% build_table(DM, col_counts = col_counts) #> A: Drug X B: Placebo/C: Combination #> (N=121) (N=235) #> ——————————————————————————————————————————————————— #> n 121 235 #> Mean (SD) 34.9 (7.8) 33.9 (6.5) #> Median 33.0 33.0 #> Min - Max 20.0 - 60.0 21.0 - 55.0"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_groups.html","id":null,"dir":"Reference","previous_headings":"","what":"Reference and treatment group combination — combine_groups","title":"Reference and treatment group combination — combine_groups","text":"Facilitate re-combination groups divided reference treatment groups; helps arranging groups columns rtables framework teal modules.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_groups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reference and treatment group combination — combine_groups","text":"","code":"combine_groups(fct, ref = NULL, collapse = \"/\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_groups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reference and treatment group combination — combine_groups","text":"fct (factor) variable levels needs grouped. ref (character) reference level(s). collapse (string) character string separate fct ref.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_groups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reference and treatment group combination — combine_groups","text":"list first item ref (reference) second item trt (treatment).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_groups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reference and treatment group combination — combine_groups","text":"","code":"groups <- combine_groups( fct = DM$ARM, ref = c(\"B: Placebo\") ) basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze_vars(\"AGE\") %>% build_table(DM) #> B: Placebo A: Drug X/C: Combination #> (N=106) (N=250) #> —————————————————————————————————————————————————— #> n 106 250 #> Mean (SD) 33.0 (6.3) 34.7 (7.1) #> Median 32.0 33.0 #> Min - Max 21.0 - 55.0 20.0 - 60.0"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_levels.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine factor levels — combine_levels","title":"Combine factor levels — combine_levels","text":"Combine specified old factor Levels single new level.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_levels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine factor levels — combine_levels","text":"","code":"combine_levels(x, levels, new_level = paste(levels, collapse = \"/\"))"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_levels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine factor levels — combine_levels","text":"x (factor) factor variable. levels (character) level names combined. new_level (string) name new level.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_levels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine factor levels — combine_levels","text":"factor new levels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_levels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine factor levels — combine_levels","text":"","code":"x <- factor(letters[1:5], levels = letters[5:1]) combine_levels(x, levels = c(\"a\", \"b\")) #> [1] a/b a/b c d e #> Levels: e d c a/b combine_levels(x, c(\"e\", \"b\")) #> [1] a e/b c d e/b #> Levels: e/b d c a"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_vectors.html","id":null,"dir":"Reference","previous_headings":"","what":"Element-wise combination of two vectors — combine_vectors","title":"Element-wise combination of two vectors — combine_vectors","text":"Element-wise combination two vectors","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_vectors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Element-wise combination of two vectors — combine_vectors","text":"","code":"combine_vectors(x, y)"},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_vectors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Element-wise combination of two vectors — combine_vectors","text":"x (vector) first vector combine. y (vector) second vector combine.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_vectors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Element-wise combination of two vectors — combine_vectors","text":"list element combines corresponding elements x y.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/combine_vectors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Element-wise combination of two vectors — combine_vectors","text":"","code":"combine_vectors(1:3, 4:6) #> [[1]] #> [1] 1 4 #> #> [[2]] #> [1] 2 5 #> #> [[3]] #> [1] 3 6 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Compare variables between groups — compare_variables","title":"Compare variables between groups — compare_variables","text":"analyze function compare_vars() creates layout element summarize compare one variables, using S3 generic function s_summary() calculate list summary statistics. list available statistics numeric variables can viewed running get_stats(\"analyze_vars_numeric\", add_pval = TRUE) non-numeric variables running get_stats(\"analyze_vars_counts\", add_pval = TRUE). Use .stats parameter specify statistics include output summary table. Prior using function table layout must use rtables::split_cols_by() create column split variable used comparisons, specify reference group via ref_group parameter. Comparisons can performed group (column) specified reference group including p-value statistic.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compare variables between groups — compare_variables","text":"","code":"compare_vars( lyt, vars, var_labels = vars, na_str = default_na_str(), nested = TRUE, ..., na.rm = TRUE, show_labels = \"default\", table_names = vars, section_div = NA_character_, .stats = c(\"n\", \"mean_sd\", \"count_fraction\", \"pval\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_compare(x, .ref_group, .in_ref_col, ...) # S3 method for class 'numeric' s_compare(x, .ref_group, .in_ref_col, ...) # S3 method for class 'factor' s_compare(x, .ref_group, .in_ref_col, denom = \"n\", na.rm = TRUE, ...) # S3 method for class 'character' s_compare( x, .ref_group, .in_ref_col, denom = \"n\", na.rm = TRUE, .var, verbose = TRUE, ... ) # S3 method for class 'logical' s_compare(x, .ref_group, .in_ref_col, na.rm = TRUE, denom = \"n\", ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compare variables between groups — compare_variables","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... arguments passed s_compare(). na.rm (flag) whether NA values removed x prior analysis. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. .stats (character) statistics select table. Options numeric variables : 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d', 'pval' Options non-numeric variables : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq', 'pval_counts' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. x (numeric) vector numbers want analyze. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. denom (string) choice denominator factor proportions, can n (number values row column intersection). .var (string) single variable name passed rtables requested statistics function. verbose (flag) whether warnings messages printed. Mainly used print information factor casting. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compare variables between groups — compare_variables","text":"compare_vars() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_compare() table layout. s_compare() returns output s_summary() comparisons versus reference group form p-values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Compare variables between groups — compare_variables","text":"compare_vars(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_compare(): S3 generic function produce comparison summary. s_compare(numeric): Method numeric class. uses standard t-test calculate p-value. s_compare(factor): Method factor class. uses chi-squared test calculate p-value. s_compare(character): Method character class. makes automatic conversion factor (warning) forwards method factors. s_compare(logical): Method logical class. chi-squared test used. missing values removed, counted FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Compare variables between groups — compare_variables","text":"factor variables, denom factor proportions can n since purpose compare proportions columns, therefore row-based proportion make sense. Proportion based N_col difficult since use counts chi-squared test statistic, therefore missing values accounted explicit factor levels. factor variables contain NA, NA values excluded default. include NA values set na.rm = FALSE missing values displayed NA level. Alternatively, explicit factor level can defined NA values pre-processing via df_explicit_na() - default na_level (\"\") also excluded na.rm set TRUE. character variables, automatic conversion factor guarantee table generated correctly. particular sparse tables likely can fail. Therefore always better manually convert character variables factors pre-processing. compare_vars(), column split must define reference group via ref_group comparison well defined.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/compare_variables.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compare variables between groups — compare_variables","text":"","code":"# `compare_vars()` in `rtables` pipelines ## Default output within a `rtables` pipeline. lyt <- basic_table() %>% split_cols_by(\"ARMCD\", ref_group = \"ARM B\") %>% compare_vars(c(\"AGE\", \"SEX\")) build_table(lyt, tern_ex_adsl) #> ARM A ARM B ARM C #> ——————————————————————————————————————————————————————————————————— #> AGE #> n 69 73 58 #> Mean (SD) 34.1 (6.8) 35.8 (7.1) 36.1 (7.4) #> p-value (t-test) 0.1446 0.8212 #> SEX #> n 69 73 58 #> F 38 (55.1%) 40 (54.8%) 32 (55.2%) #> M 31 (44.9%) 33 (45.2%) 26 (44.8%) #> p-value (chi-squared test) 1.0000 1.0000 ## Select and format statistics output. lyt <- basic_table() %>% split_cols_by(\"ARMCD\", ref_group = \"ARM C\") %>% compare_vars( vars = \"AGE\", .stats = c(\"mean_sd\", \"pval\"), .formats = c(mean_sd = \"xx.x, xx.x\"), .labels = c(mean_sd = \"Mean, SD\") ) build_table(lyt, df = tern_ex_adsl) #> ARM A ARM B ARM C #> ———————————————————————————————————————————————————— #> Mean, SD 34.1, 6.8 35.8, 7.1 36.1, 7.4 #> p-value (t-test) 0.1176 0.8212 # `s_compare.numeric` ## Usual case where both this and the reference group vector have more than 1 value. s_compare(rnorm(10, 5, 1), .ref_group = rnorm(5, -5, 1), .in_ref_col = FALSE) #> $n #> n #> 10 #> #> $sum #> sum #> 51.27191 #> #> $mean #> mean #> 5.127191 #> #> $sd #> sd #> 1.226119 #> #> $se #> se #> 0.387733 #> #> $mean_sd #> mean sd #> 5.127191 1.226119 #> #> $mean_se #> mean se #> 5.127191 0.387733 #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> 4.250078 6.004304 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> 4.739458 5.514924 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 3.901071 6.353310 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 5.127191 4.250078 6.004304 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> 3.353908e-07 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 5.024369 #> #> $mad #> mad #> -4.440892e-16 #> #> $median_ci #> median_ci_lwr median_ci_upr #> 4.638779 5.862086 #> attr(,\"conf_level\") #> [1] 0.9785156 #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 5.024369 4.638779 5.862086 #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 4.756763 5.549828 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 0.7930643 #> #> $range #> min max #> 2.725885 7.682557 #> #> $min #> min #> 2.725885 #> #> $max #> max #> 7.682557 #> #> $median_range #> median min max #> 5.024369 2.725885 7.682557 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> 23.91406 #> #> $geom_mean #> geom_mean #> 4.985435 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 4.144463 5.997052 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> 26.26258 #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 4.985435 4.144463 5.997052 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> $pval #> [1] 2.25779e-08 #> ## If one group has not more than 1 value, then p-value is not calculated. s_compare(rnorm(10, 5, 1), .ref_group = 1, .in_ref_col = FALSE) #> $n #> n #> 10 #> #> $sum #> sum #> 50.71578 #> #> $mean #> mean #> 5.071578 #> #> $sd #> sd #> 1.105832 #> #> $se #> se #> 0.3496948 #> #> $mean_sd #> mean sd #> 5.071578 1.105832 #> #> $mean_se #> mean se #> 5.0715780 0.3496948 #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> 4.280513 5.862643 #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> 4.721883 5.421273 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> 3.965746 6.177410 #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> 5.071578 4.280513 5.862643 #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> 1.511204e-07 #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> 5.260423 #> #> $mad #> mad #> 0 #> #> $median_ci #> median_ci_lwr median_ci_upr #> 3.529264 6.318293 #> attr(,\"conf_level\") #> [1] 0.9785156 #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> 5.260423 3.529264 6.318293 #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> 4.024149 6.065057 #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> 2.040908 #> #> $range #> min max #> 3.300549 6.337320 #> #> $min #> min #> 3.300549 #> #> $max #> max #> 6.33732 #> #> $median_range #> median min max #> 5.260423 3.300549 6.337320 #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> 21.8045 #> #> $geom_mean #> geom_mean #> 4.952266 #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> 4.181833 5.864639 #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> 23.97201 #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> 4.952266 4.181833 5.864639 #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> $pval #> character(0) #> ## Empty numeric does not fail, it returns NA-filled items and no p-value. s_compare(numeric(), .ref_group = numeric(), .in_ref_col = FALSE) #> $n #> n #> 0 #> #> $sum #> sum #> NA #> #> $mean #> mean #> NA #> #> $sd #> sd #> NA #> #> $se #> se #> NA #> #> $mean_sd #> mean sd #> NA NA #> #> $mean_se #> mean se #> NA NA #> #> $mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean 95% CI\" #> #> $mean_sei #> mean_sei_lwr mean_sei_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSE\" #> #> $mean_sdi #> mean_sdi_lwr mean_sdi_upr #> NA NA #> attr(,\"label\") #> [1] \"Mean -/+ 1xSD\" #> #> $mean_ci_3d #> mean mean_ci_lwr mean_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Mean (95% CI)\" #> #> $mean_pval #> p_value #> NA #> attr(,\"label\") #> [1] \"Mean p-value (H0: mean = 0)\" #> #> $median #> median #> NA #> #> $mad #> mad #> NA #> #> $median_ci #> median_ci_lwr median_ci_upr #> NA NA #> attr(,\"conf_level\") #> [1] NA #> attr(,\"label\") #> [1] \"Median 95% CI\" #> #> $median_ci_3d #> median median_ci_lwr median_ci_upr #> NA NA NA #> attr(,\"label\") #> [1] \"Median (95% CI)\" #> #> $quantiles #> quantile_0.25 quantile_0.75 #> NA NA #> attr(,\"label\") #> [1] \"25% and 75%-ile\" #> #> $iqr #> iqr #> NA #> #> $range #> min max #> NA NA #> #> $min #> min #> NA #> #> $max #> max #> NA #> #> $median_range #> median min max #> NA NA NA #> attr(,\"label\") #> [1] \"Median (Min - Max)\" #> #> $cv #> cv #> NA #> #> $geom_mean #> geom_mean #> NaN #> #> $geom_mean_ci #> mean_ci_lwr mean_ci_upr #> NA NA #> attr(,\"label\") #> [1] \"Geometric Mean 95% CI\" #> #> $geom_cv #> geom_cv #> NA #> #> $geom_mean_ci_3d #> geom_mean mean_ci_lwr mean_ci_upr #> NaN NA NA #> attr(,\"label\") #> [1] \"Geometric Mean (95% CI)\" #> #> $pval #> character(0) #> # `s_compare.factor` ## Basic usage: x <- factor(c(\"a\", \"a\", \"b\", \"c\", \"a\")) y <- factor(c(\"a\", \"b\", \"c\")) s_compare(x = x, .ref_group = y, .in_ref_col = FALSE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> ## Management of NA values. x <- explicit_na(factor(c(\"a\", \"a\", \"b\", \"c\", \"a\", NA, NA))) y <- explicit_na(factor(c(\"a\", \"b\", \"c\", NA))) s_compare(x = x, .ref_group = y, .in_ref_col = FALSE, na.rm = TRUE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> s_compare(x = x, .ref_group = y, .in_ref_col = FALSE, na.rm = FALSE) #> $n #> [1] 7 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> $count$`` #> [1] 2 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0000000 0.4285714 #> #> $count_fraction$b #> [1] 1.0000000 0.1428571 #> #> $count_fraction$c #> [1] 1.0000000 0.1428571 #> #> $count_fraction$`` #> [1] 2.0000000 0.2857143 #> #> #> $fraction #> $fraction$a #> num denom #> 3 7 #> #> $fraction$b #> num denom #> 1 7 #> #> $fraction$c #> num denom #> 1 7 #> #> $fraction$`` #> num denom #> 2 7 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.9063036 #> # `s_compare.character` ## Basic usage: x <- c(\"a\", \"a\", \"b\", \"c\", \"a\") y <- c(\"a\", \"b\", \"c\") s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = \"x\", verbose = FALSE) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> ## Note that missing values handling can make a large difference: x <- c(\"a\", \"a\", \"b\", \"c\", \"a\", NA) y <- c(\"a\", \"b\", \"c\", rep(NA, 20)) s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = \"x\", verbose = FALSE ) #> $n #> [1] 5 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.6 #> #> $count_fraction$b #> [1] 1.0 0.2 #> #> $count_fraction$c #> [1] 1.0 0.2 #> #> #> $fraction #> $fraction$a #> num denom #> 3 5 #> #> $fraction$b #> num denom #> 1 5 #> #> $fraction$c #> num denom #> 1 5 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.7659283 #> s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = \"x\", na.rm = FALSE, verbose = FALSE ) #> $n #> [1] 6 #> #> $count #> $count$a #> [1] 3 #> #> $count$b #> [1] 1 #> #> $count$c #> [1] 1 #> #> $count$`` #> [1] 1 #> #> #> $count_fraction #> $count_fraction$a #> [1] 3.0 0.5 #> #> $count_fraction$b #> [1] 1.0000000 0.1666667 #> #> $count_fraction$c #> [1] 1.0000000 0.1666667 #> #> $count_fraction$`` #> [1] 1.0000000 0.1666667 #> #> #> $fraction #> $fraction$a #> num denom #> 3 6 #> #> $fraction$b #> num denom #> 1 6 #> #> $fraction$c #> num denom #> 1 6 #> #> $fraction$`` #> num denom #> 1 6 #> #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.005768471 #> # `s_compare.logical` ## Basic usage: x <- c(TRUE, FALSE, TRUE, TRUE) y <- c(FALSE, FALSE, TRUE) s_compare(x, .ref_group = y, .in_ref_col = FALSE) #> $n #> [1] 4 #> #> $count #> [1] 3 #> #> $count_fraction #> [1] 3.00 0.75 #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.2702894 #> ## Management of NA values. x <- c(NA, TRUE, FALSE) y <- c(NA, NA, NA, NA, FALSE) s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = TRUE) #> $n #> [1] 2 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0 0.5 #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.3864762 #> s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = FALSE) #> $n #> [1] 3 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0000000 0.3333333 #> #> $n_blq #> [1] 0 #> #> $pval_counts #> [1] 0.1675463 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_analyze_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for descriptive statistics — control_analyze_vars","title":"Control function for descriptive statistics — control_analyze_vars","text":"Sets list parameters summaries descriptive statistics. Typically used internally specify details s_summary(). function family mainly used analyze_vars().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_analyze_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for descriptive statistics — control_analyze_vars","text":"","code":"control_analyze_vars( conf_level = 0.95, quantiles = c(0.25, 0.75), quantile_type = 2, test_mean = 0 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_analyze_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for descriptive statistics — control_analyze_vars","text":"conf_level (proportion) confidence level interval. quantiles (numeric(2)) vector length two specify quantiles calculate. quantile_type (numeric(1)) number 1 9 selecting quantile algorithms used. Default set 2 matches default quantile algorithm SAS proc univariate set QNTLDEF=5. differs R's default. See type stats::quantile(). test_mean (numeric(1)) number test mean null hypothesis calculating p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_analyze_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for descriptive statistics — control_analyze_vars","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_annot.html","id":null,"dir":"Reference","previous_headings":"","what":"Control functions for Kaplan-Meier plot annotation tables — control_annot","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"Auxiliary functions controlling arguments formatting annotation tables can added plots generated via g_km().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_annot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"","code":"control_surv_med_annot(x = 0.8, y = 0.85, w = 0.32, h = 0.16, fill = TRUE) control_coxph_annot( x = 0.29, y = 0.51, w = 0.4, h = 0.125, fill = TRUE, ref_lbls = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_annot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"x (proportion) x-coordinate center annotation table. y (proportion) y-coordinate center annotation table. w (proportion) relative width annotation table. h (proportion) relative height annotation table. fill (flag character) whether annotation table background fill color. Can also color code use background fill color. TRUE, color code defaults \"#00000020\". ref_lbls (flag) whether reference group explicitly printed labels annotation table. FALSE (default), comparison groups printed table labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_annot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_annot.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"control_surv_med_annot(): Control function formatting median survival time annotation table. annotation table can added g_km() setting annot_surv_med=TRUE, can configured using control_surv_med_annot() function setting control_annot_surv_med argument. control_coxph_annot(): Control function formatting Cox-PH annotation table. annotation table can added g_km() setting annot_coxph=TRUE, can configured using control_coxph_annot() function setting control_annot_coxph argument.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/control_annot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control functions for Kaplan-Meier plot annotation tables — control_annot","text":"","code":"control_surv_med_annot() #> $x #> [1] 0.8 #> #> $y #> [1] 0.85 #> #> $w #> [1] 0.32 #> #> $h #> [1] 0.16 #> #> $fill #> [1] TRUE #> control_coxph_annot() #> $x #> [1] 0.29 #> #> $y #> [1] 0.51 #> #> $w #> [1] 0.4 #> #> $h #> [1] 0.125 #> #> $fill #> [1] TRUE #> #> $ref_lbls #> [1] FALSE #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxph.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for Cox-PH model — control_coxph","title":"Control function for Cox-PH model — control_coxph","text":"auxiliary function controlling arguments Cox-PH model, typically used internally specify details Cox-PH model s_coxph_pairwise(). conf_level refers Hazard Ratio estimation.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for Cox-PH model — control_coxph","text":"","code":"control_coxph( pval_method = c(\"log-rank\", \"wald\", \"likelihood\"), ties = c(\"efron\", \"breslow\", \"exact\"), conf_level = 0.95 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for Cox-PH model — control_coxph","text":"pval_method (string) p-value method testing hazard ratio = 1. Default method \"log-rank\", can also set \"wald\" \"likelihood\". ties (string) string specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for Cox-PH model — control_coxph","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxreg.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for Cox regression — control_coxreg","title":"Control function for Cox regression — control_coxreg","text":"Sets list parameters Cox regression fit. Used internally.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxreg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for Cox regression — control_coxreg","text":"","code":"control_coxreg( pval_method = c(\"wald\", \"likelihood\"), ties = c(\"exact\", \"efron\", \"breslow\"), conf_level = 0.95, interaction = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxreg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for Cox regression — control_coxreg","text":"pval_method (string) method used estimation p.values; wald (default) likelihood. ties (string) among exact (equivalent DISCRETE SAS), efron breslow, see survival::coxph(). Note: equivalent SAS EXACT method R. conf_level (proportion) confidence level interval. interaction (flag) TRUE, model includes interaction studied treatment candidate covariate. Note univariate models without treatment arm, multivariate models, interaction can used needs FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxreg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for Cox regression — control_coxreg","text":"list items names corresponding arguments.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/control_coxreg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for Cox regression — control_coxreg","text":"","code":"control_coxreg() #> $pval_method #> [1] \"wald\" #> #> $ties #> [1] \"exact\" #> #> $conf_level #> [1] 0.95 #> #> $interaction #> [1] FALSE #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_incidence_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for incidence rate — control_incidence_rate","title":"Control function for incidence rate — control_incidence_rate","text":"auxiliary function controlling arguments incidence rate, used internally specify details s_incidence_rate().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_incidence_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for incidence rate — control_incidence_rate","text":"","code":"control_incidence_rate( conf_level = 0.95, conf_type = c(\"normal\", \"normal_log\", \"exact\", \"byar\"), input_time_unit = c(\"year\", \"day\", \"week\", \"month\"), num_pt_year = 100 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_incidence_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for incidence rate — control_incidence_rate","text":"conf_level (proportion) confidence level interval. conf_type (string)normal (default), normal_log, exact, byar confidence interval type. input_time_unit (string)day, week, month, year (default) indicating time unit data input. num_pt_year (numeric(1)) number patient-years use calculating adverse event rates.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_incidence_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for incidence rate — control_incidence_rate","text":"list components names arguments.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/control_incidence_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for incidence rate — control_incidence_rate","text":"","code":"control_incidence_rate(0.9, \"exact\", \"month\", 100) #> $conf_level #> [1] 0.9 #> #> $conf_type #> [1] \"exact\" #> #> $input_time_unit #> [1] \"month\" #> #> $num_pt_year #> [1] 100 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_lineplot_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for g_lineplot() — control_lineplot_vars","title":"Control function for g_lineplot() — control_lineplot_vars","text":"Default values variables parameter g_lineplot function. variable's default value can overwritten variable.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_lineplot_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for g_lineplot() — control_lineplot_vars","text":"","code":"control_lineplot_vars( x = \"AVISIT\", y = \"AVAL\", group_var = \"ARM\", facet_var = NA, paramcd = \"PARAMCD\", y_unit = \"AVALU\", subject_var = \"USUBJID\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_lineplot_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for g_lineplot() — control_lineplot_vars","text":"x (string) x-variable name. y (string) y-variable name. group_var (string NA) group variable name. facet_var (string NA) faceting variable name. paramcd (string NA) parameter code variable name. y_unit (string NA) y-axis unit variable name. subject_var (string NA) subject variable name.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_lineplot_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for g_lineplot() — control_lineplot_vars","text":"named character vector variable names.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_lineplot_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for g_lineplot() — control_lineplot_vars","text":"","code":"control_lineplot_vars() #> x y group_var paramcd y_unit subject_var #> \"AVISIT\" \"AVAL\" \"ARM\" \"PARAMCD\" \"AVALU\" \"USUBJID\" #> facet_var #> NA control_lineplot_vars(group_var = NA) #> x y group_var paramcd y_unit subject_var #> \"AVISIT\" \"AVAL\" NA \"PARAMCD\" \"AVALU\" \"USUBJID\" #> facet_var #> NA"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_logistic.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for logistic regression model fitting — control_logistic","title":"Control function for logistic regression model fitting — control_logistic","text":"auxiliary function controlling arguments logistic regression models. conf_level refers confidence level used Odds Ratio CIs.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_logistic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for logistic regression model fitting — control_logistic","text":"","code":"control_logistic(response_definition = \"response\", conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_logistic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for logistic regression model fitting — control_logistic","text":"response_definition (string) definition event terms response. used fitting logistic regression model left hand side formula. Note evaluated expression result either logical vector factor 2 levels. default just \"response\" original response variable used modified . conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_logistic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for logistic regression model fitting — control_logistic","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_logistic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for logistic regression model fitting — control_logistic","text":"","code":"# Standard options. control_logistic() #> $response_definition #> [1] \"response\" #> #> $conf_level #> [1] 0.95 #> # Modify confidence level. control_logistic(conf_level = 0.9) #> $response_definition #> [1] \"response\" #> #> $conf_level #> [1] 0.9 #> # Use a different response definition. control_logistic(response_definition = \"I(response %in% c('CR', 'PR'))\") #> $response_definition #> [1] \"I(response %in% c('CR', 'PR'))\" #> #> $conf_level #> [1] 0.95 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_riskdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for risk difference column — control_riskdiff","title":"Control function for risk difference column — control_riskdiff","text":"Sets list parameters use generating risk (proportion) difference column. Used input riskdiff parameter tabulate_rsp_subgroups() tabulate_survival_subgroups().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_riskdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for risk difference column — control_riskdiff","text":"","code":"control_riskdiff( arm_x = NULL, arm_y = NULL, format = \"xx.x (xx.x - xx.x)\", col_label = \"Risk Difference (%) (95% CI)\", pct = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_riskdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for risk difference column — control_riskdiff","text":"arm_x (string) name reference arm use risk difference calculations. arm_y (character) names one arms compare reference arm risk difference calculations. new column added value arm_y. format (string function) format label (string) formatting function apply risk difference statistic. See 3d string options formatters::list_valid_format_labels() possible format strings. Defaults \"xx.x (xx.x - xx.x)\". col_label (character) labels use rendering risk difference column within table. one comparison arm specified arm_y, default labels specify two arms compared (reference arm vs. comparison arm). pct (flag) whether output returned percentages. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_riskdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for risk difference column — control_riskdiff","text":"list items names corresponding arguments.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/control_riskdiff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for risk difference column — control_riskdiff","text":"","code":"control_riskdiff() #> $arm_x #> NULL #> #> $arm_y #> NULL #> #> $format #> [1] \"xx.x (xx.x - xx.x)\" #> #> $col_label #> [1] \"Risk Difference (%) (95% CI)\" #> #> $pct #> [1] TRUE #> control_riskdiff(arm_x = \"ARM A\", arm_y = \"ARM B\") #> $arm_x #> [1] \"ARM A\" #> #> $arm_y #> [1] \"ARM B\" #> #> $format #> [1] \"xx.x (xx.x - xx.x)\" #> #> $col_label #> [1] \"Risk Difference (%) (95% CI)\" #> #> $pct #> [1] TRUE #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"auxiliary function controlling arguments STEP calculations.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"","code":"control_step( biomarker = NULL, use_percentile = TRUE, bandwidth, degree = 0L, num_points = 39L )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"biomarker (numeric NULL) optional provision numeric biomarker variable, used infer bandwidth, see . use_percentile (flag) TRUE, running windows created according quantiles rather actual values, .e. bandwidth refers percentage data covered window. Suggest TRUE biomarker variable uniformly distributed. bandwidth (numeric(1) NULL) indicating bandwidth window. Depending argument use_percentile, can either length actual-value windows real biomarker scale, percentage windows. use_percentile = TRUE, number 0 1. NULL, treat bandwidth infinity, means one global model fitted. default, 0.25 used percentage windows one quarter range biomarker variable actual-value windows. degree (integer(1)) degree polynomial function biomarker interaction term treatment arm fitted window. 0 (default), biomarker variable included model fitted biomarker window. num_points (integer(1)) number points hazard ratios estimated. smallest number 2.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"list components names arguments, except biomarker just used calculate bandwidth case actual biomarker windows requested.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control function for subgroup treatment effect pattern (STEP) calculations — control_step","text":"","code":"# Provide biomarker values and request actual values to be used, # so that bandwidth is chosen from range. control_step(biomarker = 1:10, use_percentile = FALSE) #> $use_percentile #> [1] FALSE #> #> $bandwidth #> [1] 2.25 #> #> $degree #> [1] 0 #> #> $num_points #> [1] 39 #> # Use a global model with quadratic biomarker interaction term. control_step(bandwidth = NULL, degree = 2) #> $use_percentile #> [1] TRUE #> #> $bandwidth #> NULL #> #> $degree #> [1] 2 #> #> $num_points #> [1] 39 #> # Reduce number of points to be used. control_step(num_points = 10) #> $use_percentile #> [1] TRUE #> #> $bandwidth #> [1] 0.25 #> #> $degree #> [1] 0 #> #> $num_points #> [1] 10 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for survfit models for survival time — control_surv_time","title":"Control function for survfit models for survival time — control_surv_time","text":"auxiliary function controlling arguments survfit model, typically used internally specify details survfit model s_surv_time(). conf_level refers survival time estimation.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for survfit models for survival time — control_surv_time","text":"","code":"control_surv_time( conf_level = 0.95, conf_type = c(\"plain\", \"log\", \"log-log\"), quantiles = c(0.25, 0.75) )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for survfit models for survival time — control_surv_time","text":"conf_level (proportion) confidence level interval. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" longer supported. quantiles (numeric(2)) vector length two specifying quantiles survival time.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for survfit models for survival time — control_surv_time","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_timepoint.html","id":null,"dir":"Reference","previous_headings":"","what":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"auxiliary function controlling arguments survfit model, typically used internally specify details survfit model s_surv_timepoint(). conf_level refers patient risk estimation time point.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_timepoint.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"","code":"control_surv_timepoint( conf_level = 0.95, conf_type = c(\"plain\", \"log\", \"log-log\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_timepoint.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"conf_level (proportion) confidence level interval. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" longer supported.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/control_surv_timepoint.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control function for survfit models for patients' survival rate at time points — control_surv_timepoint","text":"list components names arguments.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_cumulative.html","id":null,"dir":"Reference","previous_headings":"","what":"Cumulative counts of numeric variable by thresholds — count_cumulative","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"analyze function count_cumulative() creates layout element calculate cumulative counts values numeric variable less , less equal , greater , greater equal user-specified threshold values. function analyzes numeric variable vars threshold values supplied thresholds argument numeric vector. Whether counts include threshold values, whether count values lower higher threshold values can set via include_eq lower_tail parameters, respectively.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_cumulative.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"","code":"count_cumulative( lyt, vars, thresholds, lower_tail = TRUE, include_eq = TRUE, var_labels = vars, show_labels = \"visible\", na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_cumulative( x, thresholds, lower_tail = TRUE, include_eq = TRUE, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\"), ... ) a_count_cumulative( x, thresholds, lower_tail = TRUE, include_eq = TRUE, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\"), ... )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_cumulative.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . thresholds (numeric) vector cutoff values counts. lower_tail (flag) whether count lower tail, default TRUE. include_eq (flag) whether include value equal threshold count, default TRUE. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_cumulative.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"count_cumulative() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_cumulative() table layout. s_count_cumulative() returns named list count_fractions: list thresholds value component, component containing vector count fraction. a_count_cumulative() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_cumulative.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"count_cumulative(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_cumulative(): Statistics function produces named list given numeric vector thresholds. a_count_cumulative(): Formatted analysis function used afun count_cumulative().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/count_cumulative.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cumulative counts of numeric variable by thresholds — count_cumulative","text":"","code":"basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_cumulative( vars = \"AGE\", thresholds = c(40, 60) ) %>% build_table(tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————— #> AGE #> <= 40 52 (75.4%) 58 (79.5%) 41 (70.7%) #> <= 60 69 (100%) 73 (100%) 58 (100%)"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_missed_doses.html","id":null,"dir":"Reference","previous_headings":"","what":"Count number of patients with missed doses by thresholds — count_missed_doses","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"analyze function creates layout element calculate cumulative counts patients number missed doses least equal user-specified threshold values. function analyzes numeric variable vars, variable numbers missed doses, threshold values supplied thresholds argument numeric vector. function assumes every row given data frame corresponds unique patient.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_missed_doses.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"","code":"count_missed_doses( lyt, vars, thresholds, var_labels = vars, show_labels = \"visible\", na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_count_nonmissing(x) s_count_missed_doses( x, thresholds, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\") ) a_count_missed_doses( x, thresholds, .N_col, .N_row, denom = c(\"N_col\", \"n\", \"N_row\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_missed_doses.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . thresholds (numeric) minimum number missed doses patients . var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_missed_doses.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"count_missed_doses() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_missed_doses() table layout. s_count_nonmissing() returns statistic n count non-missing values x. s_count_missed_doses() returns statistics n count_fraction one element threshold. a_count_missed_doses() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_missed_doses.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"count_missed_doses(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_nonmissing(): Statistics function count non-missing values. s_count_missed_doses(): Statistics function count patients missed doses. a_count_missed_doses(): Formatted analysis function used afun count_missed_doses().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/count_missed_doses.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count number of patients with missed doses by thresholds — count_missed_doses","text":"","code":"library(dplyr) anl <- tern_ex_adsl %>% distinct(STUDYID, USUBJID, ARM) %>% mutate( PARAMCD = \"TNDOSMIS\", PARAM = \"Total number of missed doses during study\", AVAL = sample(0:20, size = nrow(tern_ex_adsl), replace = TRUE), AVALC = \"\" ) basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_missed_doses(\"AVAL\", thresholds = c(1, 5, 10, 15), var_labels = \"Missed Doses\") %>% build_table(anl, alt_counts_df = tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————— #> Missed Doses #> n 69 73 58 #> At least 1 missed dose 69 (100%) 69 (94.5%) 55 (94.8%) #> At least 5 missed doses 57 (82.6%) 55 (75.3%) 50 (86.2%) #> At least 10 missed doses 40 (58%) 40 (54.8%) 32 (55.2%) #> At least 15 missed doses 26 (37.7%) 25 (34.2%) 13 (22.4%)"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":null,"dir":"Reference","previous_headings":"","what":"Count occurrences — count_occurrences","title":"Count occurrences — count_occurrences","text":"analyze function count_occurrences() creates layout element calculate occurrence counts patients. function analyzes variable(s) supplied vars returns table occurrence counts unique value (level) variable(s). variable (variables) must non-numeric. id variable used indicate unique subject identifiers (defaults USUBJID). multiple occurrences value recorded patient, value counted . summarize function summarize_occurrences() performs function count_occurrences() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count occurrences — count_occurrences","text":"","code":"count_occurrences( lyt, vars, id = \"USUBJID\", drop = TRUE, var_labels = vars, show_labels = \"hidden\", riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = \"count_fraction_fixed_dp\", .formats = NULL, .labels = NULL, .indent_mods = NULL ) summarize_occurrences( lyt, var, id = \"USUBJID\", drop = TRUE, riskdiff = FALSE, na_str = default_na_str(), ..., .stats = \"count_fraction_fixed_dp\", .formats = NULL, .indent_mods = NULL, .labels = NULL ) s_count_occurrences( df, denom = c(\"N_col\", \"n\", \"N_row\"), .N_col, .N_row, .df_row, drop = TRUE, .var = \"MHDECOD\", id = \"USUBJID\" ) a_count_occurrences( df, labelstr = \"\", id = \"USUBJID\", denom = c(\"N_col\", \"n\", \"N_row\"), drop = TRUE, .N_col, .N_row, .var = NULL, .df_row = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count occurrences — count_occurrences","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . id (string) subject variable name. drop (flag) whether non-appearing occurrence levels dropped resulting table. Note case remaining occurrence levels table sorted alphabetically. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. denom (string) choice denominator proportion. Options : N_col: total number patients column across rows. n: number patients occurrences. N_row: total number patients row across columns. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .df_row (data.frame) data frame across columns given row split. .var, var (string) single variable name passed rtables requested statistics function. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count occurrences — count_occurrences","text":"count_occurrences() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_occurrences() table layout. summarize_occurrences() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows containing statistics s_count_occurrences() table layout. s_count_occurrences() returns list : count: list counts one element per occurrence. count_fraction: list counts fractions one element per occurrence. fraction: list numerators denominators one element per occurrence. a_count_occurrences() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count occurrences — count_occurrences","text":"count_occurrences(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). summarize_occurrences(): Layout-creating function can take content function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_count_occurrences(): Statistics function counts number patients report occurrence. a_count_occurrences(): Formatted analysis function used afun count_occurrences().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count occurrences — count_occurrences","text":"default, occurrences appear given row split dropped table occurrences table sorted alphabetically per row split. Therefore, corresponding layout needs use split_fun = drop_split_levels split_rows_by calls. Use drop = FALSE like show occurrences.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count occurrences — count_occurrences","text":"","code":"library(dplyr) df <- data.frame( USUBJID = as.character(c( 1, 1, 2, 4, 4, 4, 6, 6, 6, 7, 7, 8 )), MHDECOD = c( \"MH1\", \"MH2\", \"MH1\", \"MH1\", \"MH1\", \"MH3\", \"MH2\", \"MH2\", \"MH3\", \"MH1\", \"MH2\", \"MH4\" ), ARM = rep(c(\"A\", \"B\"), each = 6), SEX = c(\"F\", \"F\", \"M\", \"M\", \"M\", \"M\", \"F\", \"F\", \"F\", \"M\", \"M\", \"F\") ) df_adsl <- df %>% select(USUBJID, ARM) %>% unique() # Create table layout lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_occurrences(vars = \"MHDECOD\", .stats = c(\"count_fraction\")) # Apply table layout to data and produce `rtable` object tbl <- lyt %>% build_table(df, alt_counts_df = df_adsl) %>% prune_table() tbl #> A B #> (N=3) (N=3) #> ——————————————————————————— #> MH1 3 (100%) 1 (33.3%) #> MH2 1 (33.3%) 2 (66.7%) #> MH3 1 (33.3%) 1 (33.3%) #> MH4 0 1 (33.3%) # Layout creating function with custom format. basic_table() %>% add_colcounts() %>% split_rows_by(\"SEX\", child_labels = \"visible\") %>% summarize_occurrences( var = \"MHDECOD\", .formats = c(\"count_fraction\" = \"xx.xx (xx.xx%)\") ) %>% build_table(df, alt_counts_df = df_adsl) #> all obs #> (N=6) #> ————————————————— #> F #> MH1 1 (16.7%) #> MH2 2 (33.3%) #> MH3 1 (16.7%) #> MH4 1 (16.7%) #> M #> MH1 3 (50.0%) #> MH2 1 (16.7%) #> MH3 1 (16.7%) # Count unique occurrences per subject. s_count_occurrences( df, .N_col = 4L, .N_row = 4L, .df_row = df, .var = \"MHDECOD\", id = \"USUBJID\" ) #> $count #> $count$MH1 #> [1] 4 #> #> $count$MH2 #> [1] 3 #> #> $count$MH3 #> [1] 2 #> #> $count$MH4 #> [1] 1 #> #> #> $count_fraction #> $count_fraction$MH1 #> [1] 4 1 #> #> $count_fraction$MH2 #> [1] 3.00 0.75 #> #> $count_fraction$MH3 #> [1] 2.0 0.5 #> #> $count_fraction$MH4 #> [1] 1.00 0.25 #> #> #> $fraction #> $fraction$MH1 #> num denom #> 4 4 #> #> $fraction$MH2 #> num denom #> 3 4 #> #> $fraction$MH3 #> num denom #> 2 4 #> #> $fraction$MH4 #> num denom #> 1 4 #> #> a_count_occurrences( df, .N_col = 4L, .df_row = df, .var = \"MHDECOD\", id = \"USUBJID\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 MH1 4 0 MH1 #> 2 MH2 3 0 MH2 #> 3 MH3 2 0 MH3 #> 4 MH4 1 0 MH4 #> 5 MH1 4 (100%) 0 MH1 #> 6 MH2 3 (75%) 0 MH2 #> 7 MH3 2 (50%) 0 MH3 #> 8 MH4 1 (25%) 0 MH4 #> 9 MH1 4 (100%) 0 MH1 #> 10 MH2 3 (75.0%) 0 MH2 #> 11 MH3 2 (50.0%) 0 MH3 #> 12 MH4 1 (25.0%) 0 MH4 #> 13 MH1 4/4 (100.0%) 0 MH1 #> 14 MH2 3/4 (75.0%) 0 MH2 #> 15 MH3 2/4 (50.0%) 0 MH3 #> 16 MH4 1/4 (25.0%) 0 MH4"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences_by_grade.html","id":null,"dir":"Reference","previous_headings":"","what":"Count occurrences by grade — count_occurrences_by_grade","title":"Count occurrences by grade — count_occurrences_by_grade","text":"analyze function count_occurrences_by_grade() creates layout element calculate occurrence counts grade. function analyzes primary analysis variable var indicates toxicity grades. id variable used indicate unique subject identifiers (defaults USUBJID). user can also supply list custom groups grades analyze via grade_groups parameter. remove_single argument remove single grades analysis grade groups analyzed. multiple grades recorded one patient highest grade level counted. summarize function summarize_occurrences_by_grade() performs function count_occurrences_by_grade() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences_by_grade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count occurrences by grade — count_occurrences_by_grade","text":"","code":"count_occurrences_by_grade( lyt, var, id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, var_labels = var, show_labels = \"default\", riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = var, .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .indent_mods = NULL, .labels = NULL ) summarize_occurrences_by_grade( lyt, var, id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, riskdiff = FALSE, na_str = default_na_str(), ..., .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .indent_mods = NULL, .labels = NULL ) s_count_occurrences_by_grade( df, .var, .N_row, .N_col, id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, denom = c(\"N_col\", \"n\", \"N_row\"), labelstr = \"\" ) a_count_occurrences_by_grade( df, labelstr = \"\", id = \"USUBJID\", grade_groups = list(), remove_single = TRUE, only_grade_groups = FALSE, denom = c(\"N_col\", \"n\", \"N_row\"), .N_col, .N_row, .df_row, .var = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences_by_grade.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count occurrences by grade — count_occurrences_by_grade","text":"lyt (PreDataTableLayouts) layout analyses added . id (string) subject variable name. grade_groups (named list character) list containing groupings grades. remove_single (flag)TRUE include elements one-element grade groups output list; case grade groups names included output. only_grade_groups set TRUE argument ignored. only_grade_groups (flag) whether specified grade groups included, individual grade rows removed (TRUE), grades grade groups displayed (FALSE). var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'count_fraction', 'count_fraction_fixed_dp' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. .labels (named character) labels statistics (without indent). df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. denom (string) choice denominator proportion. Options : N_col: total number patients column across rows. n: number patients occurrences. N_row: total number patients row across columns. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences_by_grade.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count occurrences by grade — count_occurrences_by_grade","text":"count_occurrences_by_grade() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_occurrences_by_grade() table layout. summarize_occurrences_by_grade() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows containing statistics s_count_occurrences_by_grade() table layout. s_count_occurrences_by_grade() returns list counts fractions one element per grade level grade level grouping. a_count_occurrences_by_grade() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences_by_grade.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count occurrences by grade — count_occurrences_by_grade","text":"count_occurrences_by_grade(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). summarize_occurrences_by_grade(): Layout-creating function can take content function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_count_occurrences_by_grade(): Statistics function counts number patients highest grade. a_count_occurrences_by_grade(): Formatted analysis function used afun count_occurrences_by_grade().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/count_occurrences_by_grade.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count occurrences by grade — count_occurrences_by_grade","text":"","code":"library(dplyr) df <- data.frame( USUBJID = as.character(c(1:6, 1)), ARM = factor(c(\"A\", \"A\", \"A\", \"B\", \"B\", \"B\", \"A\"), levels = c(\"A\", \"B\")), AETOXGR = factor(c(1, 2, 3, 4, 1, 2, 3), levels = c(1:5)), AESEV = factor( x = c(\"MILD\", \"MODERATE\", \"SEVERE\", \"MILD\", \"MILD\", \"MODERATE\", \"SEVERE\"), levels = c(\"MILD\", \"MODERATE\", \"SEVERE\") ), stringsAsFactors = FALSE ) df_adsl <- df %>% select(USUBJID, ARM) %>% unique() # Layout creating function with custom format. basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_occurrences_by_grade( var = \"AESEV\", .formats = c(\"count_fraction\" = \"xx.xx (xx.xx%)\") ) %>% build_table(df, alt_counts_df = df_adsl) #> A B #> (N=3) (N=3) #> ———————————————————————————————————————— #> MILD 0.00 (0.00%) 2.00 (66.67%) #> MODERATE 1.00 (33.33%) 1.00 (33.33%) #> SEVERE 2.00 (66.67%) 0.00 (0.00%) # Define additional grade groupings. grade_groups <- list( \"-Any-\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"), \"Grade 1-2\" = c(\"1\", \"2\"), \"Grade 3-5\" = c(\"3\", \"4\", \"5\") ) basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_occurrences_by_grade( var = \"AETOXGR\", grade_groups = grade_groups, only_grade_groups = TRUE ) %>% build_table(df, alt_counts_df = df_adsl) #> A B #> (N=3) (N=3) #> ————————————————————————————————— #> -Any- 3 (100%) 3 (100%) #> Grade 1-2 1 (33.3%) 2 (66.7%) #> Grade 3-5 2 (66.7%) 1 (33.3%) # Layout creating function with custom format. basic_table() %>% add_colcounts() %>% split_rows_by(\"ARM\", child_labels = \"visible\", nested = TRUE) %>% summarize_occurrences_by_grade( var = \"AESEV\", .formats = c(\"count_fraction\" = \"xx.xx (xx.xx%)\") ) %>% build_table(df, alt_counts_df = df_adsl) #> all obs #> (N=6) #> —————————————————————————— #> A #> MILD 0.00 (0.00%) #> MODERATE 1.00 (16.67%) #> SEVERE 2.00 (33.33%) #> B #> MILD 2.00 (33.33%) #> MODERATE 1.00 (16.67%) #> SEVERE 0.00 (0.00%) basic_table() %>% add_colcounts() %>% split_rows_by(\"ARM\", child_labels = \"visible\", nested = TRUE) %>% summarize_occurrences_by_grade( var = \"AETOXGR\", grade_groups = grade_groups ) %>% build_table(df, alt_counts_df = df_adsl) #> all obs #> (N=6) #> ——————————————————————— #> A #> -Any- 3 (50.0%) #> Grade 1-2 1 (16.7%) #> 1 0 #> 2 1 (16.7%) #> Grade 3-5 2 (33.3%) #> 3 2 (33.3%) #> 4 0 #> 5 0 #> B #> -Any- 3 (50.0%) #> Grade 1-2 2 (33.3%) #> 1 1 (16.7%) #> 2 1 (16.7%) #> Grade 3-5 1 (16.7%) #> 3 0 #> 4 1 (16.7%) #> 5 0 s_count_occurrences_by_grade( df, .N_col = 10L, .var = \"AETOXGR\", id = \"USUBJID\", grade_groups = list(\"ANY\" = levels(df$AETOXGR)) ) #> $count_fraction #> $count_fraction$ANY #> [1] 6.0 0.6 #> #> $count_fraction$`1` #> [1] 1.0 0.1 #> #> $count_fraction$`2` #> [1] 2.0 0.2 #> #> $count_fraction$`3` #> [1] 2.0 0.2 #> #> $count_fraction$`4` #> [1] 1.0 0.1 #> #> $count_fraction$`5` #> [1] 0 0 #> #> a_count_occurrences_by_grade( df, .N_col = 10L, .N_row = 10L, .var = \"AETOXGR\", id = \"USUBJID\", grade_groups = list(\"ANY\" = levels(df$AETOXGR)) ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 ANY 6 (60%) 0 ANY #> 2 1 1 (10%) 0 1 #> 3 2 2 (20%) 0 2 #> 4 3 2 (20%) 0 3 #> 5 4 1 (10%) 0 4 #> 6 5 0 0 5 #> 7 ANY 6 (60.0%) 0 ANY #> 8 1 1 (10.0%) 0 1 #> 9 2 2 (20.0%) 0 2 #> 10 3 2 (20.0%) 0 3 #> 11 4 1 (10.0%) 0 4 #> 12 5 0 0 5"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_events_in_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Count patient events in columns — count_patients_events_in_cols","title":"Count patient events in columns — count_patients_events_in_cols","text":"summarize function summarize_patients_events_in_cols() creates layout element summarize patient event counts columns. function analyzes elements (events) supplied via filters_list parameter returns row counts number patients event well total numbers patients events. id variable used indicate unique subject identifiers (defaults USUBJID). multiple occurrences event recorded patient, event counted .","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_events_in_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count patient events in columns — count_patients_events_in_cols","text":"","code":"summarize_patients_events_in_cols( lyt, id = \"USUBJID\", filters_list = list(), empty_stats = character(), na_str = default_na_str(), ..., .stats = c(\"unique\", \"all\", names(filters_list)), .labels = c(unique = \"Patients (All)\", all = \"Events (All)\", labels_or_names(filters_list)), col_split = TRUE ) s_count_patients_and_multiple_events( df, id, filters_list, empty_stats = character(), labelstr = \"\", custom_label = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_events_in_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count patient events in columns — count_patients_events_in_cols","text":"lyt (PreDataTableLayouts) layout analyses added . id (string) subject variable name. filters_list (named list character) list element list describes one type event describe filters, format s_count_patients_with_event(). label, used column title. empty_stats (character) optional names statistics returned empty corresponding table cells stay blank. na_str (string) string used replace NA empty values output. ... additional arguments lower level functions. .stats (character) statistics select table. addition statistics added using filters_list, statistic options : 'unique', '' .labels (named character) labels statistics (without indent). col_split (flag) whether columns split. Set FALSE required column split done already earlier layout pipe. df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. custom_label (string NULL) provided labelstr empty used label.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_events_in_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count patient events in columns — count_patients_events_in_cols","text":"summarize_patients_events_in_cols() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows containing statistics s_count_patients_and_multiple_events() table layout. s_count_patients_and_multiple_events() returns list statistics: unique: number unique patients df. : number rows df. one element name filters_list: number rows df, .e. events, fulfilling filter condition.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_events_in_cols.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count patient events in columns — count_patients_events_in_cols","text":"summarize_patients_events_in_cols(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_count_patients_and_multiple_events(): Statistics function counts numbers patients multiple events defined filters. Used analysis function afun summarize_patients_events_in_cols().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_events_in_cols.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count patient events in columns — count_patients_events_in_cols","text":"","code":"df <- data.frame( USUBJID = rep(c(\"id1\", \"id2\", \"id3\", \"id4\"), c(2, 3, 1, 1)), ARM = c(\"A\", \"A\", \"B\", \"B\", \"B\", \"B\", \"A\"), AESER = rep(\"Y\", 7), AESDTH = c(\"Y\", \"Y\", \"N\", \"Y\", \"Y\", \"N\", \"N\"), AEREL = c(\"Y\", \"Y\", \"N\", \"Y\", \"Y\", \"N\", \"Y\"), AEDECOD = c(\"A\", \"A\", \"A\", \"B\", \"B\", \"C\", \"D\"), AEBODSYS = rep(c(\"SOC1\", \"SOC2\", \"SOC3\"), c(3, 3, 1)) ) # `summarize_patients_events_in_cols()` basic_table() %>% summarize_patients_events_in_cols( filters_list = list( related = formatters::with_label(c(AEREL = \"Y\"), \"Events (Related)\"), fatal = c(AESDTH = \"Y\"), fatal_related = c(AEREL = \"Y\", AESDTH = \"Y\") ), custom_label = \"%s Total number of patients and events\" ) %>% build_table(df) #> Patients (All) Events (All) Events (Related) fatal fatal_related #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> %s Total number of patients and events 4 7 5 4 4"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_event.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the number of patients with a particular event — count_patients_with_event","title":"Count the number of patients with a particular event — count_patients_with_event","text":"analyze function count_patients_with_event() creates layout element calculate patient counts user-specified set events. function analyzes primary analysis variable vars indicates unique subject identifiers. Events defined user named vector via filters argument, name corresponds variable value value(s) variable takes event. multiple records event recorded patient, one occurrence counted.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_event.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the number of patients with a particular event — count_patients_with_event","text":"","code":"count_patients_with_event( lyt, vars, filters, riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .labels = NULL, .indent_mods = NULL ) s_count_patients_with_event( df, .var, filters, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") ) a_count_patients_with_event( df, labelstr = \"\", filters, denom = c(\"n\", \"N_col\", \"N_row\"), .N_col, .N_row, .df_row, .var = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_event.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the number of patients with a particular event — count_patients_with_event","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . filters (character) character vector specifying column names flag variables used counting number unique identifiers satisfying conditions. Multiple column names flags accepted format c(\"column_name1\" = \"flag1\", \"column_name2\" = \"flag2\"). Note equality accepted condition. riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) name column contains unique identifier. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_event.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count the number of patients with a particular event — count_patients_with_event","text":"count_patients_with_event() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_patients_with_event() table layout. s_count_patients_with_event() returns count fraction unique identifiers defined event. a_count_patients_with_event() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_event.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count the number of patients with a particular event — count_patients_with_event","text":"count_patients_with_event(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_patients_with_event(): Statistics function counts number patients defined event occurred. a_count_patients_with_event(): Formatted analysis function used afun count_patients_with_event().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_event.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the number of patients with a particular event — count_patients_with_event","text":"","code":"lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_values( \"STUDYID\", values = \"AB12345\", .stats = \"count\", .labels = c(count = \"Total AEs\") ) %>% count_patients_with_event( \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\"), .labels = c(count_fraction = \"Total number of patients with at least one adverse event\"), table_names = \"tbl_all\" ) %>% count_patients_with_event( \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\"), .labels = c(count_fraction = \"Total number of patients with fatal AEs\"), table_names = \"tbl_fatal\" ) %>% count_patients_with_event( \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\", \"AEREL\" = \"Y\"), .labels = c(count_fraction = \"Total number of patients with related fatal AEs\"), .indent_mods = c(count_fraction = 2L), table_names = \"tbl_rel_fatal\" ) build_table(lyt, tern_ex_adae, alt_counts_df = tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————————————————————————— #> Total AEs 202 177 162 #> Total number of patients with at least one adverse event 59 (100%) 57 (100%) 48 (100%) #> Total number of patients with fatal AEs 28 (47.5%) 31 (54.4%) 20 (41.7%) #> Total number of patients with related fatal AEs 28 (47.5%) 31 (54.4%) 20 (41.7%) s_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\") ) #> $n #> [1] 164 #> #> $count #> [1] 164 #> #> $count_fraction #> [1] 164 1 #> #> $n_blq #> [1] 0 #> s_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\") ) #> $n #> [1] 164 #> #> $count #> [1] 79 #> #> $count_fraction #> [1] 79.0000000 0.4817073 #> #> $n_blq #> [1] 0 #> s_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\", \"AEOUT\" = \"FATAL\"), denom = \"N_col\", .N_col = 456 ) #> $n #> [1] 164 #> #> $count #> [1] 79 #> #> $count_fraction #> [1] 79.0000000 0.1732456 #> #> $n_blq #> [1] 0 #> a_count_patients_with_event( tern_ex_adae, .var = \"SUBJID\", filters = c(\"TRTEMFL\" = \"Y\"), .N_col = 100, .N_row = 100 ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 164 0 n #> 2 count 164 0 count #> 3 count_fraction 164 (100%) 0 count_fraction #> 4 count_fraction_fixed_dp 164 (100%) 0 count_fraction #> 5 n_blq 0 0 n_blq"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the number of patients with particular flags — count_patients_with_flags","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"analyze function count_patients_with_flags() creates layout element calculate counts patients user-specified flags present. function analyzes primary analysis variable var indicates unique subject identifiers. Flags variables analyze specified user via flag_variables argument, must either take value TRUE (flag present) FALSE (flag absent) record. multiple records flag present patient, one occurrence counted.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"","code":"count_patients_with_flags( lyt, var, flag_variables, flag_labels = NULL, var_labels = var, show_labels = \"hidden\", riskdiff = FALSE, na_str = default_na_str(), nested = TRUE, ..., table_names = paste0(\"tbl_flags_\", var), .stats = \"count_fraction\", .formats = list(count_fraction = format_count_fraction_fixed_dp), .indent_mods = NULL, .labels = NULL ) s_count_patients_with_flags( df, .var, flag_variables, flag_labels = NULL, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") ) a_count_patients_with_flags( df, labelstr = \"\", flag_variables, flag_labels = NULL, denom = c(\"n\", \"N_col\", \"N_row\"), .N_col, .N_row, .df_row, .var = NULL, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. flag_variables (character) vector specifying names logical variables analysis dataset used counting number unique identifiers. flag_labels (character) vector labels use flag variables. labels also specified via .labels parameter, .labels values take precedence replace labels. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. .labels (named character) labels statistics (without indent). df (data.frame) data set containing analysis variables. .var (string) name column contains unique identifier. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"count_patients_with_flags() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_patients_with_flags() table layout. s_count_patients_with_flags() returns count fraction unique identifiers particular flag list statistics n, count, count_fraction, n_blq, one element per flag. a_count_patients_with_flags() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"count_patients_with_flags(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_patients_with_flags(): Statistics function counts number patients particular flag variable TRUE. a_count_patients_with_flags(): Formatted analysis function used afun count_patients_with_flags().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"flag_labels specified, variables labels extracted df. variables labeled, variable names used instead. Alternatively, named vector can supplied flag_variables within name-value pair name corresponds variable name value label use variable.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/count_patients_with_flags.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the number of patients with particular flags — count_patients_with_flags","text":"","code":"# Add labelled flag variables to analysis dataset. adae <- tern_ex_adae %>% dplyr::mutate( fl1 = TRUE %>% with_label(\"Total AEs\"), fl2 = (TRTEMFL == \"Y\") %>% with_label(\"Total number of patients with at least one adverse event\"), fl3 = (TRTEMFL == \"Y\" & AEOUT == \"FATAL\") %>% with_label(\"Total number of patients with fatal AEs\"), fl4 = (TRTEMFL == \"Y\" & AEOUT == \"FATAL\" & AEREL == \"Y\") %>% with_label(\"Total number of patients with related fatal AEs\") ) lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% count_patients_with_flags( \"SUBJID\", flag_variables = c(\"fl1\", \"fl2\", \"fl3\", \"fl4\"), denom = \"N_col\" ) build_table(lyt, adae, alt_counts_df = tern_ex_adsl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————————————————————————— #> Total AEs 59 (85.5%) 57 (78.1%) 48 (82.8%) #> Total number of patients with at least one adverse event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> Total number of patients with fatal AEs 28 (40.6%) 31 (42.5%) 20 (34.5%) #> Total number of patients with related fatal AEs 28 (40.6%) 31 (42.5%) 20 (34.5%) # `s_count_patients_with_flags()` s_count_patients_with_flags( adae, \"SUBJID\", flag_variables = c(\"fl1\", \"fl2\", \"fl3\", \"fl4\"), denom = \"N_col\", .N_col = 1000 ) #> $n #> $n$`Total AEs` #> [1] 164 #> #> $n$`Total number of patients with at least one adverse event` #> [1] 164 #> #> $n$`Total number of patients with fatal AEs` #> [1] 164 #> #> $n$`Total number of patients with related fatal AEs` #> [1] 164 #> #> #> $count #> $count$`Total AEs` #> [1] 164 #> #> $count$`Total number of patients with at least one adverse event` #> [1] 164 #> #> $count$`Total number of patients with fatal AEs` #> [1] 79 #> #> $count$`Total number of patients with related fatal AEs` #> [1] 79 #> #> #> $count_fraction #> $count_fraction$`Total AEs` #> [1] 164.000 0.164 #> #> $count_fraction$`Total number of patients with at least one adverse event` #> [1] 164.000 0.164 #> #> $count_fraction$`Total number of patients with fatal AEs` #> [1] 79.000 0.079 #> #> $count_fraction$`Total number of patients with related fatal AEs` #> [1] 79.000 0.079 #> #> #> $n_blq #> $n_blq$`Total AEs` #> [1] 0 #> #> $n_blq$`Total number of patients with at least one adverse event` #> [1] 0 #> #> $n_blq$`Total number of patients with fatal AEs` #> [1] 0 #> #> $n_blq$`Total number of patients with related fatal AEs` #> [1] 0 #> #> a_count_patients_with_flags( adae, .N_col = 10L, .N_row = 10L, .var = \"USUBJID\", flag_variables = c(\"fl1\", \"fl2\", \"fl3\", \"fl4\") ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 n.fl1 164 0 #> 2 n.fl2 164 0 #> 3 n.fl3 164 0 #> 4 n.fl4 164 0 #> 5 count.fl1 164 0 #> 6 count.fl2 164 0 #> 7 count.fl3 79 0 #> 8 count.fl4 79 0 #> 9 count_fraction.fl1 164 (100%) 0 #> 10 count_fraction.fl2 164 (100%) 0 #> 11 count_fraction.fl3 79 (48.2%) 0 #> 12 count_fraction.fl4 79 (48.2%) 0 #> 13 count_fraction_fixed_dp.fl1 164 (100%) 0 #> 14 count_fraction_fixed_dp.fl2 164 (100%) 0 #> 15 count_fraction_fixed_dp.fl3 79 (48.2%) 0 #> 16 count_fraction_fixed_dp.fl4 79 (48.2%) 0 #> 17 n_blq.fl1 0 0 #> 18 n_blq.fl2 0 0 #> 19 n_blq.fl3 0 0 #> 20 n_blq.fl4 0 0 #> row_label #> 1 Total AEs #> 2 Total number of patients with at least one adverse event #> 3 Total number of patients with fatal AEs #> 4 Total number of patients with related fatal AEs #> 5 Total AEs #> 6 Total number of patients with at least one adverse event #> 7 Total number of patients with fatal AEs #> 8 Total number of patients with related fatal AEs #> 9 Total AEs #> 10 Total number of patients with at least one adverse event #> 11 Total number of patients with fatal AEs #> 12 Total number of patients with related fatal AEs #> 13 Total AEs #> 14 Total number of patients with at least one adverse event #> 15 Total number of patients with fatal AEs #> 16 Total number of patients with related fatal AEs #> 17 Total AEs #> 18 Total number of patients with at least one adverse event #> 19 Total number of patients with fatal AEs #> 20 Total number of patients with related fatal AEs"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":null,"dir":"Reference","previous_headings":"","what":"Count specific values — count_values","title":"Count specific values — count_values","text":"analyze function count_values() creates layout element calculate counts specific values within variable interest. function analyzes one variables interest supplied vector vars. Values count variable(s) vars can given vector via values argument. One row counts generated variable.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count specific values — count_values","text":"","code":"count_values( lyt, vars, values, na_str = default_na_str(), nested = TRUE, ..., table_names = vars, .stats = \"count_fraction\", .formats = NULL, .labels = c(count_fraction = paste(values, collapse = \", \")), .indent_mods = NULL ) s_count_values( x, values, na.rm = TRUE, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") ) # S3 method for class 'character' s_count_values(x, values = \"Y\", na.rm = TRUE, ...) # S3 method for class 'factor' s_count_values(x, values = \"Y\", ...) # S3 method for class 'logical' s_count_values(x, values = TRUE, ...) a_count_values( x, values, na.rm = TRUE, .N_col, .N_row, denom = c(\"n\", \"N_col\", \"N_row\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count specific values — count_values","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . values (character) specific values counted. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'n_blq' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. na.rm (flag) whether NA values removed x prior analysis. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .N_row (integer(1)) row-wise N (row group count) group observations analyzed (.e. column-based subsetting) typically passed rtables. denom (string) choice denominator proportion. Options : n: number values row column intersection. N_row: total number values row across columns. N_col: total number values column across rows.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count specific values — count_values","text":"count_values() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_count_values() table layout. s_count_values() returns output s_summary() specified values non-numeric variable. a_count_values() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count specific values — count_values","text":"count_values(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_count_values(): S3 generic function count values. s_count_values(character): Method character class. s_count_values(factor): Method factor class. makes automatic conversion character forwards method characters. s_count_values(logical): Method logical class. a_count_values(): Formatted analysis function used afun count_values().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count specific values — count_values","text":"factor variables, s_count_values checks whether values included levels x fails otherwise. count_values(), variable labels shown one element vars, otherwise hidden.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/count_values.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count specific values — count_values","text":"","code":"# `count_values` basic_table() %>% count_values(\"Species\", values = \"setosa\") %>% build_table(iris) #> all obs #> ———————————————————— #> setosa 50 (33.33%) # `s_count_values.character` s_count_values(x = c(\"a\", \"b\", \"a\"), values = \"a\") #> $n #> [1] 3 #> #> $count #> [1] 2 #> #> $count_fraction #> [1] 2.0000000 0.6666667 #> #> $n_blq #> [1] 0 #> s_count_values(x = c(\"a\", \"b\", \"a\", NA, NA), values = \"b\", na.rm = FALSE) #> $n #> [1] 5 #> #> $count #> [1] 1 #> #> $count_fraction #> [1] 1.0 0.2 #> #> $n_blq #> [1] 0 #> # `s_count_values.factor` s_count_values(x = factor(c(\"a\", \"b\", \"a\")), values = \"a\") #> $n #> [1] 3 #> #> $count #> [1] 2 #> #> $count_fraction #> [1] 2.0000000 0.6666667 #> #> $n_blq #> [1] 0 #> # `s_count_values.logical` s_count_values(x = c(TRUE, FALSE, TRUE)) #> $n #> [1] 3 #> #> $count #> [1] 2 #> #> $count_fraction #> [1] 2.0000000 0.6666667 #> #> $n_blq #> [1] 0 #> # `a_count_values` a_count_values(x = factor(c(\"a\", \"b\", \"a\")), values = \"a\", .N_col = 10, .N_row = 10) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n 3 0 n #> 2 count 2 0 count #> 3 count_fraction 2 (66.67%) 0 count_fraction #> 4 n_blq 0 0 n_blq"},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":null,"dir":"Reference","previous_headings":"","what":"Cox proportional hazards regression — cox_regression","title":"Cox proportional hazards regression — cox_regression","text":"Fits Cox regression model estimates hazard ratio describe effect size survival analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cox proportional hazards regression — cox_regression","text":"","code":"summarize_coxreg( lyt, variables, control = control_coxreg(), at = list(), multivar = FALSE, common_var = \"STUDYID\", .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\"), .formats = c(n = \"xx\", hr = \"xx.xx\", ci = \"(xx.xx, xx.xx)\", pval = \"x.xxxx | (<0.0001)\", pval_inter = \"x.xxxx | (<0.0001)\"), varlabels = NULL, .indent_mods = NULL, na_str = \"\", .section_div = NA_character_ ) s_coxreg(model_df, .stats, .which_vars = \"all\", .var_nms = NULL) a_coxreg( df, labelstr, eff = FALSE, var_main = FALSE, multivar = FALSE, variables, at = list(), control = control_coxreg(), .spl_context, .stats, .formats, .indent_mods = NULL, na_str = \"\", cache_env = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cox proportional hazards regression — cox_regression","text":"lyt (PreDataTableLayouts) layout analyses added . variables (named list string) list additional analysis variables. control (list) list parameters returned helper function control_coxreg(). (list numeric) candidate covariate numeric, use specify value covariate effect estimated. multivar (flag) whether multivariate Cox regression run (defaults FALSE), otherwise univariate Cox regression run. common_var (string) name factor variable dataset takes value rows. created pre-processing variable currently exists. .stats (character) names statistics reported among: n: number observations (univariate ) hr: hazard ratio ci: confidence interval pval: p-value treatment effect pval_inter: p-value interaction effect treatment covariate (univariate ) .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. varlabels (list) named list corresponds names variables found data, passed named list corresponding time, event, arm, strata, covariates terms. arm missing variables, Cox model(s) including covariates fitted corresponding effect estimates tabulated later. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. na_str (string) custom string replace NA values . Defaults \"\". .section_div (string NA) string repeated section divider sections. Defaults NA section divider. vector two strings given, first used treatment covariate sections second different covariates. model_df (data.frame) contains resulting model fit fit_coxreg function tidying applied via broom::tidy(). .which_vars (character) rows statistics returned given model. Defaults \"\". options include \"var_main\" main effects, \"inter\" interaction effects, \"multi_lvl\" multivariate model covariate level rows. .which_vars \"\", specific variables can selected specifying .var_nms. .var_nms (character) term value rows df .stats returned. Typically name variable. using variable labels, var vector desired variable name variable label order see .stats related variable. .which_vars \"var_main\", .var_nms variable name. df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. eff (flag) whether treatment effect calculated. Defaults FALSE. var_main (flag) whether main effects calculated. Defaults FALSE. .spl_context (data.frame) gives information ancestor split states passed rtables. cache_env (environment) environment object used cache regression model order avoid repeatedly fitting model every row table. Defaults NULL (caching).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cox proportional hazards regression — cox_regression","text":"summarize_coxreg() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add Cox regression table containing chosen statistics table layout. s_coxreg() returns selected statistic Cox regression model selected variable(s). a_coxreg() returns formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cox proportional hazards regression — cox_regression","text":"Cox models commonly used methods estimate magnitude effect survival analysis. assumes proportional hazards: ratio hazards groups (e.g., two arms) constant time. ratio referred \"hazard ratio\" (HR) one commonly reported metrics describe effect size survival analysis (NEST Team, 2020).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cox proportional hazards regression — cox_regression","text":"summarize_coxreg(): Layout-creating function creates Cox regression summary table layout. function wrapper several rtables layouting functions. function wrapper rtables::analyze_colvars() rtables::summarize_row_groups(). s_coxreg(): Statistics function transforms results tabulated fit_coxreg_univar() fit_coxreg_multivar() list. a_coxreg(): Analysis function used afun rtables::analyze() cfun rtables::summarize_row_groups() within summarize_coxreg().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cox proportional hazards regression — cox_regression","text":"","code":"library(survival) # Testing dataset [survival::bladder]. set.seed(1, kind = \"Mersenne-Twister\") dta_bladder <- with( data = bladder[bladder$enum < 5, ], tibble::tibble( TIME = stop, STATUS = event, ARM = as.factor(rx), COVAR1 = as.factor(enum) %>% formatters::with_label(\"A Covariate Label\"), COVAR2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) %>% formatters::with_label(\"Sex (F/M)\") ) ) dta_bladder$AGE <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) dta_bladder$STUDYID <- factor(\"X\") u1_variables <- list( time = \"TIME\", event = \"STATUS\", arm = \"ARM\", covariates = c(\"COVAR1\", \"COVAR2\") ) u2_variables <- list(time = \"TIME\", event = \"STATUS\", covariates = c(\"COVAR1\", \"COVAR2\")) m1_variables <- list( time = \"TIME\", event = \"STATUS\", arm = \"ARM\", covariates = c(\"COVAR1\", \"COVAR2\") ) m2_variables <- list(time = \"TIME\", event = \"STATUS\", covariates = c(\"COVAR1\", \"COVAR2\")) # summarize_coxreg result_univar <- basic_table() %>% summarize_coxreg(variables = u1_variables) %>% build_table(dta_bladder) result_univar #> n Hazard Ratio 95% CI p-value #> ————————————————————————————————————————————————————————————————— #> Treatment: #> 2 vs control (1) 340 0.64 (0.43, 0.94) 0.0242 #> Covariate: #> A Covariate Label 340 0.61 (0.41, 0.90) 0.0126 #> Sex (F/M) 340 0.62 (0.42, 0.92) 0.0182 result_univar_covs <- basic_table() %>% summarize_coxreg( variables = u2_variables, ) %>% build_table(dta_bladder) result_univar_covs #> Hazard Ratio 95% CI p-value #> ——————————————————————————————————————————————————————————————————————————— #> Covariate: #> A Covariate Label (reference = 1) <0.0001 #> 2 0.45 (0.28, 0.71) 0.0007 #> 3 0.31 (0.19, 0.52) <0.0001 #> 4 0.18 (0.10, 0.33) <0.0001 #> Sex (F/M) (reference = F) #> M 1.33 (0.91, 1.94) 0.1414 result_multivar <- basic_table() %>% summarize_coxreg( variables = m1_variables, multivar = TRUE, ) %>% build_table(dta_bladder) result_multivar #> Hazard Ratio 95% CI p-value #> ——————————————————————————————————————————————————————————————————————————— #> Treatment: #> ARM (reference = 1) #> 2 0.61 (0.41, 0.90) 0.0123 #> Covariate: #> A Covariate Label (reference = 1) <0.0001 #> 2 0.46 (0.28, 0.73) 0.0011 #> 3 0.31 (0.18, 0.51) <0.0001 #> 4 0.18 (0.10, 0.33) <0.0001 #> Sex (F/M) (reference = F) #> M 1.29 (0.88, 1.89) 0.1911 result_multivar_covs <- basic_table() %>% summarize_coxreg( variables = m2_variables, multivar = TRUE, varlabels = c(\"Covariate 1\", \"Covariate 2\") # custom labels ) %>% build_table(dta_bladder) result_multivar_covs #> Hazard Ratio 95% CI p-value #> ————————————————————————————————————————————————————————————————————— #> Covariate: #> Covariate 1 (reference = 1) <0.0001 #> 2 0.46 (0.29, 0.74) 0.0012 #> 3 0.31 (0.19, 0.52) <0.0001 #> 4 0.19 (0.10, 0.34) <0.0001 #> Covariate 2 (reference = F) #> M 1.29 (0.88, 1.88) 0.1958 # s_coxreg # Univariate univar_model <- fit_coxreg_univar(variables = u1_variables, data = dta_bladder) df1 <- broom::tidy(univar_model) s_coxreg(model_df = df1, .stats = \"hr\") #> $hr #> $hr$`2 vs control (1)` #> [1] 0.6386426 #> #> #> $hr #> $hr$`A Covariate Label` #> [1] 0.607037 #> #> #> $hr #> $hr$`Sex (F/M)` #> [1] 0.6242738 #> #> # Univariate with interactions univar_model_inter <- fit_coxreg_univar( variables = u1_variables, control = control_coxreg(interaction = TRUE), data = dta_bladder ) df1_inter <- broom::tidy(univar_model_inter) s_coxreg(model_df = df1_inter, .stats = \"hr\", .which_vars = \"inter\", .var_nms = \"COVAR1\") #> $hr #> $hr$` 1` #> [1] 0.6284569 #> #> $hr$` 2` #> [1] 0.5806499 #> #> $hr$` 3` #> [1] 0.5486103 #> #> $hr$` 4` #> [1] 0.6910725 #> #> # Univariate without treatment arm - only \"COVAR2\" covariate effects univar_covs_model <- fit_coxreg_univar(variables = u2_variables, data = dta_bladder) df1_covs <- broom::tidy(univar_covs_model) s_coxreg(model_df = df1_covs, .stats = \"hr\", .var_nms = c(\"COVAR2\", \"Sex (F/M)\")) #> $hr #> $hr$`Sex (F/M) (reference = F)` #> numeric(0) #> #> #> $hr #> $hr$M #> [1] 1.3271 #> #> # Multivariate. multivar_model <- fit_coxreg_multivar(variables = m1_variables, data = dta_bladder) df2 <- broom::tidy(multivar_model) s_coxreg(model_df = df2, .stats = \"pval\", .which_vars = \"var_main\", .var_nms = \"COVAR1\") #> $pval #> $pval$`A Covariate Label (reference = 1)` #> [1] 7.209956e-09 #> #> s_coxreg( model_df = df2, .stats = \"pval\", .which_vars = \"multi_lvl\", .var_nms = c(\"COVAR1\", \"A Covariate Label\") ) #> $pval #> $pval$`2` #> [1] 0.001120332 #> #> $pval$`3` #> [1] 6.293725e-06 #> #> $pval$`4` #> [1] 3.013875e-08 #> #> # Multivariate without treatment arm - only \"COVAR1\" main effect multivar_covs_model <- fit_coxreg_multivar(variables = m2_variables, data = dta_bladder) df2_covs <- broom::tidy(multivar_covs_model) s_coxreg(model_df = df2_covs, .stats = \"hr\") #> $hr #> $hr$`2` #> [1] 0.4600728 #> #> $hr$`3` #> [1] 0.3100455 #> #> $hr$`4` #> [1] 0.1854177 #> #> #> $hr #> $hr$`A Covariate Label (reference = 1)` #> numeric(0) #> #> #> $hr #> $hr$`Sex (F/M) (reference = F)` #> numeric(0) #> #> #> $hr #> $hr$M #> [1] 1.285406 #> #> a_coxreg( df = dta_bladder, labelstr = \"Label 1\", variables = u1_variables, .spl_context = list(value = \"COVAR1\"), .stats = \"n\", .formats = \"xx\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Label 1 340 0 Label 1 a_coxreg( df = dta_bladder, labelstr = \"\", variables = u1_variables, .spl_context = list(value = \"COVAR2\"), .stats = \"pval\", .formats = \"xx.xxxx\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Sex (F/M) 0.0182 0 Sex (F/M)"},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":null,"dir":"Reference","previous_headings":"","what":"Cox regression helper function for interactions — cox_regression_inter","title":"Cox regression helper function for interactions — cox_regression_inter","text":"Test estimate effect treatment interaction covariate. effect estimated HR tested treatment given level covariate, comparison treatment control.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cox regression helper function for interactions — cox_regression_inter","text":"","code":"h_coxreg_inter_effect(x, effect, covar, mod, label, control, ...) # S3 method for class 'numeric' h_coxreg_inter_effect(x, effect, covar, mod, label, control, at, ...) # S3 method for class 'factor' h_coxreg_inter_effect(x, effect, covar, mod, label, control, data, ...) # S3 method for class 'character' h_coxreg_inter_effect(x, effect, covar, mod, label, control, data, ...) h_coxreg_extract_interaction(effect, covar, mod, data, at, control) h_coxreg_inter_estimations( variable, given, lvl_var, lvl_given, mod, conf_level = 0.95 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cox regression helper function for interactions — cox_regression_inter","text":"x (numeric factor) values covariate tested. effect (string) name effect tested estimated. covar (string) name covariate model. mod (coxph) fitted Cox regression model (see survival::coxph()). label (string) label returned term_label. control (list) list controls returned control_coxreg(). ... see methods. (list) list items named covariate, every item vector levels interaction estimated. data (data.frame) data frame model fit. variable, given (string) name variables interaction. seek estimation levels variable given levels given. lvl_var, lvl_given (character) corresponding levels given levels(). conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cox regression helper function for interactions — cox_regression_inter","text":"h_coxreg_inter_effect() returns data.frame covariate interaction effects consisting following variables: effect, term, term_label, level, n, hr, lcl, ucl, pval, pval_inter. h_coxreg_extract_interaction() returns result interaction test estimated values. interaction, h_coxreg_univar_extract() applied instead. h_coxreg_inter_estimations() returns list matrices (one per level variable) rows corresponding combinations variable given, columns: coef_hat: Estimation coefficient. coef_se: Standard error estimation. hr: Hazard ratio. lcl, ucl: Lower/upper confidence limit hazard ratio.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cox regression helper function for interactions — cox_regression_inter","text":"Given cox regression investigating effect Arm (, B, C; reference ) Sex (F, M; reference Female) model abbreviated: y ~ Arm + Sex + Arm:Sex. cox regression estimates coefficients along variance-covariance matrix : b1 (arm b), b2 (arm c) b3 (sex m) b4 (arm b: sex m), b5 (arm c: sex m) estimation Hazard Ratio arm C/sex M given reference arm /Sex M exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5). interaction coefficient deduced b2 + b5 standard error obtained $sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cox regression helper function for interactions — cox_regression_inter","text":"h_coxreg_inter_effect(): S3 generic helper function determine interaction effect. h_coxreg_inter_effect(numeric): Method numeric class. Estimates interaction numeric covariate. h_coxreg_inter_effect(factor): Method factor class. Estimate interaction factor covariate. h_coxreg_inter_effect(character): Method character class. Estimate interaction character covariate. makes automatic conversion factor forwards method factors. h_coxreg_extract_interaction(): higher level function get results interaction test estimated values. h_coxreg_inter_estimations(): Hazard ratio estimation interactions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Cox regression helper function for interactions — cox_regression_inter","text":"Automatic conversion character factor guarantee results can generated correctly. therefore better always pre-process dataset factors manually created character variables passing dataset rtables::build_table().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cox_regression_inter.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cox regression helper function for interactions — cox_regression_inter","text":"","code":"library(survival) set.seed(1, kind = \"Mersenne-Twister\") # Testing dataset [survival::bladder]. dta_bladder <- with( data = bladder[bladder$enum < 5, ], data.frame( time = stop, status = event, armcd = as.factor(rx), covar1 = as.factor(enum), covar2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) ) ) labels <- c(\"armcd\" = \"ARM\", \"covar1\" = \"A Covariate Label\", \"covar2\" = \"Sex (F/M)\") formatters::var_labels(dta_bladder)[names(labels)] <- labels dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) plot( survfit(Surv(time, status) ~ armcd + covar1, data = dta_bladder), lty = 2:4, xlab = \"Months\", col = c(\"blue1\", \"blue2\", \"blue3\", \"blue4\", \"red1\", \"red2\", \"red3\", \"red4\") ) mod <- coxph(Surv(time, status) ~ armcd * covar1, data = dta_bladder) h_coxreg_extract_interaction( mod = mod, effect = \"armcd\", covar = \"covar1\", data = dta_bladder, control = control_coxreg() ) #> effect term term_label level n hr #> 1 Covariate: covar1 A Covariate Label 340 NA #> armcd2/covar11 Covariate: covar1 1 1 NA 0.6341111 #> armcd2/covar12 Covariate: covar1 2 2 NA 0.5845305 #> armcd2/covar13 Covariate: covar1 3 3 NA 0.5507703 #> armcd2/covar14 Covariate: covar1 4 4 NA 0.6910643 #> lcl ucl pval pval_inter #> 1 NA NA 0.1302825 0.988245 #> armcd2/covar11 0.3514676 1.144051 NA NA #> armcd2/covar12 0.2716689 1.257692 NA NA #> armcd2/covar13 0.2244668 1.351415 NA NA #> armcd2/covar14 0.2315248 2.062715 NA NA mod <- coxph(Surv(time, status) ~ armcd * covar1, data = dta_bladder) result <- h_coxreg_inter_estimations( variable = \"armcd\", given = \"covar1\", lvl_var = levels(dta_bladder$armcd), lvl_given = levels(dta_bladder$covar1), mod = mod, conf_level = .95 ) result #> $armcd2 #> coef se(coef) hr lcl ucl #> armcd2/covar11 -0.4555312 0.3010803 0.6341111 0.3514676 1.144051 #> armcd2/covar12 -0.5369464 0.3909383 0.5845305 0.2716689 1.257692 #> armcd2/covar13 -0.5964375 0.4579624 0.5507703 0.2244668 1.351415 #> armcd2/covar14 -0.3695225 0.5579418 0.6910643 0.2315248 2.062715 #> #> attr(,\"details\") #> [1] \"Estimations of armcd hazard ratio given the level of covar1 compared to armcd level 1.\""},{"path":"https://insightsengineering.github.io/tern/main/reference/cut_quantile_bins.html","id":null,"dir":"Reference","previous_headings":"","what":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"cuts numeric vector sample quantile bins.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cut_quantile_bins.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"","code":"cut_quantile_bins( x, probs = c(0.25, 0.5, 0.75), labels = NULL, type = 7, ordered = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/cut_quantile_bins.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"x (numeric) continuous variable values cut quantile bins. may contain NA values, used quantile calculations, included return vector. probs (numeric) probabilities identifying quantiles. sorted vector unique proportion values, .e. 0 1, boundaries 0 1 must included. labels (character) unique labels quantile bins. n probabilities probs, must n + 1 long. type (integer(1)) type quantiles use, see stats::quantile() details. ordered (flag) result ordered factor.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cut_quantile_bins.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"factor variable appropriately-labeled bins levels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cut_quantile_bins.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"Intervals closed right side. , first bin interval [-Inf, q1] q1 first quantile, second bin (q1, q2], etc., last bin (qn, +Inf] qn last quantile.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/cut_quantile_bins.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cut numeric vector into empirical quantile bins — cut_quantile_bins","text":"","code":"# Default is to cut into quartile bins. cut_quantile_bins(cars$speed) #> [1] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] #> [7] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] #> [13] [0%,25%] [0%,25%] [0%,25%] (25%,50%] (25%,50%] (25%,50%] #> [19] (25%,50%] (25%,50%] (25%,50%] (25%,50%] (25%,50%] (25%,50%] #> [25] (25%,50%] (25%,50%] (50%,75%] (50%,75%] (50%,75%] (50%,75%] #> [31] (50%,75%] (50%,75%] (50%,75%] (50%,75%] (50%,75%] (50%,75%] #> [37] (50%,75%] (50%,75%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [43] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [49] (75%,100%] (75%,100%] #> Levels: [0%,25%] < (25%,50%] < (50%,75%] < (75%,100%] # Use custom quantiles. cut_quantile_bins(cars$speed, probs = c(0.1, 0.2, 0.6, 0.88)) #> [1] [0%,10%] [0%,10%] [0%,10%] [0%,10%] [0%,10%] (10%,20%] #> [7] (10%,20%] (10%,20%] (10%,20%] (10%,20%] (10%,20%] (20%,60%] #> [13] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] #> [19] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] #> [25] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] (20%,60%] #> [31] (20%,60%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] #> [37] (60%,88%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] (60%,88%] #> [43] (60%,88%] (60%,88%] (88%,100%] (88%,100%] (88%,100%] (88%,100%] #> [49] (88%,100%] (88%,100%] #> Levels: [0%,10%] < (10%,20%] < (20%,60%] < (60%,88%] < (88%,100%] # Use custom labels. cut_quantile_bins(cars$speed, labels = paste0(\"Q\", 1:4)) #> [1] Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q1 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 #> [26] Q2 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 Q4 #> Levels: Q1 < Q2 < Q3 < Q4 # NAs are preserved in result factor. ozone_binned <- cut_quantile_bins(airquality$Ozone) which(is.na(ozone_binned)) #> [1] 5 10 25 26 27 32 33 34 35 36 37 39 42 43 45 46 52 53 54 #> [20] 55 56 57 58 59 60 61 65 72 75 83 84 102 103 107 115 119 150 # So you might want to make these explicit. explicit_na(ozone_binned) #> [1] (50%,75%] (50%,75%] [0%,25%] [0%,25%] (25%,50%] #> [7] (25%,50%] (25%,50%] [0%,25%] [0%,25%] [0%,25%] #> [13] [0%,25%] [0%,25%] [0%,25%] [0%,25%] (50%,75%] [0%,25%] #> [19] (25%,50%] [0%,25%] [0%,25%] [0%,25%] [0%,25%] (50%,75%] #> [25] (25%,50%] (50%,75%] (75%,100%] #> [31] (50%,75%] #> [37] (25%,50%] (75%,100%] (50%,75%] #> [43] (25%,50%] (25%,50%] (50%,75%] #> [49] (25%,50%] [0%,25%] [0%,25%] #> [55] #> [61] (75%,100%] (50%,75%] (50%,75%] (75%,100%] #> [67] (50%,75%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [73] [0%,25%] (25%,50%] [0%,25%] (50%,75%] (50%,75%] #> [79] (50%,75%] (75%,100%] (50%,75%] [0%,25%] #> [85] (75%,100%] (75%,100%] (25%,50%] (50%,75%] (75%,100%] (50%,75%] #> [91] (75%,100%] (50%,75%] (50%,75%] [0%,25%] [0%,25%] (75%,100%] #> [97] (50%,75%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [103] (50%,75%] (25%,50%] (75%,100%] (25%,50%] #> [109] (50%,75%] (25%,50%] (25%,50%] (50%,75%] (25%,50%] [0%,25%] #> [115] (50%,75%] (75%,100%] (75%,100%] (75%,100%] #> [121] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] (75%,100%] #> [127] (75%,100%] (50%,75%] (50%,75%] (25%,50%] (25%,50%] (25%,50%] #> [133] (25%,50%] (50%,75%] (25%,50%] (25%,50%] [0%,25%] [0%,25%] #> [139] (50%,75%] [0%,25%] [0%,25%] (25%,50%] [0%,25%] [0%,25%] #> [145] (25%,50%] (50%,75%] [0%,25%] [0%,25%] (25%,50%] #> [151] [0%,25%] [0%,25%] (25%,50%] #> Levels: [0%,25%] < (25%,50%] < (50%,75%] < (75%,100%] < "},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_abnormal_by_baseline.html","id":null,"dir":"Reference","previous_headings":"","what":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"Description function produces labels s_count_abnormal_by_baseline().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_abnormal_by_baseline.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"","code":"d_count_abnormal_by_baseline(abnormal)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_abnormal_by_baseline.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"abnormal (character) values identifying abnormal range level(s) .var.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_abnormal_by_baseline.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"Abnormal category labels s_count_abnormal_by_baseline().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_abnormal_by_baseline.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Description function for s_count_abnormal_by_baseline() — d_count_abnormal_by_baseline","text":"","code":"d_count_abnormal_by_baseline(\"LOW\") #> $not_abnormal #> [1] \"Not low\" #> #> $abnormal #> [1] \"Low\" #> #> $total #> [1] \"Total\" #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_cumulative.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of cumulative count — d_count_cumulative","title":"Description of cumulative count — d_count_cumulative","text":"helper function describes analysis s_count_cumulative().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_cumulative.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of cumulative count — d_count_cumulative","text":"","code":"d_count_cumulative(threshold, lower_tail = TRUE, include_eq = TRUE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_cumulative.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of cumulative count — d_count_cumulative","text":"threshold (numeric(1)) cutoff value threshold count values x. lower_tail (flag) whether count lower tail, default TRUE. include_eq (flag) whether include value equal threshold count, default TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_cumulative.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of cumulative count — d_count_cumulative","text":"Labels s_count_cumulative().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_missed_doses.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses","text":"","code":"d_count_missed_doses(thresholds)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_missed_doses.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses","text":"thresholds (numeric) minimum number missed doses patients .","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_count_missed_doses.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description function that calculates labels for s_count_missed_doses() — d_count_missed_doses","text":"d_count_missed_doses() returns named character vector labels.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/d_onco_rsp_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of standard oncology response — d_onco_rsp_label","title":"Description of standard oncology response — d_onco_rsp_label","text":"Describe oncology response standard way.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_onco_rsp_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of standard oncology response — d_onco_rsp_label","text":"","code":"d_onco_rsp_label(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_onco_rsp_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of standard oncology response — d_onco_rsp_label","text":"x (character) standard oncology codes described.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_onco_rsp_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of standard oncology response — d_onco_rsp_label","text":"Response labels.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/d_onco_rsp_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Description of standard oncology response — d_onco_rsp_label","text":"","code":"d_onco_rsp_label( c(\"CR\", \"PR\", \"SD\", \"NON CR/PD\", \"PD\", \"NE\", \"Missing\", \"\", \"NE/Missing\") ) #> CR PR #> Complete Response (CR) Partial Response (PR) #> SD NON CR/PD #> Stable Disease (SD) Non-CR or Non-PD (NON CR/PD) #> PD NE #> Progressive Disease (PD) Not Evaluable (NE) #> Missing #> Missing #> NE/Missing #> Missing or unevaluable #> 9 Levels: Complete Response (CR) Partial Response (PR) ... # Adding some values not considered in d_onco_rsp_label d_onco_rsp_label( c(\"CR\", \"PR\", \"hello\", \"hi\") ) #> CR PR hello #> Complete Response (CR) Partial Response (PR) hello #> hi #> hi #> Levels: Complete Response (CR) Partial Response (PR) hello hi"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/d_pkparam.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate PK reference dataset — d_pkparam","text":"","code":"d_pkparam()"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_pkparam.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate PK reference dataset — d_pkparam","text":"data.frame PK parameters.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_pkparam.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate PK reference dataset — d_pkparam","text":"","code":"pk_reference_dataset <- d_pkparam()"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of the proportion summary — d_proportion","title":"Description of the proportion summary — d_proportion","text":"helper function describes analysis s_proportion().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of the proportion summary — d_proportion","text":"","code":"d_proportion(conf_level, method, long = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of the proportion summary — d_proportion","text":"conf_level (proportion) confidence level interval. method (string) method used construct confidence interval proportion successful outcomes; one waldcc, wald, clopper-pearson, wilson, wilsonc, strat_wilson, strat_wilsonc, agresti-coull jeffreys. long (flag) whether long short (default) description required.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of the proportion summary — d_proportion","text":"String describing analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of method used for proportion comparison — d_proportion_diff","title":"Description of method used for proportion comparison — d_proportion_diff","text":"auxiliary function describes analysis s_proportion_diff().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of method used for proportion comparison — d_proportion_diff","text":"","code":"d_proportion_diff(conf_level, method, long = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of method used for proportion comparison — d_proportion_diff","text":"conf_level (proportion) confidence level interval. method (string) method used confidence interval estimation. long (flag) whether long (TRUE) short (FALSE, default) description required.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_proportion_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of method used for proportion comparison — d_proportion_diff","text":"string describing analysis.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/d_rsp_subgroups_colvars.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"Internal function check variables included tabulate_rsp_subgroups() create column labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_rsp_subgroups_colvars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"","code":"d_rsp_subgroups_colvars(vars, conf_level = NULL, method = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_rsp_subgroups_colvars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"vars (character) variable names primary analysis variable iterated . conf_level (proportion) confidence level interval. method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_rsp_subgroups_colvars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for column variables in binary response by subgroup table — d_rsp_subgroups_colvars","text":"list variables tabulate labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_survival_subgroups_colvars.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"Internal function check variables included tabulate_survival_subgroups() create column labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_survival_subgroups_colvars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"","code":"d_survival_subgroups_colvars(vars, conf_level, method, time_unit = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_survival_subgroups_colvars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"vars (character) names statistics reported among: n_tot_events: Total number events per group. n_events: Number events per group. n_tot: Total number observations per group. n: Number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. conf_level (proportion) confidence level interval. method (string) p-value method testing hazard ratio = 1. time_unit (string) label unit median survival time. Default NULL skips displaying unit.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_survival_subgroups_colvars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"list variables labels tabulate.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_survival_subgroups_colvars.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Labels for column variables in survival duration by subgroup table — d_survival_subgroups_colvars","text":"least one n_tot n_tot_events must provided vars.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_test_proportion_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Description of the difference test between two proportions — d_test_proportion_diff","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"auxiliary function describes analysis s_test_proportion_diff.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_test_proportion_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"","code":"d_test_proportion_diff(method)"},{"path":"https://insightsengineering.github.io/tern/main/reference/d_test_proportion_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"method (string) one chisq, cmh, fisher, schouten; specifies test used calculate p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/d_test_proportion_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Description of the difference test between two proportions — d_test_proportion_diff","text":"string describing test p-value derived.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/day2month.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion of days to months — day2month","title":"Conversion of days to months — day2month","text":"Conversion days months","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/day2month.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion of days to months — day2month","text":"","code":"day2month(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/day2month.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conversion of days to months — day2month","text":"x (numeric(1)) time days.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/day2month.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conversion of days to months — day2month","text":"numeric vector time months.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/day2month.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conversion of days to months — day2month","text":"","code":"x <- c(403, 248, 30, 86) day2month(x) #> [1] 13.2402464 8.1478439 0.9856263 2.8254620"},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"function useful label grid grobs (also ggplot2, lattice plots) title, footnote, page numbers.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"","code":"decorate_grob( grob, titles, footnotes, page = \"\", width_titles = grid::unit(1, \"npc\"), width_footnotes = grid::unit(1, \"npc\"), border = TRUE, padding = grid::unit(rep(1, 4), \"lines\"), margins = grid::unit(c(1, 0, 1, 0), \"lines\"), outer_margins = grid::unit(c(2, 1.5, 3, 1.5), \"cm\"), gp_titles = grid::gpar(), gp_footnotes = grid::gpar(fontsize = 8), name = NULL, gp = grid::gpar(), vp = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"grob (grob) grid grob object, optionally NULL grob decoration shown. titles (character) titles given vector strings separated newline wrapped according page width. footnotes (character) footnotes. Uses formatting rules titles. page (string NULL) page numeration. NULL page number displayed. width_titles (grid::unit) width titles. Usually defined available space grid::unit(1, \"npc\"), affected parameter outer_margins. Right margins (outer_margins[4]) need subtracted allowed width. width_footnotes (grid::unit) width footnotes. default margin correction width_titles. border (flag) whether border drawn around plot . padding (grid::unit) padding. unit object length 4. Innermost margin plot (grob) , possibly, border plot. Usually expressed 4 identical values (usually \"lines\"). defaults grid::unit(rep(1, 4), \"lines\"). margins (grid::unit) margins. unit object length 4. Margins plot elements list (e.g. titles, plot, footers). usually expressed 4 \"lines\", lateral ones 0s, top bottom 1s. defaults grid::unit(c(1, 0, 1, 0), \"lines\"). outer_margins (grid::unit) outer margins. unit object length 4. defines general margin plot, considering also decorations like titles, footnotes, page numbers. defaults grid::unit(c(2, 1.5, 3, 1.5), \"cm\"). gp_titles (gpar) gpar object. Mainly used set different \"fontsize\". gp_footnotes (gpar) gpar object. Mainly used set different \"fontsize\". name character identifier grob. Used find grob display list /child another grob. gp \"gpar\" object, typically output call function gpar. basically list graphical parameter settings. vp viewport object (NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"grid grob (gTree).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"titles footnotes ragged, .e. title wrapped individually.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add titles, footnotes, page Number, and a bounding box to a grid grob — decorate_grob","text":"","code":"library(grid) titles <- c( \"Edgar Anderson's Iris Data\", paste( \"This famous (Fisher's or Anderson's) iris data set gives the measurements\", \"in centimeters of the variables sepal length and width and petal length\", \"and width, respectively, for 50 flowers from each of 3 species of iris.\" ) ) footnotes <- c( \"The species are Iris setosa, versicolor, and virginica.\", paste( \"iris is a data frame with 150 cases (rows) and 5 variables (columns) named\", \"Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, and Species.\" ) ) ## empty plot grid.newpage() grid.draw( decorate_grob( NULL, titles = titles, footnotes = footnotes, page = \"Page 4 of 10\" ) ) # grid p <- gTree( children = gList( rectGrob(), xaxisGrob(), yaxisGrob(), textGrob(\"Sepal.Length\", y = unit(-4, \"lines\")), textGrob(\"Petal.Length\", x = unit(-3.5, \"lines\"), rot = 90), pointsGrob(iris$Sepal.Length, iris$Petal.Length, gp = gpar(col = iris$Species), pch = 16) ), vp = vpStack(plotViewport(), dataViewport(xData = iris$Sepal.Length, yData = iris$Petal.Length)) ) grid.newpage() grid.draw(p) grid.newpage() grid.draw( decorate_grob( grob = p, titles = titles, footnotes = footnotes, page = \"Page 6 of 129\" ) ) ## with ggplot2 library(ggplot2) p_gg <- ggplot2::ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) + ggplot2::geom_point() p_gg p <- ggplotGrob(p_gg) grid.newpage() grid.draw( decorate_grob( grob = p, titles = titles, footnotes = footnotes, page = \"Page 6 of 129\" ) ) ## with lattice library(lattice) xyplot(Sepal.Length ~ Petal.Length, data = iris, col = iris$Species) p <- grid.grab() grid.newpage() grid.draw( decorate_grob( grob = p, titles = titles, footnotes = footnotes, page = \"Page 6 of 129\" ) ) # with gridExtra - no borders library(gridExtra) #> #> Attaching package: ‘gridExtra’ #> The following object is masked from ‘package:dplyr’: #> #> combine grid.newpage() grid.draw( decorate_grob( tableGrob( head(mtcars) ), titles = \"title\", footnotes = \"footnote\", border = FALSE ) )"},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_factory.html","id":null,"dir":"Reference","previous_headings":"","what":"Update page number — decorate_grob_factory","title":"Update page number — decorate_grob_factory","text":"Automatically updates page number.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_factory.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update page number — decorate_grob_factory","text":"","code":"decorate_grob_factory(npages, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_factory.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update page number — decorate_grob_factory","text":"npages (numeric(1)) total number pages. ... arguments passed decorate_grob().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_factory.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update page number — decorate_grob_factory","text":"Closure increments page number.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Decorate set of grobs and add page numbering — decorate_grob_set","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"Note uses decorate_grob_factory() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"","code":"decorate_grob_set(grobs, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"grobs (list grob) list grid grobs. ... arguments passed decorate_grob().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"decorated grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/decorate_grob_set.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decorate set of grobs and add page numbering — decorate_grob_set","text":"","code":"library(ggplot2) library(grid) g <- with(data = iris, { list( ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Length, Sepal.Width, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Length, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Width, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Length, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Width, col = Species)) + ggplot2::geom_point() ), ggplot2::ggplotGrob( ggplot2::ggplot(mapping = aes(Petal.Length, Petal.Width, col = Species)) + ggplot2::geom_point() ) ) }) lg <- decorate_grob_set(grobs = g, titles = \"Hello\\nOne\\nTwo\\nThree\", footnotes = \"\") draw_grob(lg[[1]]) #> Warning: `draw_grob()` was deprecated in tern 0.9.4. #> ℹ `tern` plotting functions no longer generate `grob` objects. draw_grob(lg[[2]]) draw_grob(lg[[6]])"},{"path":"https://insightsengineering.github.io/tern/main/reference/default_na_str.html","id":null,"dir":"Reference","previous_headings":"","what":"Default string replacement for NA values — default_na_str","title":"Default string replacement for NA values — default_na_str","text":"default string used represent NA values. value used default value na_str argument throughout tern package, printed place NA values output tables. specified tern function user via na_str argument, R environment options via set_default_na_str(), NA used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_na_str.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Default string replacement for NA values — default_na_str","text":"","code":"default_na_str() set_default_na_str(na_str)"},{"path":"https://insightsengineering.github.io/tern/main/reference/default_na_str.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Default string replacement for NA values — default_na_str","text":"na_str (string) single string value set R environment options default value replace NAs. Use getOption(\"tern_default_na_str\") check current value set R environment (defaults NULL set).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_na_str.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Default string replacement for NA values — default_na_str","text":"default_na_str returns current value R environment option set \"tern_default_na_str\", NA_character_ otherwise. set_default_na_str return value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_na_str.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Default string replacement for NA values — default_na_str","text":"default_na_str(): Accessor default NA value replacement string. set_default_na_str(): Setter default NA value replacement string. Sets option \"tern_default_na_str\" within R environment.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_na_str.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Default string replacement for NA values — default_na_str","text":"","code":"# Default settings default_na_str() #> [1] NA getOption(\"tern_default_na_str\") #> NULL # Set custom value set_default_na_str(\"\") # Settings after value has been set default_na_str() #> [1] \"\" getOption(\"tern_default_na_str\") #> [1] \"\""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"Utility functions get valid statistic methods different method groups (.stats) associated formats (.formats), labels (.labels), indent modifiers (.indent_mods). utility used across tern, working principles can seen analyze_vars(). See notes understand experimental.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"","code":"get_stats( method_groups = \"analyze_vars_numeric\", stats_in = NULL, add_pval = FALSE ) get_formats_from_stats(stats, formats_in = NULL) get_labels_from_stats(stats, labels_in = NULL, row_nms = NULL) get_indents_from_stats(stats, indents_in = NULL, row_nms = NULL) tern_default_stats tern_default_formats tern_default_labels summary_formats(type = \"numeric\", include_pval = FALSE) summary_labels(type = \"numeric\", include_pval = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"tern_default_stats named list available statistics, element named corresponding statistical method group. tern_default_formats named vector available default formats, element named corresponding statistic. tern_default_labels named character vector available default labels, element named corresponding statistic.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"method_groups (character) indicates statistical method group (tern analyze function) retrieve default statistics . character vector can used specify one statistical method group. stats_in (character) statistics retrieve selected method group. add_pval (flag) \"pval\" (\"pval_counts\" method_groups contains \"analyze_vars_counts\") added statistical methods? stats (character) statistical methods get defaults . formats_in (named vector) inserted formats replace defaults. can character vector formatters::list_valid_format_labels() custom format function. labels_in (named character) inserted labels replace defaults. row_nms (character) row names. Levels factor character variable, statistics .stats calculated . parameter set, variable levels used defaults, names given custom values correspond levels (format statistic.level) instead statistics. Can also variable names rows correspond different variables instead levels. Defaults NULL. indents_in (named vector) inserted indent modifiers replace defaults (default 0L). type (string)\"numeric\" \"counts\". include_pval (flag) add_pval argument get_stats().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"get_stats() returns character vector statistical methods. get_formats_from_stats() returns named vector formats (present either tern_default_formats formats_in, otherwise NULL). Values can taken formatters::list_valid_format_labels() custom function (e.g. formatting_functions). get_labels_from_stats() returns named character vector labels (present either tern_default_labels labels_in, otherwise NULL). get_indents_from_stats() returns single indent modifier value apply rows named numeric vector indent modifiers (present, otherwise NULL). summary_formats() returns named vector default statistic formats given data type. summary_labels returns named vector default statistic labels given data type.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"Current choices type counts numeric analyze_vars() affect get_stats(). summary_* quick get functions labels formats uses get_stats get_labels_from_stats get_formats_from_stats respectively retrieve relevant information.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"get_stats(): Get statistics available given method group (analyze function). check available defaults see tern::tern_default_stats list. get_formats_from_stats(): Get formats corresponding list statistics. check available defaults see tern::tern_default_formats list. get_labels_from_stats(): Get labels corresponding list statistics. check available defaults see tern::tern_default_labels list. available , statistics name used label. get_indents_from_stats(): Format indent modifiers given vector/list statistics. defaults 0L values. tern_default_stats: Named list available statistics method group tern. tern_default_formats: Named vector default formats tern. tern_default_labels: Named character vector default labels tern. summary_formats(): Quick function retrieve default formats summary statistics: analyze_vars() analyze_vars_in_cols() principally. summary_labels(): Quick function retrieve default labels summary statistics. Returns labels descriptive statistics understood rtables. Similar summary_formats.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"defaults experimental use names functions retrieve default statistics. generalized groups methods according reasonable groupings. Formats tern rtables can functions take table cell value return string. well documented vignette(\"custom_appearance\", package = \"rtables\").","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/default_stats_formats_labels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get default statistical methods and their associated formats, labels, and indent modifiers — default_stats_formats_labels","text":"","code":"# analyze_vars is numeric num_stats <- get_stats(\"analyze_vars_numeric\") # also the default # Other type cnt_stats <- get_stats(\"analyze_vars_counts\") # Weirdly taking the pval from count_occurrences only_pval <- get_stats(\"count_occurrences\", add_pval = TRUE, stats_in = \"pval\") # All count_occurrences all_cnt_occ <- get_stats(\"count_occurrences\") # Multiple get_stats(c(\"count_occurrences\", \"analyze_vars_counts\")) #> [1] \"count\" \"count_fraction\" #> [3] \"count_fraction_fixed_dp\" \"fraction\" #> [5] \"n\" \"n_blq\" # Defaults formats get_formats_from_stats(num_stats) #> $n #> [1] \"xx.\" #> #> $sum #> [1] \"xx.x\" #> #> $mean #> [1] \"xx.x\" #> #> $sd #> [1] \"xx.x\" #> #> $se #> [1] \"xx.x\" #> #> $mean_sd #> [1] \"xx.x (xx.x)\" #> #> $mean_se #> [1] \"xx.x (xx.x)\" #> #> $mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sei #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sdi #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_pval #> [1] \"x.xxxx | (<0.0001)\" #> #> $median #> [1] \"xx.x\" #> #> $mad #> [1] \"xx.x\" #> #> $median_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $quantiles #> [1] \"xx.x - xx.x\" #> #> $iqr #> [1] \"xx.x\" #> #> $range #> [1] \"xx.x - xx.x\" #> #> $min #> [1] \"xx.x\" #> #> $max #> [1] \"xx.x\" #> #> $median_range #> [1] \"xx.x (xx.x - xx.x)\" #> #> $cv #> [1] \"xx.x\" #> #> $geom_mean #> [1] \"xx.x\" #> #> $geom_mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $geom_cv #> [1] \"xx.x\" #> #> $median_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $geom_mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> get_formats_from_stats(cnt_stats) #> $n #> [1] \"xx.\" #> #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> checkmate::assert_vector(x) #> checkmate::assert_count(x[\"num\"]) #> checkmate::assert_count(x[\"denom\"]) #> #> result <- if (x[\"num\"] == 0) { #> paste0(x[\"num\"], \"/\", x[\"denom\"]) #> } else { #> paste0( #> x[\"num\"], \"/\", x[\"denom\"], #> \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" #> ) #> } #> return(result) #> } #> #> #> $n_blq #> [1] \"xx.\" #> get_formats_from_stats(only_pval) #> $pval #> [1] \"x.xxxx | (<0.0001)\" #> get_formats_from_stats(all_cnt_occ) #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> checkmate::assert_vector(x) #> checkmate::assert_count(x[\"num\"]) #> checkmate::assert_count(x[\"denom\"]) #> #> result <- if (x[\"num\"] == 0) { #> paste0(x[\"num\"], \"/\", x[\"denom\"]) #> } else { #> paste0( #> x[\"num\"], \"/\", x[\"denom\"], #> \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" #> ) #> } #> return(result) #> } #> #> # Addition of customs get_formats_from_stats(all_cnt_occ, formats_in = c(\"fraction\" = c(\"xx\"))) #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> [1] \"xx\" #> get_formats_from_stats(all_cnt_occ, formats_in = list(\"fraction\" = c(\"xx.xx\", \"xx\"))) #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> [1] \"xx.xx\" \"xx\" #> # Defaults labels get_labels_from_stats(num_stats) #> n sum #> \"n\" \"Sum\" #> mean sd #> \"Mean\" \"SD\" #> se mean_sd #> \"SE\" \"Mean (SD)\" #> mean_se mean_ci #> \"Mean (SE)\" \"Mean 95% CI\" #> mean_sei mean_sdi #> \"Mean -/+ 1xSE\" \"Mean -/+ 1xSD\" #> mean_pval median #> \"Mean p-value (H0: mean = 0)\" \"Median\" #> mad median_ci #> \"Median Absolute Deviation\" \"Median 95% CI\" #> quantiles iqr #> \"25% and 75%-ile\" \"IQR\" #> range min #> \"Min - Max\" \"Minimum\" #> max median_range #> \"Maximum\" \"Median (Min - Max)\" #> cv geom_mean #> \"CV (%)\" \"Geometric Mean\" #> geom_mean_ci geom_cv #> \"Geometric Mean 95% CI\" \"CV % Geometric Mean\" #> median_ci_3d mean_ci_3d #> \"Median (95% CI)\" \"Mean (95% CI)\" #> geom_mean_ci_3d #> \"Geometric Mean (95% CI)\" get_labels_from_stats(cnt_stats) #> n count count_fraction #> \"n\" \"count\" \"count_fraction\" #> count_fraction_fixed_dp fraction n_blq #> \"count_fraction\" \"fraction\" \"n_blq\" get_labels_from_stats(only_pval) #> pval #> \"p-value (t-test)\" get_labels_from_stats(all_cnt_occ) #> count count_fraction count_fraction_fixed_dp #> \"count\" \"count_fraction\" \"count_fraction\" #> fraction #> \"fraction\" # Addition of customs get_labels_from_stats(all_cnt_occ, labels_in = c(\"fraction\" = \"Fraction\")) #> count count_fraction count_fraction_fixed_dp #> \"count\" \"count_fraction\" \"count_fraction\" #> fraction #> \"Fraction\" get_labels_from_stats(all_cnt_occ, labels_in = list(\"fraction\" = c(\"Some more fractions\"))) #> $count #> [1] \"count\" #> #> $count_fraction #> [1] \"count_fraction\" #> #> $count_fraction_fixed_dp #> [1] \"count_fraction\" #> #> $fraction #> [1] \"Some more fractions\" #> get_indents_from_stats(all_cnt_occ, indents_in = 3L) #> [1] 3 3 3 3 get_indents_from_stats(all_cnt_occ, indents_in = list(count = 2L, count_fraction = 5L)) #> $count #> [1] 2 #> #> $count_fraction #> [1] 5 #> #> $count_fraction_fixed_dp #> [1] 0 #> #> $fraction #> [1] 0 #> get_indents_from_stats( all_cnt_occ, indents_in = list(a = 2L, count.a = 1L, count.b = 5L), row_nms = c(\"a\", \"b\") ) #> $count.a #> [1] 1 #> #> $count.b #> [1] 5 #> #> $count_fraction.a #> [1] 2 #> #> $count_fraction.b #> [1] 0 #> #> $count_fraction_fixed_dp.a #> [1] 2 #> #> $count_fraction_fixed_dp.b #> [1] 0 #> #> $fraction.a #> [1] 2 #> #> $fraction.b #> [1] 0 #> summary_formats() #> $n #> [1] \"xx.\" #> #> $sum #> [1] \"xx.x\" #> #> $mean #> [1] \"xx.x\" #> #> $sd #> [1] \"xx.x\" #> #> $se #> [1] \"xx.x\" #> #> $mean_sd #> [1] \"xx.x (xx.x)\" #> #> $mean_se #> [1] \"xx.x (xx.x)\" #> #> $mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sei #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_sdi #> [1] \"(xx.xx, xx.xx)\" #> #> $mean_pval #> [1] \"x.xxxx | (<0.0001)\" #> #> $median #> [1] \"xx.x\" #> #> $mad #> [1] \"xx.x\" #> #> $median_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $quantiles #> [1] \"xx.x - xx.x\" #> #> $iqr #> [1] \"xx.x\" #> #> $range #> [1] \"xx.x - xx.x\" #> #> $min #> [1] \"xx.x\" #> #> $max #> [1] \"xx.x\" #> #> $median_range #> [1] \"xx.x (xx.x - xx.x)\" #> #> $cv #> [1] \"xx.x\" #> #> $geom_mean #> [1] \"xx.x\" #> #> $geom_mean_ci #> [1] \"(xx.xx, xx.xx)\" #> #> $geom_cv #> [1] \"xx.x\" #> #> $median_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> #> $geom_mean_ci_3d #> [1] \"xx.xx (xx.xx - xx.xx)\" #> summary_formats(type = \"counts\", include_pval = TRUE) #> $n #> [1] \"xx.\" #> #> $count #> [1] \"xx.\" #> #> $count_fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else { #> paste0(x[1], \" (\", round(x[2] * 100, 1), \"%)\") #> } #> #> return(result) #> } #> #> #> $count_fraction_fixed_dp #> function(x, ...) { #> attr(x, \"label\") <- NULL #> #> if (any(is.na(x))) { #> return(\"NA\") #> } #> #> checkmate::assert_vector(x) #> checkmate::assert_integerish(x[1]) #> assert_proportion_value(x[2], include_boundaries = TRUE) #> #> result <- if (x[1] == 0) { #> \"0\" #> } else if (.is_equal_float(x[2], 1)) { #> sprintf(\"%d (100%%)\", x[1]) #> } else { #> sprintf(\"%d (%.1f%%)\", x[1], x[2] * 100) #> } #> #> return(result) #> } #> #> #> $fraction #> function(x, ...) { #> attr(x, \"label\") <- NULL #> checkmate::assert_vector(x) #> checkmate::assert_count(x[\"num\"]) #> checkmate::assert_count(x[\"denom\"]) #> #> result <- if (x[\"num\"] == 0) { #> paste0(x[\"num\"], \"/\", x[\"denom\"]) #> } else { #> paste0( #> x[\"num\"], \"/\", x[\"denom\"], #> \" (\", sprintf(\"%.1f\", round(x[\"num\"] / x[\"denom\"] * 100, 1)), \"%)\" #> ) #> } #> return(result) #> } #> #> #> $n_blq #> [1] \"xx.\" #> #> $pval_counts #> [1] \"x.xxxx | (<0.0001)\" #> summary_labels() #> n sum #> \"n\" \"Sum\" #> mean sd #> \"Mean\" \"SD\" #> se mean_sd #> \"SE\" \"Mean (SD)\" #> mean_se mean_ci #> \"Mean (SE)\" \"Mean 95% CI\" #> mean_sei mean_sdi #> \"Mean -/+ 1xSE\" \"Mean -/+ 1xSD\" #> mean_pval median #> \"Mean p-value (H0: mean = 0)\" \"Median\" #> mad median_ci #> \"Median Absolute Deviation\" \"Median 95% CI\" #> quantiles iqr #> \"25% and 75%-ile\" \"IQR\" #> range min #> \"Min - Max\" \"Minimum\" #> max median_range #> \"Maximum\" \"Median (Min - Max)\" #> cv geom_mean #> \"CV (%)\" \"Geometric Mean\" #> geom_mean_ci geom_cv #> \"Geometric Mean 95% CI\" \"CV % Geometric Mean\" #> median_ci_3d mean_ci_3d #> \"Median (95% CI)\" \"Mean (95% CI)\" #> geom_mean_ci_3d #> \"Geometric Mean (95% CI)\" summary_labels(type = \"counts\", include_pval = TRUE) #> n count #> \"n\" \"count\" #> count_fraction count_fraction_fixed_dp #> \"count_fraction\" \"count_fraction\" #> fraction n_blq #> \"fraction\" \"n_blq\" #> pval_counts #> \"p-value (chi-squared test)\""},{"path":"https://insightsengineering.github.io/tern/main/reference/desctools_binom.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence intervals for a difference of binomials — desctools_binom","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"Several confidence intervals difference proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/desctools_binom.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"","code":"desctools_binom( x1, n1, x2, n2, conf.level = 0.95, sides = c(\"two.sided\", \"left\", \"right\"), method = c(\"ac\", \"wald\", \"waldcc\", \"score\", \"scorecc\", \"mn\", \"mee\", \"blj\", \"ha\", \"hal\", \"jp\") ) desctools_binomci( x, n, conf.level = 0.95, sides = c(\"two.sided\", \"left\", \"right\"), method = c(\"wilson\", \"wald\", \"waldcc\", \"agresti-coull\", \"jeffreys\", \"modified wilson\", \"wilsoncc\", \"modified jeffreys\", \"clopper-pearson\", \"arcsine\", \"logit\", \"witting\", \"pratt\", \"midp\", \"lik\", \"blaker\"), rand = 123, tol = 1e-05 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/desctools_binom.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"conf.level (proportion) confidence level, defaults 0.95. sides (string) side confidence interval compute. Must one \"two-sided\" (default), \"left\", \"right\". method (string) method use. Can one : \"wald\", \"wilson\", \"wilsoncc\", \"agresti-coull\", \"jeffreys\", \"modified wilson\", \"modified jeffreys\", \"clopper-pearson\", \"arcsine\", \"logit\", \"witting\", \"pratt\", \"midp\", \"lik\", \"blaker\". x (integer(1)) number successes. n (integer(1)) number trials.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/desctools_binom.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"matrix 3 values: est: estimate proportion difference. lwr.ci: estimate lower end confidence interval. upr.ci: estimate upper end confidence interval. matrix 3 columns containing: est: estimate proportion difference. lwr.ci: lower end confidence interval. upr.ci: upper end confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/desctools_binom.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Confidence intervals for a difference of binomials — desctools_binom","text":"desctools_binom(): Several confidence intervals difference proportions. desctools_binomci(): Compute confidence intervals binomial proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df2gg.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert data.frame object to ggplot object — df2gg","title":"Convert data.frame object to ggplot object — df2gg","text":"Given data.frame object, performs basic conversion ggplot2::ggplot() object built using functions ggplot2 package.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df2gg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert data.frame object to ggplot object — df2gg","text":"","code":"df2gg( df, colwidths = NULL, font_size = 10, col_labels = TRUE, col_lab_fontface = \"bold\", hline = TRUE, bg_fill = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/df2gg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert data.frame object to ggplot object — df2gg","text":"df (data.frame) data frame. colwidths (numeric NULL) vector column widths. element's position colwidths corresponds column df position. NULL, column widths calculated according maximum number characters per column. font_size (numeric(1)) font size. col_labels (flag) whether column names (labels) df used first row output table. col_lab_fontface (string) font face apply first row (column labels col_labels = TRUE). Defaults \"bold\". hline (flag) whether horizontal line printed first row table. bg_fill (string) table background fill color.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df2gg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert data.frame object to ggplot object — df2gg","text":"ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df2gg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert data.frame object to ggplot object — df2gg","text":"","code":"if (FALSE) { # \\dontrun{ df2gg(head(iris, 5)) df2gg(head(iris, 5), font_size = 15, colwidths = c(1, 1, 1, 1, 1)) } # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/df_explicit_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Encode categorical missing values in a data frame — df_explicit_na","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"helper function encode missing entries across groups categorical variables data frame.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df_explicit_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"","code":"df_explicit_na( data, omit_columns = NULL, char_as_factor = TRUE, logical_as_factor = FALSE, na_level = \"\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/df_explicit_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"data (data.frame) data set. omit_columns (character) names variables data modified function. char_as_factor (flag) whether convert character variables data factors. logical_as_factor (flag) whether convert logical variables data factors. na_level (string) string used replace NA empty values inside non-omit_columns columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df_explicit_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"data.frame chosen modifications applied.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/df_explicit_na.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"Missing entries NA empty strings replaced specified value. factor variables include missing values, missing value inserted last level. Similarly, case character logical variables converted factors char_as_factor logical_as_factor options, missing values set last level.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/df_explicit_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Encode categorical missing values in a data frame — df_explicit_na","text":"","code":"my_data <- data.frame( u = c(TRUE, FALSE, NA, TRUE), v = factor(c(\"A\", NA, NA, NA), levels = c(\"Z\", \"A\")), w = c(\"A\", \"B\", NA, \"C\"), x = c(\"D\", \"E\", \"F\", NA), y = c(\"G\", \"H\", \"I\", \"\"), z = c(1, 2, 3, 4), stringsAsFactors = FALSE ) # Example 1 # Encode missing values in all character or factor columns. df_explicit_na(my_data) #> u v w x y z #> 1 TRUE A A D G 1 #> 2 FALSE B E H 2 #> 3 NA F I 3 #> 4 TRUE C 4 # Also convert logical columns to factor columns. df_explicit_na(my_data, logical_as_factor = TRUE) #> u v w x y z #> 1 TRUE A A D G 1 #> 2 FALSE B E H 2 #> 3 F I 3 #> 4 TRUE C 4 # Encode missing values in a subset of columns. df_explicit_na(my_data, omit_columns = c(\"x\", \"y\")) #> u v w x y z #> 1 TRUE A A D G 1 #> 2 FALSE B E H 2 #> 3 NA F I 3 #> 4 TRUE C 4 # Example 2 # Here we purposefully convert all `M` values to `NA` in the `SEX` variable. # After running `df_explicit_na` the `NA` values are encoded as `` but they are not # included when generating `rtables`. adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl) # If you want the `Na` values to be displayed in the table use the `na_level` argument. adsl <- tern_ex_adsl adsl$SEX[adsl$SEX == \"M\"] <- NA adsl <- df_explicit_na(adsl, na_level = \"Missing Values\") # Example 3 # Numeric variables that have missing values are not altered. This means that any `NA` value in # a numeric variable will not be included in the summary statistics, nor will they be included # in the denominator value for calculating the percent values. adsl <- tern_ex_adsl adsl$AGE[adsl$AGE < 30] <- NA adsl <- df_explicit_na(adsl)"},{"path":"https://insightsengineering.github.io/tern/main/reference/dot-is_equal_float.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to check if a float value is equal to another float value — .is_equal_float","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"Uses .Machine$double.eps tolerance comparison.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/dot-is_equal_float.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"","code":".is_equal_float(x, y)"},{"path":"https://insightsengineering.github.io/tern/main/reference/dot-is_equal_float.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"x (numeric(1)) float number. y (numeric(1)) float number.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/dot-is_equal_float.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to check if a float value is equal to another float value — .is_equal_float","text":"TRUE identical, otherwise FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/draw_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Draw grob — draw_grob","title":"Draw grob — draw_grob","text":"Draw grob device page.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/draw_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Draw grob — draw_grob","text":"","code":"draw_grob(grob, newpage = TRUE, vp = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/draw_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Draw grob — draw_grob","text":"grob (grob) grid object. newpage (flag) draw new page. vp (viewport NULL) viewport() object (NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/draw_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Draw grob — draw_grob","text":"grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/draw_grob.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Draw grob — draw_grob","text":"","code":"library(dplyr) library(grid) # \\donttest{ rect <- rectGrob(width = grid::unit(0.5, \"npc\"), height = grid::unit(0.5, \"npc\")) rect %>% draw_grob(vp = grid::viewport(angle = 45)) num <- lapply(1:10, textGrob) num %>% arrange_grobs(grobs = .) %>% draw_grob() #> Warning: `stack_grobs()` was deprecated in tern 0.9.4. #> ℹ `tern` plotting functions no longer generate `grob` objects. #> ℹ The deprecated feature was likely used in the tern package. #> Please report the issue at #> . showViewport() # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/empty_vector_if_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Return an empty numeric if all elements are NA. — empty_vector_if_na","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"Return empty numeric elements NA.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/empty_vector_if_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"","code":"empty_vector_if_na(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/empty_vector_if_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"x (numeric) vector.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/empty_vector_if_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"empty numeric elements x NA, otherwise x.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/empty_vector_if_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return an empty numeric if all elements are NA. — empty_vector_if_na","text":"","code":"x <- c(NA, NA, NA) # Internal function - empty_vector_if_na"},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_coef.html","id":null,"dir":"Reference","previous_headings":"","what":"Hazard ratio estimation in interactions — estimate_coef","title":"Hazard ratio estimation in interactions — estimate_coef","text":"function estimates hazard ratios arms interaction variable given specific values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_coef.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Hazard ratio estimation in interactions — estimate_coef","text":"","code":"estimate_coef( variable, given, lvl_var, lvl_given, coef, mmat, vcov, conf_level = 0.95 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_coef.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Hazard ratio estimation in interactions — estimate_coef","text":"variable, given (character(2)) names two variables interaction. seek estimation levels variable given levels given. lvl_var, lvl_given (character) corresponding levels given levels(). coef (numeric) vector estimated coefficients. mmat (named numeric) vector filled 0s used template obtain design matrix. vcov (matrix) variance-covariance matrix underlying model. conf_level (proportion) confidence level estimate intervals.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_coef.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Hazard ratio estimation in interactions — estimate_coef","text":"list matrices (one per level variable) rows corresponding combinations variable given, columns: coef_hat: Estimation coefficient. coef_se: Standard error estimation. hr: Hazard ratio. lcl, ucl: Lower/upper confidence limit hazard ratio.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_coef.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Hazard ratio estimation in interactions — estimate_coef","text":"Given cox regression investigating effect Arm (, B, C; reference ) Sex (F, M; reference Female). model abbreviated: y ~ Arm + Sex + Arm x Sex. cox regression estimates coefficients along variance-covariance matrix : b1 (arm b), b2 (arm c) b3 (sex m) b4 (arm b: sex m), b5 (arm c: sex m) Given want estimation Hazard Ratio arm C/sex M, estimation given reference arm /Sex M exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5), therefore interaction coefficient given b2 + b5 standard error obtained $1.96 * sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$ confidence level 0.95.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_coef.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Hazard ratio estimation in interactions — estimate_coef","text":"","code":"library(dplyr) library(survival) ADSL <- tern_ex_adsl %>% filter(SEX %in% c(\"F\", \"M\")) adtte <- tern_ex_adtte %>% filter(PARAMCD == \"PFS\") adtte$ARMCD <- droplevels(adtte$ARMCD) adtte$SEX <- droplevels(adtte$SEX) mod <- coxph( formula = Surv(time = AVAL, event = 1 - CNSR) ~ (SEX + ARMCD)^2, data = adtte ) mmat <- stats::model.matrix(mod)[1, ] mmat[!mmat == 0] <- 0"},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_multinomial_rsp.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"analyze & summarize function estimate_multinomial_response() creates layout element estimate proportion proportion confidence interval level factor variable. primary analysis variable, var, factor variable, values used labels within output table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_multinomial_rsp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"","code":"estimate_multinomial_response( lyt, var, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"hidden\", table_names = var, .stats = \"prop_ci\", .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_length_proportion(x, .N_col, ...) a_length_proportion(x, .N_col, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_multinomial_rsp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n_prop', 'prop_ci' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. x (numeric) vector numbers want analyze. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_multinomial_rsp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"estimate_multinomial_response() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_length_proportion() table layout. s_length_proportion() returns statistics s_proportion(). a_length_proportion() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_multinomial_rsp.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"estimate_multinomial_response(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze() rtables::summarize_row_groups(). s_length_proportion(): Statistics function feeds length x number successes, .N_col total number successes failures s_proportion(). a_length_proportion(): Formatted analysis function used afun estimate_multinomial_response().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_multinomial_rsp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate proportions of each level of a variable — estimate_multinomial_rsp","text":"","code":"library(dplyr) # Use of the layout creating function. dta_test <- data.frame( USUBJID = paste0(\"S\", 1:12), ARM = factor(rep(LETTERS[1:3], each = 4)), AVAL = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0)) ) %>% mutate( AVALC = factor(AVAL, levels = c(0, 1), labels = c(\"Complete Response (CR)\", \"Partial Response (PR)\") ) ) lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% estimate_multinomial_response(var = \"AVALC\") tbl <- build_table(lyt, dta_test) tbl #> A B C #> ————————————————————————————————————————————————————————————————————————————————————— #> Complete Response (CR) 0 (0.0%) 2 (50.0%) 4 (100.0%) #> 95% CI (Wald, with correction) (0.00, 12.50) (0.00, 100.00) (87.50, 100.00) #> Partial Response (PR) 4 (100.0%) 2 (50.0%) 0 (0.0%) #> 95% CI (Wald, with correction) (87.50, 100.00) (0.00, 100.00) (0.00, 12.50) s_length_proportion(rep(\"CR\", 10), .N_col = 100) #> $n_prop #> [1] 10.0 0.1 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> [1] 3.620108 16.379892 #> attr(,\"label\") #> [1] \"95% CI (Wald, with correction)\" #> s_length_proportion(factor(character(0)), .N_col = 100) #> $n_prop #> [1] 0 0 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> [1] 0.0 0.5 #> attr(,\"label\") #> [1] \"95% CI (Wald, with correction)\" #> a_length_proportion(rep(\"CR\", 10), .N_col = 100) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n_prop 10 (10.0%) 0 Responders #> 2 prop_ci (3.62, 16.38) 0 95% CI (Wald, with correction) a_length_proportion(factor(character(0)), .N_col = 100) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 n_prop 0 (0.0%) 0 Responders #> 2 prop_ci (0.00, 0.50) 0 95% CI (Wald, with correction)"},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_proportion.html","id":null,"dir":"Reference","previous_headings":"","what":"Proportion estimation — estimate_proportion","title":"Proportion estimation — estimate_proportion","text":"analyze function estimate_proportion() creates layout element estimate proportion responders within studied population. primary analysis variable, vars, indicates whether response occurred record. See method parameter options methods use constructing confidence interval proportion. Additionally, stratification variable can supplied via strata element variables argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_proportion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Proportion estimation — estimate_proportion","text":"","code":"estimate_proportion( lyt, vars, conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"clopper-pearson\", \"wilson\", \"wilsonc\", \"strat_wilson\", \"strat_wilsonc\", \"agresti-coull\", \"jeffreys\"), weights = NULL, max_iterations = 50, variables = list(strata = NULL), long = FALSE, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"hidden\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_proportion( df, .var, conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"clopper-pearson\", \"wilson\", \"wilsonc\", \"strat_wilson\", \"strat_wilsonc\", \"agresti-coull\", \"jeffreys\"), weights = NULL, max_iterations = 50, variables = list(strata = NULL), long = FALSE ) a_proportion( df, .var, conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"clopper-pearson\", \"wilson\", \"wilsonc\", \"strat_wilson\", \"strat_wilsonc\", \"agresti-coull\", \"jeffreys\"), weights = NULL, max_iterations = 50, variables = list(strata = NULL), long = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_proportion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Proportion estimation — estimate_proportion","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . conf_level (proportion) confidence level interval. method (string) method used construct confidence interval proportion successful outcomes; one waldcc, wald, clopper-pearson, wilson, wilsonc, strat_wilson, strat_wilsonc, agresti-coull jeffreys. weights (numeric NULL) weights level strata. NULL, estimated using iterative algorithm proposed Yan2010-jt;textualtern minimizes weighted squared length confidence interval. max_iterations (count) maximum number iterations iterative procedure used find estimates optimal weights. variables (named list string) list additional analysis variables. long (flag) whether long description required. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n_prop', 'prop_ci' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (logical data.frame) logical vector used, indicates whether subject responder . TRUE represents successful outcome. data.frame provided, also strata variable names must provided variables list element strata strings. case data.frame, logical vector responses must indicated variable name .var. .var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_proportion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Proportion estimation — estimate_proportion","text":"estimate_proportion() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_proportion() table layout. s_proportion() returns statistics n_prop (n proportion) prop_ci (proportion CI) given variable. a_proportion() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_proportion.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Proportion estimation — estimate_proportion","text":"estimate_proportion(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_proportion(): Statistics function estimating proportion along confidence interval. a_proportion(): Formatted analysis function used afun estimate_proportion().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/estimate_proportion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Proportion estimation — estimate_proportion","text":"","code":"dta_test <- data.frame( USUBJID = paste0(\"S\", 1:12), ARM = rep(LETTERS[1:3], each = 4), AVAL = rep(LETTERS[1:3], each = 4) ) basic_table() %>% split_cols_by(\"ARM\") %>% estimate_proportion(vars = \"AVAL\") %>% build_table(df = dta_test) #> A B C #> —————————————————————————————————————————————————————————————————— #> Responders #> 95% CI (Wald, with correction) # Case with only logical vector. rsp_v <- c(1, 0, 1, 0, 1, 1, 0, 0) s_proportion(rsp_v) #> $n_prop #> [1] 4.0 0.5 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> [1] 9.102404 90.897596 #> attr(,\"label\") #> [1] \"95% CI (Wald, with correction)\" #> # Example for Stratified Wilson CI nex <- 100 # Number of example rows dta <- data.frame( \"rsp\" = sample(c(TRUE, FALSE), nex, TRUE), \"grp\" = sample(c(\"A\", \"B\"), nex, TRUE), \"f1\" = sample(c(\"a1\", \"a2\"), nex, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), nex, TRUE), stringsAsFactors = TRUE ) s_proportion( df = dta, .var = \"rsp\", variables = list(strata = c(\"f1\", \"f2\")), conf_level = 0.90, method = \"strat_wilson\" ) #> $n_prop #> [1] 49.00 0.49 #> attr(,\"label\") #> [1] \"Responders\" #> #> $prop_ci #> lower upper #> 40.80675 56.65017 #> attr(,\"label\") #> [1] \"90% CI (Stratified Wilson, without correction)\" #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/ex_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulated CDISC data for examples — ex_data","title":"Simulated CDISC data for examples — ex_data","text":"Simulated CDISC data examples","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/ex_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulated CDISC data for examples — ex_data","text":"","code":"tern_ex_adsl tern_ex_adae tern_ex_adlb tern_ex_adpp tern_ex_adrs tern_ex_adtte"},{"path":"https://insightsengineering.github.io/tern/main/reference/ex_data.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Simulated CDISC data for examples — ex_data","text":"rds (data.frame) object class tbl_df (inherits tbl, data.frame) 200 rows 21 columns. object class tbl_df (inherits tbl, data.frame) 541 rows 42 columns. object class tbl_df (inherits tbl, data.frame) 4200 rows 50 columns. object class tbl_df (inherits tbl, data.frame) 522 rows 25 columns. object class tbl_df (inherits tbl, data.frame) 1600 rows 29 columns. object class tbl_df (inherits tbl, data.frame) 1000 rows 28 columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/ex_data.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Simulated CDISC data for examples — ex_data","text":"tern_ex_adsl: ADSL data tern_ex_adae: ADAE data tern_ex_adlb: ADLB data tern_ex_adpp: ADPP data tern_ex_adrs: ADRS data tern_ex_adtte: ADTTE data","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/explicit_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Missing data — explicit_na","title":"Missing data — explicit_na","text":"Substitute missing data string factor level.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/explicit_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Missing data — explicit_na","text":"","code":"explicit_na(x, label = \"\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/explicit_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Missing data — explicit_na","text":"x (factor character) values missing values substituted. label (string) string missing data replaced .","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/explicit_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Missing data — explicit_na","text":"x NA values substituted label.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/explicit_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Missing data — explicit_na","text":"","code":"explicit_na(c(NA, \"a\", \"b\")) #> [1] \"\" \"a\" \"b\" is.na(explicit_na(c(NA, \"a\", \"b\"))) #> [1] FALSE FALSE FALSE explicit_na(factor(c(NA, \"a\", \"b\"))) #> [1] a b #> Levels: a b is.na(explicit_na(factor(c(NA, \"a\", \"b\")))) #> [1] FALSE FALSE FALSE explicit_na(sas_na(c(\"a\", \"\"))) #> [1] \"a\" \"\""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_by_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract elements by name — extract_by_name","title":"Extract elements by name — extract_by_name","text":"utility function extracts elements vector x names. Differences standard [ function :","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_by_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract elements by name — extract_by_name","text":"","code":"extract_by_name(x, names)"},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_by_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract elements by name — extract_by_name","text":"x (named vector) extract named elements . names (character) vector names extract.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_by_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract elements by name — extract_by_name","text":"NULL x NULL, otherwise extracted elements x.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_by_name.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract elements by name — extract_by_name","text":"x NULL, still always NULL returned (base function). x NULL, intersection names made names elements returned. , names appear x returned NAs.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_biomarkers.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"Prepares estimates number responses, patients overall response rate, well odds ratio estimates, confidence intervals p-values, multiple biomarkers across population subgroups single data frame. variables corresponds names variables found data, passed named list requires elements rsp biomarkers (vector continuous biomarker variables) optionally covariates, subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_biomarkers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"","code":"extract_rsp_biomarkers( variables, data, groups_lists = list(), control = control_logistic(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_biomarkers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (named list) controls response definition confidence level produced control_logistic(). label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_biomarkers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"data.frame columns biomarker, biomarker_label, n_tot, n_rsp, prop, , lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_biomarkers.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"can also specify continuous variable rsp use response_definition control convert internally logical variable reflecting binary response.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_biomarkers.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare response data estimates for multiple biomarkers in a single data frame — extract_rsp_biomarkers","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% mutate(rsp = AVALC == \"CR\") # Typical analysis of two continuous biomarkers `BMRKR1` and `AGE`, # in logistic regression models with one covariate `RACE`. The subgroups # are defined by the levels of `BMRKR2`. df <- extract_rsp_biomarkers( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", subgroups = \"BMRKR2\" ), data = adrs_f ) df #> biomarker biomarker_label n_tot n_rsp prop or #> 1 BMRKR1 Continuous Level Biomarker 1 200 164 0.8200000 0.9755036 #> 2 AGE Age 200 164 0.8200000 0.9952416 #> 3 BMRKR1 Continuous Level Biomarker 1 70 53 0.7571429 1.1524547 #> 4 AGE Age 70 53 0.7571429 0.9261012 #> 5 BMRKR1 Continuous Level Biomarker 1 68 58 0.8529412 0.8773122 #> 6 AGE Age 68 58 0.8529412 0.9867104 #> 7 BMRKR1 Continuous Level Biomarker 1 62 53 0.8548387 0.8792921 #> 8 AGE Age 62 53 0.8548387 1.0630262 #> lcl ucl conf_level pval pval_label subgroup var #> 1 0.8804862 1.080775 0.95 0.6352602 p-value (Wald) All Patients ALL #> 2 0.9462617 1.046757 0.95 0.8530389 p-value (Wald) All Patients ALL #> 3 0.9462127 1.403650 0.95 0.1584187 p-value (Wald) LOW BMRKR2 #> 4 0.8487519 1.010500 0.95 0.0844837 p-value (Wald) LOW BMRKR2 #> 5 0.7277189 1.057657 0.95 0.1699778 p-value (Wald) MEDIUM BMRKR2 #> 6 0.8798911 1.106498 0.95 0.8189816 p-value (Wald) MEDIUM BMRKR2 #> 7 0.7189748 1.075357 0.95 0.2103709 p-value (Wald) HIGH BMRKR2 #> 8 0.9595973 1.177603 0.95 0.2418840 p-value (Wald) HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Continuous Level Biomarker 2 analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis # Here we group the levels of `BMRKR2` manually, and we add a stratification # variable `STRATA1`. We also here use a continuous variable `EOSDY` # which is then binarized internally (response is defined as this variable # being larger than 750). df_grouped <- extract_rsp_biomarkers( variables = list( rsp = \"EOSDY\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", subgroups = \"BMRKR2\", strata = \"STRATA1\" ), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ), control = control_logistic( response_definition = \"I(response > 750)\" ) ) df_grouped #> biomarker biomarker_label n_tot n_rsp prop or lcl ucl conf_level #> 1 BMRKR1 Continuous Level Biomarker 1 200 0 0 NA NA NA 0.95 #> 2 AGE Age 200 0 0 NA NA NA 0.95 #> 3 BMRKR1 Continuous Level Biomarker 1 70 0 0 NA NA NA 0.95 #> 4 AGE Age 70 0 0 NA NA NA 0.95 #> 5 BMRKR1 Continuous Level Biomarker 1 138 0 0 NA NA NA 0.95 #> 6 AGE Age 138 0 0 NA NA NA 0.95 #> 7 BMRKR1 Continuous Level Biomarker 1 200 0 0 NA NA NA 0.95 #> 8 AGE Age 200 0 0 NA NA NA 0.95 #> pval pval_label subgroup var var_label #> 1 NA p-value (Wald) All Patients ALL All Patients #> 2 NA p-value (Wald) All Patients ALL All Patients #> 3 NA p-value (Wald) low BMRKR2 Continuous Level Biomarker 2 #> 4 NA p-value (Wald) low BMRKR2 Continuous Level Biomarker 2 #> 5 NA p-value (Wald) low/medium BMRKR2 Continuous Level Biomarker 2 #> 6 NA p-value (Wald) low/medium BMRKR2 Continuous Level Biomarker 2 #> 7 NA p-value (Wald) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> 8 NA p-value (Wald) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 content #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis #> 7 analysis #> 8 analysis"},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"Prepares response rates odds ratios population subgroups data frames. Simple wrapper h_odds_ratio_subgroups_df() h_proportion_subgroups_df(). Result list two data.frames: prop . variables corresponds names variables found data, passed named list requires elements rsp, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"","code":"extract_rsp_subgroups( variables, data, groups_lists = list(), conf_level = 0.95, method = NULL, label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. conf_level (proportion) confidence level interval. method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed. label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_rsp_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare response data for population subgroups in data frames — extract_rsp_subgroups","text":"named list two elements: prop: data.frame containing columns arm, n, n_rsp, prop, subgroup, var, var_label, row_type. : data.frame containing columns arm, n_tot, , lcl, ucl, conf_level, subgroup, var, var_label, row_type.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_biomarkers.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"Prepares estimates number events, patients median survival times, well hazard ratio estimates, confidence intervals p-values, multiple biomarkers across population subgroups single data frame. variables corresponds names variables found data, passed named list requires elements tte, is_event, biomarkers (vector continuous biomarker variables), optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_biomarkers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"","code":"extract_survival_biomarkers( variables, data, groups_lists = list(), control = control_coxreg(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_biomarkers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (list) list parameters returned helper function control_coxreg(). label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_biomarkers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare survival data estimates for multiple biomarkers in a single data frame — extract_survival_biomarkers","text":"data.frame columns biomarker, biomarker_label, n_tot, n_tot_events, median, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"Prepares estimates median survival times treatment hazard ratios population subgroups data frames. Simple wrapper h_survtime_subgroups_df() h_coxph_subgroups_df(). Result list two data.frames: survtime hr. variables corresponds names variables found data, passed named list requires elements tte, is_event, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"","code":"extract_survival_subgroups( variables, data, groups_lists = list(), control = control_coxph(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing null hypothesis hazard ratio = 1. Default method \"log-rank\" comes survival::survdiff(), can also set \"wald\" \"likelihood\" (survival::coxph()). ties (string) specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval HR. label_all (string) label total population analysis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extract_survival_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare survival data for population subgroups in data frames — extract_survival_subgroups","text":"named list two elements: survtime: data.frame containing columns arm, n, n_events, median, subgroup, var, var_label, row_type. hr: data.frame containing columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Format extreme values — extreme_format","title":"Format extreme values — extreme_format","text":"rtables formatting functions handle extreme values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format extreme values — extreme_format","text":"","code":"h_get_format_threshold(digits = 2L) h_format_threshold(x, digits = 2L)"},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format extreme values — extreme_format","text":"digits (integer(1)) number decimal places display. x (numeric(1)) value format.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format extreme values — extreme_format","text":"h_get_format_threshold() returns list 2 elements: threshold, low high thresholds, format_string, thresholds formatted strings. h_format_threshold() returns given value, value within digit threshold relation given value digit threshold, formatted string.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Format extreme values — extreme_format","text":"input, apply format specified number digits. value threshold, returns \"<0.01\" e.g. number digits 2. value threshold, returns \">999.99\" e.g. number digits 2. zero, returns \"0.00\".","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Format extreme values — extreme_format","text":"h_get_format_threshold(): Internal helper function calculate threshold create formatted strings used Formatting Functions. Returns list elements threshold format_string. h_format_threshold(): Internal helper function apply threshold format value. Creates formatted string used Formatting Functions.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/extreme_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format extreme values — extreme_format","text":"","code":"h_get_format_threshold(2L) #> $threshold #> low high #> 0.01 999.99 #> #> $format_string #> low high #> \"<0.01\" \">999.99\" #> h_format_threshold(0.001) #> [1] \"<0.01\" h_format_threshold(1000) #> [1] \">999.99\""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/f_conf_level.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to create label for confidence interval — f_conf_level","text":"","code":"f_conf_level(conf_level)"},{"path":"https://insightsengineering.github.io/tern/main/reference/f_conf_level.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to create label for confidence interval — f_conf_level","text":"conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/f_conf_level.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to create label for confidence interval — f_conf_level","text":"string.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/f_pval.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to create label for p-value — f_pval","text":"","code":"f_pval(test_mean)"},{"path":"https://insightsengineering.github.io/tern/main/reference/f_pval.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to create label for p-value — f_pval","text":"test_mean (numeric(1)) mean value test null hypothesis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/f_pval.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to create label for p-value — f_pval","text":"string.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_collapse_only.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse factor levels and keep only those new group levels — fct_collapse_only","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"collapses levels keeps new group levels, order provided. returned factor levels order given, possible missing level last (included missing values).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_collapse_only.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"","code":"fct_collapse_only(.f, ..., .na_level = \"\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_collapse_only.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":".f (factor character) original vector. ... (named character) levels vector provided collapsed new level given respective name. .na_level (string) level use levels, missing new factor. Note level must contained new levels specified ....","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_collapse_only.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"modified factor collapsed levels. Values levels included given character vector input set missing level .na_level.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_collapse_only.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"existing NAs input vector replaced missing level. needed, explicit_na() can called separately result.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_collapse_only.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse factor levels and keep only those new group levels — fct_collapse_only","text":"","code":"fct_collapse_only(factor(c(\"a\", \"b\", \"c\", \"d\")), TRT = \"b\", CTRL = c(\"c\", \"d\")) #> [1] TRT CTRL CTRL #> Levels: TRT CTRL "},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_discard.html","id":null,"dir":"Reference","previous_headings":"","what":"Discard specified levels of a factor — fct_discard","title":"Discard specified levels of a factor — fct_discard","text":"discards observations well levels specified factor.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_discard.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Discard specified levels of a factor — fct_discard","text":"","code":"fct_discard(x, discard)"},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_discard.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Discard specified levels of a factor — fct_discard","text":"x (factor) original factor. discard (character) levels discard.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_discard.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Discard specified levels of a factor — fct_discard","text":"modified factor observations well levels discard dropped.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_discard.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Discard specified levels of a factor — fct_discard","text":"","code":"fct_discard(factor(c(\"a\", \"b\", \"c\")), \"c\") #> [1] a b #> Levels: a b"},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_explicit_na_if.html","id":null,"dir":"Reference","previous_headings":"","what":"Insertion of explicit missing values in a factor — fct_explicit_na_if","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"inserts explicit missing values factor based condition. Additionally, existing NA values explicitly converted given na_level.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_explicit_na_if.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"","code":"fct_explicit_na_if(x, condition, na_level = \"\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_explicit_na_if.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"x (factor) original factor. condition (logical) positions insert missing values. na_level (string) level use missing values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_explicit_na_if.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"modified factor inserted existing NA converted na_level.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/fct_explicit_na_if.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insertion of explicit missing values in a factor — fct_explicit_na_if","text":"","code":"fct_explicit_na_if(factor(c(\"a\", \"b\", NA)), c(TRUE, FALSE, FALSE)) #> [1] b #> Levels: a b "},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":null,"dir":"Reference","previous_headings":"","what":"Fitting functions for Cox proportional hazards regression — fit_coxreg","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"Fitting functions univariate multivariate Cox regression models.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"","code":"fit_coxreg_univar(variables, data, at = list(), control = control_coxreg()) fit_coxreg_multivar(variables, data, control = control_coxreg())"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"variables (named list) names variables found data, passed named list corresponding time, event, arm, strata, covariates terms. arm missing variables, Cox model(s) including covariates fitted corresponding effect estimates tabulated later. data (data.frame) dataset containing variables fit models. (list numeric) candidate covariate numeric, use specify value covariate effect estimated. control (list) list parameters returned helper function control_coxreg().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"fit_coxreg_univar() returns coxreg.univar class object named list 5 elements: mod: Cox regression models fitted survival::coxph(). data: original data frame input. control: original control input. vars: variables used model. : Value covariate effect estimated. fit_coxreg_multivar() returns coxreg.multivar class object named list 4 elements: mod: Cox regression model fitted survival::coxph(). data: original data frame input. control: original control input. vars: variables used model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"fit_coxreg_univar(): Fit series univariate Cox regression models given inputs. fit_coxreg_multivar(): Fit multivariate Cox regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"using fit_coxreg_univar two study arms.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_coxreg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fitting functions for Cox proportional hazards regression — fit_coxreg","text":"","code":"library(survival) set.seed(1, kind = \"Mersenne-Twister\") # Testing dataset [survival::bladder]. dta_bladder <- with( data = bladder[bladder$enum < 5, ], data.frame( time = stop, status = event, armcd = as.factor(rx), covar1 = as.factor(enum), covar2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) ) ) labels <- c(\"armcd\" = \"ARM\", \"covar1\" = \"A Covariate Label\", \"covar2\" = \"Sex (F/M)\") formatters::var_labels(dta_bladder)[names(labels)] <- labels dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) plot( survfit(Surv(time, status) ~ armcd + covar1, data = dta_bladder), lty = 2:4, xlab = \"Months\", col = c(\"blue1\", \"blue2\", \"blue3\", \"blue4\", \"red1\", \"red2\", \"red3\", \"red4\") ) # fit_coxreg_univar ## Cox regression: arm + 1 covariate. mod1 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = \"covar1\" ), data = dta_bladder, control = control_coxreg(conf_level = 0.91) ) ## Cox regression: arm + 1 covariate + interaction, 2 candidate covariates. mod2 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder, control = control_coxreg(conf_level = 0.91, interaction = TRUE) ) ## Cox regression: arm + 1 covariate, stratified analysis. mod3 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", strata = \"covar2\", covariates = c(\"covar1\") ), data = dta_bladder, control = control_coxreg(conf_level = 0.91) ) ## Cox regression: no arm, only covariates. mod4 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder ) # fit_coxreg_multivar ## Cox regression: multivariate Cox regression. multivar_model <- fit_coxreg_multivar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder ) # Example without treatment arm. multivar_covs_model <- fit_coxreg_multivar( variables = list( time = \"time\", event = \"status\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder )"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_logistic.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit for logistic regression — fit_logistic","title":"Fit for logistic regression — fit_logistic","text":"Fit (conditional) logistic regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_logistic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit for logistic regression — fit_logistic","text":"","code":"fit_logistic( data, variables = list(response = \"Response\", arm = \"ARMCD\", covariates = NULL, interaction = NULL, strata = NULL), response_definition = \"response\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_logistic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit for logistic regression — fit_logistic","text":"data (data.frame) data frame model fit. variables (named list string) list additional analysis variables. response_definition (string) definition event terms response. used fitting (conditional) logistic regression model left hand side formula.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_logistic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit for logistic regression — fit_logistic","text":"fitted logistic regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_logistic.html","id":"model-specification","dir":"Reference","previous_headings":"","what":"Model Specification","title":"Fit for logistic regression — fit_logistic","text":"variables list needs include following elements: arm: Treatment arm variable name. response: response arm variable name. Usually 0/1 variable. covariates: either NULL (covariates) character vector covariate variable names. interaction: either NULL (interaction) string single covariate variable name already included covariates. interaction treatment arm included model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_logistic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fit for logistic regression — fit_logistic","text":"","code":"library(dplyr) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_rsp_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"fits Subgroup Treatment Effect Pattern logistic regression models binary (response) outcome. treatment arm variable must exactly 2 levels, first one taken reference estimated odds ratios comparison second level vs. first one. (conditional) logistic regression model fit : response ~ arm * poly(biomarker, degree) + covariates + strata(strata) degree specified control_step().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_rsp_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"","code":"fit_rsp_step(variables, data, control = c(control_step(), control_logistic()))"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_rsp_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"variables (named list character) list analysis variables: needs response, arm, biomarker, optional covariates strata. data (data.frame) dataset containing variables summarize. control (named list) combined control list control_step() control_logistic().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_rsp_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"matrix class step. first part columns describe subgroup intervals used biomarker variable, including center intervals bounds. second part columns contain estimates treatment arm comparison.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_rsp_step.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"default degree 0 biomarker variable included model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_rsp_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subgroup treatment effect pattern (STEP) fit for binary (response) outcome — fit_rsp_step","text":"","code":"# Testing dataset with just two treatment arms. library(survival) library(dplyr) adrs_f <- tern_ex_adrs %>% filter( PARAMCD == \"BESRSPI\", ARM %in% c(\"B: Placebo\", \"A: Drug X\") ) %>% mutate( # Reorder levels of ARM to have Placebo as reference arm for Odds Ratio calculations. ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")), RSP = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), SEX = factor(SEX) ) variables <- list( arm = \"ARM\", biomarker = \"BMRKR1\", covariates = \"AGE\", response = \"RSP\" ) # Fit default STEP models: Here a constant treatment effect is estimated in each subgroup. # We use a large enough bandwidth to avoid too small subgroups and linear separation in those. step_matrix <- fit_rsp_step( variables = variables, data = adrs_f, control = c(control_logistic(), control_step(bandwidth = 0.9)) ) dim(step_matrix) #> [1] 39 11 head(step_matrix) #> Percentile Center Percentile Lower Percentile Upper Interval Center #> [1,] 0.025 0 0.925 1.472755 #> [2,] 0.050 0 0.950 2.028546 #> [3,] 0.075 0 0.975 2.204086 #> [4,] 0.100 0 1.000 2.799776 #> [5,] 0.125 0 1.000 2.969998 #> [6,] 0.150 0 1.000 3.149068 #> Interval Lower Interval Upper n logor se ci_lower ci_upper #> [1,] 0.4459546 11.74529 131 1.835008 1.134560 -0.3886885 4.058703 #> [2,] 0.4459546 12.73387 134 1.895158 1.136248 -0.3318481 4.122163 #> [3,] 0.4459546 14.75099 138 1.947699 1.136969 -0.2807193 4.176116 #> [4,] 0.4459546 18.49236 142 1.931001 1.135866 -0.2952561 4.157258 #> [5,] 0.4459546 18.49236 142 1.931001 1.135866 -0.2952561 4.157258 #> [6,] 0.4459546 18.49236 142 1.931001 1.135866 -0.2952561 4.157258 # Specify different polynomial degree for the biomarker interaction to use more flexible local # models. Or specify different logistic regression options, including confidence level. step_matrix2 <- fit_rsp_step( variables = variables, data = adrs_f, control = c(control_logistic(conf_level = 0.9), control_step(bandwidth = NULL, degree = 1)) ) # Use a global constant model. This is helpful as a reference for the subgroup models. step_matrix3 <- fit_rsp_step( variables = variables, data = adrs_f, control = c(control_logistic(), control_step(bandwidth = NULL, num_points = 2L)) ) # It is also possible to use strata, i.e. use conditional logistic regression models. variables2 <- list( arm = \"ARM\", biomarker = \"BMRKR1\", covariates = \"AGE\", response = \"RSP\", strata = c(\"STRATA1\", \"STRATA2\") ) step_matrix4 <- fit_rsp_step( variables = variables2, data = adrs_f, control = c(control_logistic(), control_step(bandwidth = NULL)) )"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_survival_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"fits subgroup treatment effect pattern (STEP) models survival outcome. treatment arm variable must exactly 2 levels, first one taken reference estimated hazard ratios comparison second level vs. first one. model fit : Surv(time, event) ~ arm * poly(biomarker, degree) + covariates + strata(strata) degree specified control_step().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_survival_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"","code":"fit_survival_step( variables, data, control = c(control_step(), control_coxph()) )"},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_survival_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"variables (named list character) list analysis variables: needs time, event, arm, biomarker, optional covariates strata. data (data.frame) dataset containing variables summarize. control (named list) combined control list control_step() control_coxph().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_survival_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"matrix class step. first part columns describe subgroup intervals used biomarker variable, including center intervals bounds. second part columns contain estimates treatment arm comparison.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_survival_step.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"default degree 0 biomarker variable included model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/fit_survival_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subgroup treatment effect pattern (STEP) fit for survival outcome — fit_survival_step","text":"","code":"# Testing dataset with just two treatment arms. library(dplyr) adtte_f <- tern_ex_adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")), is_event = CNSR == 0 ) labels <- c(\"ARM\" = \"Treatment Arm\", \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels variables <- list( arm = \"ARM\", biomarker = \"BMRKR1\", covariates = c(\"AGE\", \"BMRKR2\"), event = \"is_event\", time = \"AVAL\" ) # Fit default STEP models: Here a constant treatment effect is estimated in each subgroup. step_matrix <- fit_survival_step( variables = variables, data = adtte_f ) dim(step_matrix) #> [1] 39 12 head(step_matrix) #> Percentile Center Percentile Lower Percentile Upper Interval Center #> [1,] 0.025 0 0.275 1.472755 #> [2,] 0.050 0 0.300 2.028546 #> [3,] 0.075 0 0.325 2.204086 #> [4,] 0.100 0 0.350 2.799776 #> [5,] 0.125 0 0.375 2.969998 #> [6,] 0.150 0 0.400 3.149068 #> Interval Lower Interval Upper n events loghr se ci_lower #> [1,] 0.4459546 4.182444 39 29 0.03729601 0.4243013 -0.7943192 #> [2,] 0.4459546 4.349471 43 31 0.23246622 0.3881347 -0.5282639 #> [3,] 0.4459546 4.626913 46 32 0.07952492 0.3813113 -0.6678314 #> [4,] 0.4459546 4.805767 50 35 0.09020455 0.3638368 -0.6229026 #> [5,] 0.4459546 4.929816 53 37 0.15522702 0.3477999 -0.5264483 #> [6,] 0.4459546 5.020539 57 41 0.11135760 0.3332843 -0.5418676 #> ci_upper #> [1,] 0.8689112 #> [2,] 0.9931963 #> [3,] 0.8268813 #> [4,] 0.8033117 #> [5,] 0.8369023 #> [6,] 0.7645828 # Specify different polynomial degree for the biomarker interaction to use more flexible local # models. Or specify different Cox regression options. step_matrix2 <- fit_survival_step( variables = variables, data = adtte_f, control = c(control_coxph(conf_level = 0.9), control_step(degree = 2)) ) # Use a global model with cubic interaction and only 5 points. step_matrix3 <- fit_survival_step( variables = variables, data = adtte_f, control = c(control_coxph(), control_step(bandwidth = NULL, degree = 3, num_points = 5L)) )"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/forest_viewport.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a viewport tree for the forest plot — forest_viewport","text":"","code":"forest_viewport( tbl, width_row_names = NULL, width_columns = NULL, width_forest = grid::unit(1, \"null\"), gap_column = grid::unit(1, \"lines\"), gap_header = grid::unit(1, \"lines\"), mat_form = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/forest_viewport.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a viewport tree for the forest plot — forest_viewport","text":"tbl (VTableTree)rtables table object. width_row_names (grid::unit) width row names. width_columns (grid::unit) width column spans. width_forest (grid::unit) width forest plot. gap_column (grid::unit) gap width columns. gap_header (grid::unit) gap width header. mat_form (MatrixPrintForm) matrix print form table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/forest_viewport.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a viewport tree for the forest plot — forest_viewport","text":"viewport tree.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/forest_viewport.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a viewport tree for the forest plot — forest_viewport","text":"","code":"library(grid) tbl <- rtable( header = rheader( rrow(\"\", \"E\", rcell(\"CI\", colspan = 2)), rrow(\"\", \"A\", \"B\", \"C\") ), rrow(\"row 1\", 1, 0.8, 1.1), rrow(\"row 2\", 1.4, 0.8, 1.6), rrow(\"row 3\", 1.2, 0.8, 1.2) ) # \\donttest{ v <- forest_viewport(tbl) #> Warning: `forest_viewport()` was deprecated in tern 0.9.4. #> ℹ `g_forest` now generates `ggplot` objects. This function is no longer used #> within `tern`. #> Warning: `vp_forest_table_part()` was deprecated in tern 0.9.4. #> ℹ `g_forest` now generates `ggplot` objects. This function is no longer used #> within `tern`. #> ℹ The deprecated feature was likely used in the tern package. #> Please report the issue at #> . grid::grid.newpage() showViewport(v) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_auto.html","id":null,"dir":"Reference","previous_headings":"","what":"Format automatically using data significant digits — format_auto","title":"Format automatically using data significant digits — format_auto","text":"Formatting function majority default methods used analyze_vars(). non-derived values, significant digits data used (e.g. range), derived values one digits (measure location dispersion like mean, standard deviation). function can called internally \"auto\" like, example, .formats = c(\"mean\" = \"auto\"). See details see works inner function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_auto.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format automatically using data significant digits — format_auto","text":"","code":"format_auto(dt_var, x_stat)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_auto.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format automatically using data significant digits — format_auto","text":"dt_var (numeric) variable data statistics calculated . Used find significant digits. analyze_vars comes .df_row (see rtables::additional_fun_params), row data row splits. column split considered. x_stat (string) string indicating current statistical method used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_auto.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format automatically using data significant digits — format_auto","text":"string rtables prints table cell.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_auto.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Format automatically using data significant digits — format_auto","text":"internal function needed work rtables default structure format functions, .e. function(x, ...), x results statistical evaluation. can one element (e.g. .stats = \"mean_sd\").","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_auto.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format automatically using data significant digits — format_auto","text":"","code":"x_todo <- c(0.001, 0.2, 0.0011000, 3, 4) res <- c(mean(x_todo[1:3]), sd(x_todo[1:3])) # x is the result coming into the formatting function -> res!! format_auto(dt_var = x_todo, x_stat = \"mean_sd\")(x = res) #> [1] \"0.06737 (0.11486)\" format_auto(x_todo, \"range\")(x = range(x_todo)) #> [1] \"0.0010 - 4.0000\" no_sc_x <- c(0.0000001, 1) format_auto(no_sc_x, \"range\")(x = no_sc_x) #> [1] \"0.0000001 - 1.0000000\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction.html","id":null,"dir":"Reference","previous_headings":"","what":"Format count and fraction — format_count_fraction","title":"Format count and fraction — format_count_fraction","text":"Formats count together fraction special consideration count 0.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format count and fraction — format_count_fraction","text":"","code":"format_count_fraction(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format count and fraction — format_count_fraction","text":"x (numeric(2)) vector length 2 count fraction, respectively. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format count and fraction — format_count_fraction","text":"string format count (fraction %). count 0, format 0.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format count and fraction — format_count_fraction","text":"","code":"format_count_fraction(x = c(2, 0.6667)) #> [1] \"2 (66.7%)\" format_count_fraction(x = c(0, 0)) #> [1] \"0\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_fixed_dp.html","id":null,"dir":"Reference","previous_headings":"","what":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"Formats count together fraction special consideration count 0.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_fixed_dp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"","code":"format_count_fraction_fixed_dp(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_fixed_dp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"x (numeric(2)) vector length 2 count fraction, respectively. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_fixed_dp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"string format count (fraction %). count 0, format 0.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_fixed_dp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format count and percentage with fixed single decimal place — format_count_fraction_fixed_dp","text":"","code":"format_count_fraction_fixed_dp(x = c(2, 0.6667)) #> [1] \"2 (66.7%)\" format_count_fraction_fixed_dp(x = c(2, 0.5)) #> [1] \"2 (50.0%)\" format_count_fraction_fixed_dp(x = c(0, 0)) #> [1] \"0\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_lt10.html","id":null,"dir":"Reference","previous_headings":"","what":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"Formats count together fraction special consideration count less 10.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_lt10.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"","code":"format_count_fraction_lt10(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_lt10.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"x (numeric(2)) vector length 2 count fraction, respectively. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_lt10.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"string format count (fraction %). count less 10, count printed.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_count_fraction_lt10.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format count and fraction with special case for count < 10 — format_count_fraction_lt10","text":"","code":"format_count_fraction_lt10(x = c(275, 0.9673)) #> [1] \"275 (96.7%)\" format_count_fraction_lt10(x = c(2, 0.6667)) #> [1] \"2\" format_count_fraction_lt10(x = c(9, 1)) #> [1] \"9\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values.html","id":null,"dir":"Reference","previous_headings":"","what":"Format a single extreme value — format_extreme_values","title":"Format a single extreme value — format_extreme_values","text":"Create formatting function single extreme value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format a single extreme value — format_extreme_values","text":"","code":"format_extreme_values(digits = 2L)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format a single extreme value — format_extreme_values","text":"digits (integer(1)) number decimal places display.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format a single extreme value — format_extreme_values","text":"rtables formatting function uses threshold digits return formatted extreme value.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format a single extreme value — format_extreme_values","text":"","code":"format_fun <- format_extreme_values(2L) format_fun(x = 0.127) #> [1] \"0.13\" format_fun(x = Inf) #> [1] \">999.99\" format_fun(x = 0) #> [1] \"0.00\" format_fun(x = 0.009) #> [1] \"<0.01\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Format extreme values part of a confidence interval — format_extreme_values_ci","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"Formatting Function extreme values part confidence interval. Values formatted e.g. \"(xx.xx, xx.xx)\" number digits 2.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"","code":"format_extreme_values_ci(digits = 2L)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"digits (integer(1)) number decimal places display.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"rtables formatting function uses threshold digits return formatted extreme values confidence interval.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_extreme_values_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format extreme values part of a confidence interval — format_extreme_values_ci","text":"","code":"format_fun <- format_extreme_values_ci(2L) format_fun(x = c(0.127, Inf)) #> [1] \"(0.13, >999.99)\" format_fun(x = c(0, 0.009)) #> [1] \"(0.00, <0.01)\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction.html","id":null,"dir":"Reference","previous_headings":"","what":"Format fraction and percentage — format_fraction","title":"Format fraction and percentage — format_fraction","text":"Formats fraction together ratio percent.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format fraction and percentage — format_fraction","text":"","code":"format_fraction(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format fraction and percentage — format_fraction","text":"x (named integer) vector elements num denom. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format fraction and percentage — format_fraction","text":"string format num / denom (ratio %). num 0, format num / denom.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format fraction and percentage — format_fraction","text":"","code":"format_fraction(x = c(num = 2L, denom = 3L)) #> [1] \"2/3 (66.7%)\" format_fraction(x = c(num = 0L, denom = 3L)) #> [1] \"0/3\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_fixed_dp.html","id":null,"dir":"Reference","previous_headings":"","what":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"Formats fraction together ratio percent fixed single decimal place. Includes trailing zero case whole number percentages always keep one decimal place.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_fixed_dp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"","code":"format_fraction_fixed_dp(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_fixed_dp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"x (named integer) vector elements num denom. ... used. Required rtables interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_fixed_dp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"string format num / denom (ratio %). num 0, format num / denom.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_fixed_dp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format fraction and percentage with fixed single decimal place — format_fraction_fixed_dp","text":"","code":"format_fraction_fixed_dp(x = c(num = 1L, denom = 2L)) #> [1] \"1/2 (50.0%)\" format_fraction_fixed_dp(x = c(num = 1L, denom = 4L)) #> [1] \"1/4 (25.0%)\" format_fraction_fixed_dp(x = c(num = 0L, denom = 3L)) #> [1] \"0/3\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_threshold.html","id":null,"dir":"Reference","previous_headings":"","what":"Format fraction with lower threshold — format_fraction_threshold","title":"Format fraction with lower threshold — format_fraction_threshold","text":"Formats fraction second element input x fraction. applies lower threshold, just stated fraction smaller .","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_threshold.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format fraction with lower threshold — format_fraction_threshold","text":"","code":"format_fraction_threshold(threshold)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_threshold.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format fraction with lower threshold — format_fraction_threshold","text":"threshold (proportion) lower threshold.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_threshold.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format fraction with lower threshold — format_fraction_threshold","text":"rtables formatting function takes numeric input x second element fraction formatted. fraction equal threshold, displayed percentage. positive threshold, returns, e.g. \"<1\" threshold 0.01. zero, just \"0\" returned.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_fraction_threshold.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format fraction with lower threshold — format_fraction_threshold","text":"","code":"format_fun <- format_fraction_threshold(0.05) format_fun(x = c(20, 0.1)) #> [1] 10 format_fun(x = c(2, 0.01)) #> [1] \"<5\" format_fun(x = c(0, 0)) #> [1] \"0\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_sigfig.html","id":null,"dir":"Reference","previous_headings":"","what":"Format numeric values by significant figures — format_sigfig","title":"Format numeric values by significant figures — format_sigfig","text":"Format numeric values print specified number significant figures.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_sigfig.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format numeric values by significant figures — format_sigfig","text":"","code":"format_sigfig(sigfig, format = \"xx\", num_fmt = \"fg\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_sigfig.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format numeric values by significant figures — format_sigfig","text":"sigfig (integer(1)) number significant figures display. format (string) format label (string) apply printing value. Decimal places string ignored favor formatting significant figures. Formats options : \"xx\", \"xx / xx\", \"(xx, xx)\", \"xx - xx\", \"xx (xx)\". num_fmt (string) numeric format modifiers apply value. Defaults \"fg\" standard significant figures formatting - fixed (non-scientific notation) format (\"f\") sigfig equal number significant figures instead decimal places (\"g\"). See formatC() format argument options.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_sigfig.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format numeric values by significant figures — format_sigfig","text":"rtables formatting function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_sigfig.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format numeric values by significant figures — format_sigfig","text":"","code":"fmt_3sf <- format_sigfig(3) fmt_3sf(1.658) #> [1] \"1.66\" fmt_3sf(1e1) #> [1] \"10.0\" fmt_5sf <- format_sigfig(5) fmt_5sf(0.57) #> [1] \"0.57000\" fmt_5sf(0.000025645) #> [1] \"0.000025645\""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_xx.html","id":null,"dir":"Reference","previous_headings":"","what":"Format XX as a formatting function — format_xx","title":"Format XX as a formatting function — format_xx","text":"Translate string x dots interpreted number place holders, others formatting elements.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_xx.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format XX as a formatting function — format_xx","text":"","code":"format_xx(str)"},{"path":"https://insightsengineering.github.io/tern/main/reference/format_xx.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format XX as a formatting function — format_xx","text":"str (string) template.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/format_xx.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format XX as a formatting function — format_xx","text":"rtables formatting function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/format_xx.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format XX as a formatting function — format_xx","text":"","code":"test <- list(c(1.658, 0.5761), c(1e1, 785.6)) z <- format_xx(\"xx (xx.x)\") sapply(test, z) #> [1] \"2 (0.6)\" \"10 (785.6)\" z <- format_xx(\"xx.x - xx.x\") sapply(test, z) #> [1] \"1.7 - 0.6\" \"10 - 785.6\" z <- format_xx(\"xx.x, incl. xx.x% NE\") sapply(test, z) #> [1] \"1.7, incl. 0.6% NE\" \"10, incl. 785.6% NE\""},{"path":"https://insightsengineering.github.io/tern/main/reference/formatting_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Formatting functions — formatting_functions","title":"Formatting functions — formatting_functions","text":"See list formatting functions created tern work rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/formatting_functions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Formatting functions — formatting_functions","text":"available formats can listed via formatters::list_valid_format_labels(). Additional custom formats can created via formatters::sprintf_format() function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/g_bland_altman.html","id":null,"dir":"Reference","previous_headings":"","what":"Bland-Altman plot — g_bland_altman","title":"Bland-Altman plot — g_bland_altman","text":"Graphing function produces Bland-Altman plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_bland_altman.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bland-Altman plot — g_bland_altman","text":"","code":"g_bland_altman(x, y, conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_bland_altman.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bland-Altman plot — g_bland_altman","text":"x (numeric) vector numbers want analyze. y (numeric) vector numbers want analyze, compared x. conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_bland_altman.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bland-Altman plot — g_bland_altman","text":"ggplot Bland-Altman plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_bland_altman.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Bland-Altman plot — g_bland_altman","text":"","code":"x <- seq(1, 60, 5) y <- seq(5, 50, 4) g_bland_altman(x = x, y = y, conf_level = 0.9)"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/g_forest.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a forest plot from an rtable — g_forest","text":"","code":"g_forest( tbl, col_x = attr(tbl, \"col_x\"), col_ci = attr(tbl, \"col_ci\"), vline = 1, forest_header = attr(tbl, \"forest_header\"), xlim = c(0.1, 10), logx = TRUE, x_at = c(0.1, 1, 10), width_row_names = lifecycle::deprecated(), width_columns = NULL, width_forest = lifecycle::deprecated(), lbl_col_padding = 0, rel_width_forest = 0.25, font_size = 12, col_symbol_size = attr(tbl, \"col_symbol_size\"), col = getOption(\"ggplot2.discrete.colour\")[1], ggtheme = NULL, as_list = FALSE, gp = lifecycle::deprecated(), draw = lifecycle::deprecated(), newpage = lifecycle::deprecated() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_forest.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a forest plot from an rtable — g_forest","text":"tbl (VTableTree)rtables table least one column single value one column 2 values. col_x (integer(1) NULL) column index estimator. default tries get tbl attribute col_x, otherwise needs manually specified. NULL, points excluded forest plot. col_ci (integer(1) NULL) column index confidence intervals. default tries get tbl attribute col_ci, otherwise needs manually specified. NULL, lines excluded forest plot. vline (numeric(1) NULL) x coordinate vertical line, NULL line omitted. forest_header (character(2)) text displayed left right vline, respectively. vline = NULL forest_header printed. default tries get tbl attribute forest_header. NULL, defaults extracted table possible, set \"Comparison\\nBetter\" \"Treatment\\nBetter\" . xlim (numeric(2)) limits x axis. logx (flag) show x-values logarithm scale. x_at (numeric) x-tick locations, NULL, x_at set vline xlim values. width_row_names Please use lbl_col_padding argument instead. width_columns (numeric) vector column widths. element's position colwidths corresponds column tbl position. NULL, column widths calculated according maximum number characters per column. width_forest Please use rel_width_forest argument instead. lbl_col_padding (numeric) additional padding use calculating spacing first (label) column second column tbl. colwidths specified, width first column becomes colwidths[1] + lbl_col_padding. Defaults 0. rel_width_forest (proportion) proportion total width allocate forest plot. Relative width table 1 - rel_width_forest. as_list = TRUE, parameter ignored. font_size (numeric(1)) font size. col_symbol_size (numeric NULL) column index tbl containing data used determine relative size estimator plot symbol. Typically, symbol size proportional sample size used calculate estimator. NULL, symbol size used subgroups. default tries get tbl attribute col_symbol_size, otherwise needs manually specified. col (character) color(s). ggtheme (theme) graphical theme provided ggplot2 control styling plot. as_list (flag) whether two ggplot objects returned list. TRUE, named list two elements, table plot, returned. FALSE (default) table forest plot printed side--side via cowplot::plot_grid(). gp g_forest now generated ggplot object. argument longer used. draw g_forest now generated ggplot object. argument longer used. newpage g_forest now generated ggplot object. argument longer used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_forest.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a forest plot from an rtable — g_forest","text":"ggplot forest plot table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_forest.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a forest plot from an rtable — g_forest","text":"Given rtables::rtable() object least one column single value one column 2 values, converts table ggplot2::ggplot() object generates accompanying forest plot. table forest plot printed side--side.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_forest.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a forest plot from an rtable — g_forest","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs n_records <- 20 adrs_labels <- formatters::var_labels(adrs, fill = TRUE) adrs <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>% slice(seq_len(n_records)) %>% droplevels() %>% mutate( # Reorder levels of factor to make the placebo group the reference arm. ARM = fct_relevel(ARM, \"B: Placebo\"), rsp = AVALC == \"CR\" ) formatters::var_labels(adrs) <- c(adrs_labels, \"Response\") df <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"STRATA2\")), data = adrs ) # Full commonly used response table. tbl <- basic_table() %>% tabulate_rsp_subgroups(df) g_forest(tbl) # Odds ratio only table. tbl_or <- basic_table() %>% tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"or\", \"ci\")) g_forest( tbl_or, forest_header = c(\"Comparison\\nBetter\", \"Treatment\\nBetter\") ) # Survival forest plot example. adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte, fill = TRUE) adtte_f <- adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\"), SEX %in% c(\"M\", \"F\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(fct_relevel(ARM, \"B: Placebo\")), SEX = droplevels(SEX), AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- list( \"ARM\" = adtte_labels[\"ARM\"], \"SEX\" = adtte_labels[\"SEX\"], \"AVALU\" = adtte_labels[\"AVALU\"], \"is_event\" = \"Event Flag\" ) formatters::var_labels(adtte_f)[names(labels)] <- as.character(labels) df <- extract_survival_subgroups( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f ) table_hr <- basic_table() %>% tabulate_survival_subgroups(df, time_unit = adtte_f$AVALU[1]) g_forest(table_hr) # Works with any `rtable`. tbl <- rtable( header = c(\"E\", \"CI\", \"N\"), rrow(\"\", 1, c(.8, 1.2), 200), rrow(\"\", 1.2, c(1.1, 1.4), 50) ) g_forest( tbl = tbl, col_x = 1, col_ci = 2, xlim = c(0.5, 2), x_at = c(0.5, 1, 2), col_symbol_size = 3 ) tbl <- rtable( header = rheader( rrow(\"\", rcell(\"A\", colspan = 2)), rrow(\"\", \"c1\", \"c2\") ), rrow(\"row 1\", 1, c(.8, 1.2)), rrow(\"row 2\", 1.2, c(1.1, 1.4)) ) g_forest( tbl = tbl, col_x = 1, col_ci = 2, xlim = c(0.5, 2), x_at = c(0.5, 1, 2), vline = 1, forest_header = c(\"Hello\", \"World\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_ipp.html","id":null,"dir":"Reference","previous_headings":"","what":"Individual patient plots — g_ipp","title":"Individual patient plots — g_ipp","text":"Line plot(s) displaying trend patients' parameter values time rendered. Patients' individual baseline values can added plot(s) reference.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_ipp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Individual patient plots — g_ipp","text":"","code":"g_ipp( df, xvar, yvar, xlab, ylab, id_var = \"USUBJID\", title = \"Individual Patient Plots\", subtitle = \"\", caption = NULL, add_baseline_hline = FALSE, yvar_baseline = \"BASE\", ggtheme = nestcolor::theme_nest(), plotting_choices = c(\"all_in_one\", \"split_by_max_obs\", \"separate_by_obs\"), max_obs_per_plot = 4, col = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_ipp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Individual patient plots — g_ipp","text":"df (data.frame) data set containing analysis variables. xvar (string) time point variable plotted x-axis. yvar (string) continuous analysis variable plotted y-axis. xlab (string) plot label x-axis. ylab (string) plot label y-axis. id_var (string) variable used patient identifier. title (string) title plot. subtitle (string) subtitle plot. caption (string) optional caption plot. add_baseline_hline (flag) adds horizontal line baseline y-value plot TRUE. yvar_baseline (string) variable baseline values . Ignored add_baseline_hline FALSE. ggtheme (theme) optional graphical theme function provided ggplot2 control outlook plot. Use ggplot2::theme() tweak display. plotting_choices (string) specifies options displaying plots. Must one \"all_in_one\", \"split_by_max_obs\", \"separate_by_obs\". max_obs_per_plot (integer(1)) number observations plotted one plot. Ignored plotting_choices \"separate_by_obs\". col (character) line colors.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_ipp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Individual patient plots — g_ipp","text":"ggplot object list ggplot objects.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_ipp.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Individual patient plots — g_ipp","text":"g_ipp(): Plotting function individual patient plots , depending user preference, renders single graphic compiles list graphics show trends individual's parameter values time.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/g_ipp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Individual patient plots — g_ipp","text":"","code":"library(dplyr) # Select a small sample of data to plot. adlb <- tern_ex_adlb %>% filter(PARAMCD == \"ALT\", !(AVISIT %in% c(\"SCREENING\", \"BASELINE\"))) %>% slice(1:36) plot_list <- g_ipp( df = adlb, xvar = \"AVISIT\", yvar = \"AVAL\", xlab = \"Visit\", ylab = \"SGOT/ALT (U/L)\", title = \"Individual Patient Plots\", add_baseline_hline = TRUE, plotting_choices = \"split_by_max_obs\", max_obs_per_plot = 5 ) plot_list #> [[1]] #> #> [[2]] #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_km.html","id":null,"dir":"Reference","previous_headings":"","what":"Kaplan-Meier plot — g_km","title":"Kaplan-Meier plot — g_km","text":"survival model, graphic rendered along tabulated annotation including number patient risk given time median survival per group.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_km.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Kaplan-Meier plot — g_km","text":"","code":"g_km( df, variables, control_surv = control_surv_timepoint(), col = NULL, lty = NULL, lwd = 0.5, censor_show = TRUE, pch = 3, size = 2, max_time = NULL, xticks = NULL, xlab = \"Days\", yval = c(\"Survival\", \"Failure\"), ylab = paste(yval, \"Probability\"), ylim = NULL, title = NULL, footnotes = NULL, font_size = 10, ci_ribbon = FALSE, annot_at_risk = TRUE, annot_at_risk_title = TRUE, annot_surv_med = TRUE, annot_coxph = FALSE, annot_stats = NULL, annot_stats_vlines = FALSE, control_coxph_pw = control_coxph(), ref_group_coxph = NULL, control_annot_surv_med = control_surv_med_annot(), control_annot_coxph = control_coxph_annot(), legend_pos = NULL, rel_height_plot = 0.75, ggtheme = NULL, as_list = FALSE, draw = lifecycle::deprecated(), newpage = lifecycle::deprecated(), gp = lifecycle::deprecated(), vp = lifecycle::deprecated(), name = lifecycle::deprecated(), annot_coxph_ref_lbls = lifecycle::deprecated(), position_coxph = lifecycle::deprecated(), position_surv_med = lifecycle::deprecated(), width_annots = lifecycle::deprecated() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_km.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Kaplan-Meier plot — g_km","text":"df (data.frame) data set containing analysis variables. variables (named list) variable names. Details : tte (numeric) variable indicating time--event duration values. is_event (logical) event variable. TRUE event, FALSE time event censored. arm (factor) treatment group variable. strata (character NULL) variable names indicating stratification factors. control_surv (list) parameters comparison details, specified using helper function control_surv_timepoint(). possible parameter options : conf_level (proportion) confidence level interval survival rate. conf_type (string)\"plain\" (default), \"log\", \"log-log\" confidence interval type, see survival::survfit(). Note option \"none\" longer supported. col (character) lines colors. Length vector equal number strata survival::survfit(). lty (numeric) line type. vector given, length equal number strata survival::survfit(). lwd (numeric) line width. vector given, length equal number strata survival::survfit(). censor_show (flag) whether show censored observations. pch (string) name symbol character use point symbol indicate censored cases. size (numeric(1)) size censored point symbols. max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL). xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis. NULL (default), labeling::extended() used determine optimal tick positions x-axis. xlab (string) x-axis label. yval (string) type plot, plotted y-axis. Options Survival (default) Failure probability. ylab (string) y-axis label. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used. title (string) plot title. footnotes (string) plot footnotes. font_size (numeric(1)) font size use text. ci_ribbon (flag) whether confidence interval drawn around Kaplan-Meier curve. annot_at_risk (flag) compute add annotation table reporting number patient risk matching main grid Kaplan-Meier curve. annot_at_risk_title (flag) whether \"Patients Risk\" title added annot_at_risk table. effect annot_at_risk FALSE. Defaults TRUE. annot_surv_med (flag) compute add annotation table Kaplan-Meier curve estimating median survival time per group. annot_coxph (flag) whether add annotation table survival::coxph() model. annot_stats (string NULL) statistics annotations add plot. Options median (median survival follow-time) min (minimum survival follow-time). annot_stats_vlines (flag) add vertical lines corresponding statistics specified annot_stats. annot_stats NULL lines added. control_coxph_pw (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing hazard ratio = 1. Default method \"log-rank\", can also set \"wald\" \"likelihood\". ties (string) method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph() conf_level (proportion) confidence level interval HR. ref_group_coxph (string NULL) level arm variable use reference group calculations annot_coxph table. NULL (default), uses first level arm variable. control_annot_surv_med (list) parameters control position size annotation table added plot annot_surv_med = TRUE, specified using control_surv_med_annot() function. Parameter options : x, y, w, h, fill. See control_surv_med_annot() details. control_annot_coxph (list) parameters control position size annotation table added plot annot_coxph = TRUE, specified using control_coxph_annot() function. Parameter options : x, y, w, h, fill, ref_lbls. See control_coxph_annot() details. legend_pos (numeric(2) NULL) vector containing x- y-coordinates, respectively, legend position relative KM plot area. NULL (default), legend positioned bottom right corner plot, middle right plot needed prevent overlapping. rel_height_plot (proportion) proportion total figure height allocate Kaplan-Meier plot. Relative height patients risk table 1 - rel_height_plot. annot_at_risk = FALSE as_list = TRUE, parameter ignored. ggtheme (theme) graphical theme provided ggplot2 format Kaplan-Meier plot. as_list (flag) whether two ggplot objects returned list annot_at_risk = TRUE. TRUE, named list two elements, plot table, returned. FALSE (default) patients risk table printed plot via cowplot::plot_grid(). draw function longer generates grob objects. newpage function longer generates grob objects. gp function longer generates grob objects. vp function longer generates grob objects. name function longer generates grob objects. annot_coxph_ref_lbls Please use ref_lbls element control_annot_coxph instead. position_coxph Please use x y elements control_annot_coxph instead. position_surv_med Please use x y elements control_annot_surv_med instead. width_annots Please use w element control_annot_surv_med (surv_med) control_annot_coxph (coxph).\"","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_km.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Kaplan-Meier plot — g_km","text":"ggplot Kaplan-Meier plot (optionally) summary table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_km.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Kaplan-Meier plot — g_km","text":"","code":"library(dplyr) df <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) variables <- list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARMCD\") # Basic examples g_km(df = df, variables = variables) g_km(df = df, variables = variables, yval = \"Failure\") # Examples with customization parameters applied g_km( df = df, variables = variables, control_surv = control_surv_timepoint(conf_level = 0.9), col = c(\"grey25\", \"grey50\", \"grey75\"), annot_at_risk_title = FALSE, lty = 1:3, font_size = 8 ) g_km( df = df, variables = variables, annot_stats = c(\"min\", \"median\"), annot_stats_vlines = TRUE, max_time = 3000, ggtheme = ggplot2::theme_minimal() ) # Example with pairwise Cox-PH analysis annotation table, adjusted annotation tables g_km( df = df, variables = variables, annot_coxph = TRUE, control_coxph = control_coxph(pval_method = \"wald\", ties = \"exact\", conf_level = 0.99), control_annot_coxph = control_coxph_annot(x = 0.26, w = 0.35), control_annot_surv_med = control_surv_med_annot(x = 0.8, y = 0.9, w = 0.35) )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_lineplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Line plot with optional table — g_lineplot","title":"Line plot with optional table — g_lineplot","text":"Line plot optional table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_lineplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Line plot with optional table — g_lineplot","text":"","code":"g_lineplot( df, alt_counts_df = NULL, variables = control_lineplot_vars(), mid = \"mean\", interval = \"mean_ci\", whiskers = c(\"mean_ci_lwr\", \"mean_ci_upr\"), table = NULL, sfun = s_summary, ..., mid_type = \"pl\", mid_point_size = 2, position = ggplot2::position_dodge(width = 0.4), legend_title = NULL, legend_position = \"bottom\", ggtheme = nestcolor::theme_nest(), xticks = NULL, xlim = NULL, ylim = NULL, x_lab = obj_label(df[[variables[[\"x\"]]]]), y_lab = NULL, y_lab_add_paramcd = TRUE, y_lab_add_unit = TRUE, title = \"Plot of Mean and 95% Confidence Limits by Visit\", subtitle = \"\", subtitle_add_paramcd = TRUE, subtitle_add_unit = TRUE, caption = NULL, table_format = NULL, table_labels = NULL, table_font_size = 3, errorbar_width = 0.45, newpage = lifecycle::deprecated(), col = NULL, linetype = NULL, rel_height_plot = 0.5, as_list = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_lineplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Line plot with optional table — g_lineplot","text":"df (data.frame) data set containing analysis variables. alt_counts_df (data.frame NULL) data set used () counts objects groups stratification. variables (named character) vector variable names df include: x (string) name x-axis variable. y (string) name y-axis variable. group_var (string NULL) name grouping variable (strata), .e. treatment arm. Can NA indicate lack groups. subject_var (string NULL) name subject variable. applies group_var NULL. paramcd (string NA) name variable parameter's code. Used y-axis label plot's subtitle. Can NA paramcd added y-axis label subtitle. y_unit (string NA) name variable units y. Used y-axis label plot's subtitle. Can NA y unit added y-axis label subtitle. facet_var (string NA) name secondary grouping variable used plot faceting, .e. treatment arm. Can NA indicate lack groups. mid (character NULL) names statistics plotted midpoints. statistics indicated mid variable must present object returned sfun, double numeric type vector length one. interval (character NULL) names statistics plotted intervals. statistics indicated interval variable must present object returned sfun, double numeric type vector length two. Set interval = NULL intervals added plot. whiskers (character) names interval whiskers plotted. Names must match names list element interval returned sfun (e.g. mean_ci_lwr element sfun(x)[[\"mean_ci\"]]). possible specify one whisker , suppress whiskers setting interval = NULL. table (character NULL) names statistics displayed table plot. statistics indicated table variable must present object returned sfun. sfun (function) function compute values required statistics. must return named list atomic vectors. names list elements refer names statistics used mid, interval, table. must able accept input vector data statistics computed. ... optional arguments sfun. mid_type (string) controls type mid plot, can point (\"p\"), line (\"l\"), point line (\"pl\"). mid_point_size (numeric(1)) font size mid plot points. position (character call) geom element position adjustment, either string, result call position adjustment function. legend_title (string) legend title. legend_position (string) position plot legend (\"none\", \"left\", \"right\", \"bottom\", \"top\", two-element numeric vector). ggtheme (theme) graphical theme provided ggplot2 control styling plot. xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis, use variables$x numeric. NULL (default), labeling::extended() used determine optimal tick positions x-axis. variables$x numeric, argument ignored. xlim (numeric(2)) vector containing lower upper limits x-axis, respectively. NULL (default), default scale range used. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used. x_lab (string NULL) x-axis label. NULL label added. y_lab (string NULL) y-axis label. NULL label added. y_lab_add_paramcd (flag) whether paramcd, .e. unique(df[[variables[\"paramcd\"]]]) added y-axis label (y_lab). y_lab_add_unit (flag) whether y-axis unit, .e. unique(df[[variables[\"y_unit\"]]]) added y-axis label (y_lab). title (string) plot title. subtitle (string) plot subtitle. subtitle_add_paramcd (flag) whether paramcd, .e. unique(df[[variables[\"paramcd\"]]]) added plot's subtitle (subtitle). subtitle_add_unit (flag) whether y-axis unit, .e. unique(df[[variables[\"y_unit\"]]]) added plot's subtitle (subtitle). caption (string) optional caption plot. table_format (named character NULL) format patterns descriptive statistics used (optional) table appended plot. passed directly h_format_row function format parameter. Names table_format must match names statistics returned sfun function. table_labels (named character NULL) labels descriptive statistics used (optional) table appended plot. Names table_labels must match names statistics returned sfun function. table_font_size (numeric(1)) font size text table. errorbar_width (numeric(1)) width error bars. newpage used. col (character) color(s). See ?ggplot2::aes_colour_fill_alpha example values. linetype (character) line type(s). See ?ggplot2::aes_linetype_size_shape example values. rel_height_plot (proportion) proportion total figure height allocate line plot. Relative height annotation table 1 - rel_height_plot. table = NULL, parameter ignored. as_list (flag) whether two ggplot objects returned list table NULL. TRUE, named list two elements, plot table, returned. FALSE (default) annotation table printed plot via cowplot::plot_grid().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_lineplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Line plot with optional table — g_lineplot","text":"ggplot line plot (statistics table applicable).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_lineplot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Line plot with optional table — g_lineplot","text":"","code":"adsl <- tern_ex_adsl adlb <- tern_ex_adlb %>% dplyr::filter(ANL01FL == \"Y\", PARAMCD == \"ALT\", AVISIT != \"SCREENING\") adlb$AVISIT <- droplevels(adlb$AVISIT) adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) # Mean with CI g_lineplot(adlb, adsl, subtitle = \"Laboratory Test:\") # Mean with CI, no stratification with group_var g_lineplot(adlb, variables = control_lineplot_vars(group_var = NA)) # Mean, upper whisker of CI, no group_var(strata) counts N g_lineplot( adlb, whiskers = \"mean_ci_upr\", title = \"Plot of Mean and Upper 95% Confidence Limit by Visit\" ) # Median with CI g_lineplot( adlb, adsl, mid = \"median\", interval = \"median_ci\", whiskers = c(\"median_ci_lwr\", \"median_ci_upr\"), title = \"Plot of Median and 95% Confidence Limits by Visit\" ) # Mean, +/- SD g_lineplot(adlb, adsl, interval = \"mean_sdi\", whiskers = c(\"mean_sdi_lwr\", \"mean_sdi_upr\"), title = \"Plot of Median +/- SD by Visit\" ) # Mean with CI plot with stats table g_lineplot(adlb, adsl, table = c(\"n\", \"mean\", \"mean_ci\")) # Mean with CI, table and customized confidence level g_lineplot( adlb, adsl, table = c(\"n\", \"mean\", \"mean_ci\"), control = control_analyze_vars(conf_level = 0.80), title = \"Plot of Mean and 80% Confidence Limits by Visit\" ) # Mean with CI, table, filtered data adlb_f <- dplyr::filter(adlb, ARMCD != \"ARM A\" | AVISIT == \"BASELINE\") g_lineplot(adlb_f, table = c(\"n\", \"mean\"))"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a STEP graph — g_step","title":"Create a STEP graph — g_step","text":"Based STEP results, creates ggplot graph showing estimated HR along continuous biomarker value subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a STEP graph — g_step","text":"","code":"g_step( df, use_percentile = \"Percentile Center\" %in% names(df), est = list(col = \"blue\", lty = 1), ci_ribbon = list(fill = getOption(\"ggplot2.discrete.colour\")[1], alpha = 0.5), col = getOption(\"ggplot2.discrete.colour\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a STEP graph — g_step","text":"df (tibble) result tidy.step(). use_percentile (flag) whether use percentiles x axis actual biomarker values. est (named list)col lty settings estimate line. ci_ribbon (named list NULL)fill alpha settings confidence interval ribbon area, NULL plot CI ribbon. col (character) color(s).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a STEP graph — g_step","text":"ggplot STEP graph.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/g_step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a STEP graph — g_step","text":"","code":"library(survival) lung$sex <- factor(lung$sex) # Survival example. vars <- list( time = \"time\", event = \"status\", arm = \"sex\", biomarker = \"age\" ) step_matrix <- fit_survival_step( variables = vars, data = lung, control = c(control_coxph(), control_step(num_points = 10, degree = 2)) ) step_data <- broom::tidy(step_matrix) # Default plot. g_step(step_data) # Add the reference 1 horizontal line. library(ggplot2) g_step(step_data) + ggplot2::geom_hline(ggplot2::aes(yintercept = 1), linetype = 2) # Use actual values instead of percentiles, different color for estimate and no CI, # use log scale for y axis. g_step( step_data, use_percentile = FALSE, est = list(col = \"blue\", lty = 1), ci_ribbon = NULL ) + scale_y_log10() # Adding another curve based on additional column. step_data$extra <- exp(step_data$`Percentile Center`) g_step(step_data) + ggplot2::geom_line(ggplot2::aes(y = extra), linetype = 2, color = \"green\") # Response example. vars <- list( response = \"status\", arm = \"sex\", biomarker = \"age\" ) step_matrix <- fit_rsp_step( variables = vars, data = lung, control = c( control_logistic(response_definition = \"I(response == 2)\"), control_step() ) ) step_data <- broom::tidy(step_matrix) g_step(step_data)"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_waterfall.html","id":null,"dir":"Reference","previous_headings":"","what":"Horizontal waterfall plot — g_waterfall","title":"Horizontal waterfall plot — g_waterfall","text":"basic waterfall plot visualizes quantity height ordered value markup.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_waterfall.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Horizontal waterfall plot — g_waterfall","text":"","code":"g_waterfall( height, id, col_var = NULL, col = getOption(\"ggplot2.discrete.colour\"), xlab = NULL, ylab = NULL, col_legend_title = NULL, title = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/g_waterfall.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Horizontal waterfall plot — g_waterfall","text":"height (numeric) vector containing values plotted waterfall bars. id (character) vector containing identifiers use x-axis label waterfall bars. col_var (factor, character, NULL) categorical variable bar coloring. NULL default. col (character) color(s). xlab (string) x label. Default \"ID\". ylab (string) y label. Default \"Value\". col_legend_title (string) text displayed legend title. title (string) text displayed plot title.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_waterfall.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Horizontal waterfall plot — g_waterfall","text":"ggplot waterfall plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/g_waterfall.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Horizontal waterfall plot — g_waterfall","text":"","code":"library(dplyr) g_waterfall(height = c(3, 5, -1), id = letters[1:3]) g_waterfall( height = c(3, 5, -1), id = letters[1:3], col_var = letters[1:3] ) adsl_f <- tern_ex_adsl %>% select(USUBJID, STUDYID, ARM, ARMCD, SEX) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"OVRINV\") %>% mutate(pchg = rnorm(n(), 10, 50)) adrs_f <- head(adrs_f, 30) adrs_f <- adrs_f[!duplicated(adrs_f$USUBJID), ] head(adrs_f) #> # A tibble: 5 × 30 #> STUDYID COUNTRY SITEID SUBJID AGE SEX ARMCD ARM ACTARMCD ACTARM RACE #> #> 1 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug… ARM A A: Dr… ASIAN #> 2 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac… ARM B B: Pl… ASIAN #> 3 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac… ARM B B: Pl… ASIAN #> 4 AB12345 BRA BRA-1 id-23 41.3 F ARM A A: Drug… ARM A A: Dr… AMER… #> 5 AB12345 BRA BRA-1 id-59 26.7 F ARM A A: Drug… ARM A A: Dr… ASIAN #> # ℹ 19 more variables: TRTSDTM , TRTEDTM , EOSDY , #> # STRATA1 , STRATA2 , BMRKR1 , BMRKR2 , REGION1 , #> # SAFFL , USUBJID , AVISIT , PARAMCD , PARAM , #> # AVALC , AVAL , ADTM , AVISITN , DTHFL , #> # pchg g_waterfall( height = adrs_f$pchg, id = adrs_f$USUBJID, col_var = adrs_f$AVALC ) g_waterfall( height = adrs_f$pchg, id = paste(\"asdfdsfdsfsd\", adrs_f$USUBJID), col_var = adrs_f$SEX ) g_waterfall( height = adrs_f$pchg, id = paste(\"asdfdsfdsfsd\", adrs_f$USUBJID), xlab = \"ID\", ylab = \"Percentage Change\", title = \"Waterfall plot\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/get_covariates.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to return a named list of covariate names — get_covariates","title":"Utility function to return a named list of covariate names — get_covariates","text":"Utility function return named list covariate names","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/get_covariates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to return a named list of covariate names — get_covariates","text":"","code":"get_covariates(covariates)"},{"path":"https://insightsengineering.github.io/tern/main/reference/get_covariates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to return a named list of covariate names — get_covariates","text":"covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\".","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/get_covariates.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to return a named list of covariate names — get_covariates","text":"named list character vector.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/get_smooths.html","id":null,"dir":"Reference","previous_headings":"","what":"Smooth function with optional grouping — get_smooths","title":"Smooth function with optional grouping — get_smooths","text":"produces loess smoothed estimates y Student confidence intervals.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/get_smooths.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Smooth function with optional grouping — get_smooths","text":"","code":"get_smooths(df, x, y, groups = NULL, level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/main/reference/get_smooths.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Smooth function with optional grouping — get_smooths","text":"df (data.frame) data set containing analysis variables. x (string) x column name. y (string) y column name. groups (character NULL) vector optional grouping variables names. level (proportion) level confidence interval use (0.95 default).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/get_smooths.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Smooth function with optional grouping — get_smooths","text":"data.frame original x, smoothed y, ylow, yhigh, optional groups variables formatted factor type.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/groups_list_to_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert list of groups to a data frame — groups_list_to_df","title":"Convert list of groups to a data frame — groups_list_to_df","text":"converts list group levels data frame format expected rtables::add_combo_levels().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/groups_list_to_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert list of groups to a data frame — groups_list_to_df","text":"","code":"groups_list_to_df(groups_list)"},{"path":"https://insightsengineering.github.io/tern/main/reference/groups_list_to_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert list of groups to a data frame — groups_list_to_df","text":"groups_list (named list character) specifies new group levels via names levels belong character vectors elements list.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/groups_list_to_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert list of groups to a data frame — groups_list_to_df","text":"tibble required format.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/groups_list_to_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert list of groups to a data frame — groups_list_to_df","text":"","code":"grade_groups <- list( \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"), \"Grade 3-4 (%)\" = c(\"3\", \"4\"), \"Grade 5 (%)\" = \"5\" ) groups_list_to_df(grade_groups) #> # A tibble: 3 × 4 #> valname label levelcombo exargs #> #> 1 AnyGrade Any Grade (%) #> 2 Grade34 Grade 3-4 (%) #> 3 Grade5 Grade 5 (%) "},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_abnormal_by_worst_grade.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"Helper function prepare ADLB data frame used input count_abnormal_by_worst_grade(). following pre-processing steps applied: adlb filtered variable avisit include post-baseline visits. adlb filtered variables worst_flag_low worst_flag_high worst grades (either direction) included. standard lab grade variable atoxgr, following two variables derived added adlb: grade direction variable (e.g. GRADE_DIR). variable takes value \"HIGH\" atoxgr > 0, \"LOW\" atoxgr < 0, \"ZERO\" otherwise. toxicity grade variable (e.g. GRADE_ANL) negative values atoxgr replaced absolute values. Unused factor levels dropped adlb via droplevels().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_abnormal_by_worst_grade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"","code":"h_adlb_abnormal_by_worst_grade( adlb, atoxgr = \"ATOXGR\", avisit = \"AVISIT\", worst_flag_low = \"WGRLOFL\", worst_flag_high = \"WGRHIFL\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_abnormal_by_worst_grade.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"adlb (data.frame) ADLB data frame. atoxgr (string) name analysis toxicity grade variable. must factor variable. avisit (string) name analysis visit variable. worst_flag_low (string) name worst low lab grade flag variable. variable set \"Y\" indicating records worst low lab grades. worst_flag_high (string) name worst high lab grade flag variable. variable set \"Y\" indicating records worst high lab grades.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_abnormal_by_worst_grade.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"h_adlb_abnormal_by_worst_grade() returns adlb data frame two new variables: GRADE_DIR GRADE_ANL.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_abnormal_by_worst_grade.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to prepare ADLB for count_abnormal_by_worst_grade() — h_adlb_abnormal_by_worst_grade","text":"","code":"h_adlb_abnormal_by_worst_grade(tern_ex_adlb) %>% dplyr::select(ATOXGR, GRADE_DIR, GRADE_ANL) %>% head(10) #> # A tibble: 10 × 3 #> ATOXGR GRADE_DIR GRADE_ANL #> #> 1 -3 LOW 3 #> 2 0 ZERO 0 #> 3 0 ZERO 0 #> 4 2 HIGH 2 #> 5 0 ZERO 0 #> 6 0 ZERO 0 #> 7 -4 LOW 4 #> 8 1 HIGH 1 #> 9 -1 LOW 1 #> 10 0 ZERO 0"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_worsen.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"Helper function prepare df generate patient count shift table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_worsen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"","code":"h_adlb_worsen( adlb, worst_flag_low = NULL, worst_flag_high = NULL, direction_var )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_worsen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"adlb (data.frame) ADLB data frame. worst_flag_low (named vector) worst low post-baseline lab grade flag variable. See implemented following examples. worst_flag_high (named vector) worst high post-baseline lab grade flag variable. See implemented following examples. direction_var (string) name direction variable specifying direction shift table interest. lab records flagged L, H B included shift table. L: low direction H: high direction B: low high directions","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_worsen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"h_adlb_worsen() returns adlb data.frame containing worst labs specified according worst_flag_low worst_flag_high direction specified according direction_var. instance, lab needed low direction , records flagged worst_flag_low selected. lab needed low high directions, worst low records selected low direction, worst high record selected high direction.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adlb_worsen.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to prepare ADLB with worst labs — h_adlb_worsen","text":"","code":"library(dplyr) # The direction variable, GRADDR, is based on metadata adlb <- tern_ex_adlb %>% mutate( GRADDR = case_when( PARAMCD == \"ALT\" ~ \"B\", PARAMCD == \"CRP\" ~ \"L\", PARAMCD == \"IGA\" ~ \"H\" ) ) %>% filter(SAFFL == \"Y\" & ONTRTFL == \"Y\" & GRADDR != \"\") df <- h_adlb_worsen( adlb, worst_flag_low = c(\"WGRLOFL\" = \"Y\"), worst_flag_high = c(\"WGRHIFL\" = \"Y\"), direction_var = \"GRADDR\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adsl_adlb_merge_using_worst_flag.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"Helper function merges ADSL ADLB datasets missing lab test records inserted output dataset. Remember na_level must match needed pre-processing done df_explicit_na() desired output.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"","code":"h_adsl_adlb_merge_using_worst_flag( adsl, adlb, worst_flag = c(WGRHIFL = \"Y\"), by_visit = FALSE, no_fillin_visits = c(\"SCREENING\", \"BASELINE\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"adsl (data.frame) ADSL data frame. adlb (data.frame) ADLB data frame. worst_flag (named character) worst post-baseline lab flag variable. See implemented following examples. by_visit (flag) defaults FALSE generate worst grade per patient. worst grade per patient per visit specified worst_flag, by_visit TRUE generate worst grade patient per visit. no_fillin_visits (named character) visits considered post-baseline worst toxicity grade. Defaults c(\"SCREENING\", \"BASELINE\").","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"df containing variables shared adlb adsl along variables PARAM, PARAMCD, ATOXGR, BTOXGR relevant analysis. Optionally, AVISIT AVISITN included by_visit = TRUE no_fillin_visits = c(\"SCREENING\", \"BASELINE\").","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"result data missing records created following situations: Patients present adsl lab data adlb (baseline post-baseline). Patients post-baseline lab values. Patients without post-baseline values flagged worst.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_adsl_adlb_merge_using_worst_flag.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for deriving analysis datasets for select laboratory tables — h_adsl_adlb_merge_using_worst_flag","text":"","code":"# `h_adsl_adlb_merge_using_worst_flag` adlb_out <- h_adsl_adlb_merge_using_worst_flag( tern_ex_adsl, tern_ex_adlb, worst_flag = c(\"WGRHIFL\" = \"Y\") ) # `h_adsl_adlb_merge_using_worst_flag` by visit example adlb_out_by_visit <- h_adsl_adlb_merge_using_worst_flag( tern_ex_adsl, tern_ex_adlb, worst_flag = c(\"WGRLOVFL\" = \"Y\"), by_visit = TRUE )"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ancova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to return results of a linear model — h_ancova","text":"","code":"h_ancova(.var, .df_row, variables, interaction_item = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ancova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to return results of a linear model — h_ancova","text":".var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) data set includes variables called .var variables. variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". interaction_item (string NULL) name variable interactions arm. interaction needed, default option NULL.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ancova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to return results of a linear model — h_ancova","text":"summary linear model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ancova.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to return results of a linear model — h_ancova","text":"","code":"h_ancova( .var = \"Sepal.Length\", .df_row = iris, variables = list(arm = \"Species\", covariates = c(\"Petal.Length * Petal.Width\", \"Sepal.Width\")) ) #> Species emmean SE df lower.CL upper.CL #> setosa 6.15 0.3370 143 5.49 6.82 #> versicolor 5.72 0.0668 143 5.59 5.85 #> virginica 5.41 0.1490 143 5.11 5.70 #> #> Confidence level used: 0.95"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_append_grade_groups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"Helper function s_count_occurrences_by_grade() insert grade groupings list individual grade frequencies. order final result follows order grade_groups. elements -grade group (), .e. grade group equal refs moved end. Grade groups names must unique.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_append_grade_groups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"","code":"h_append_grade_groups( grade_groups, refs, remove_single = TRUE, only_grade_groups = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_append_grade_groups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"grade_groups (named list character) list containing groupings grades. refs (named list numeric) named list name corresponds reference grade level entry represents count. remove_single (flag)TRUE include elements one-element grade groups output list; case grade groups names included output. only_grade_groups set TRUE argument ignored. only_grade_groups (flag) whether specified grade groups included, individual grade rows removed (TRUE), grades grade groups displayed (FALSE).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_append_grade_groups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"Formatted list grade groupings.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_append_grade_groups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for s_count_occurrences_by_grade() — h_append_grade_groups","text":"","code":"h_append_grade_groups( list( \"Any Grade\" = as.character(1:5), \"Grade 1-2\" = c(\"1\", \"2\"), \"Grade 3-4\" = c(\"3\", \"4\") ), list(\"1\" = 10, \"2\" = 20, \"3\" = 30, \"4\" = 40, \"5\" = 50) ) #> $`Any Grade` #> [1] 150 #> #> $`Grade 1-2` #> [1] 30 #> #> $`1` #> [1] 10 #> #> $`2` #> [1] 20 #> #> $`Grade 3-4` #> [1] 70 #> #> $`3` #> [1] 30 #> #> $`4` #> [1] 40 #> #> $`5` #> [1] 50 #> h_append_grade_groups( list( \"Any Grade\" = as.character(5:1), \"Grade A\" = \"5\", \"Grade B\" = c(\"4\", \"3\") ), list(\"1\" = 10, \"2\" = 20, \"3\" = 30, \"4\" = 40, \"5\" = 50) ) #> $`Any Grade` #> [1] 150 #> #> $`Grade A` #> [1] 50 #> #> $`Grade B` #> [1] 70 #> #> $`4` #> [1] 40 #> #> $`3` #> [1] 30 #> #> $`2` #> [1] 20 #> #> $`1` #> [1] 10 #> h_append_grade_groups( list( \"Any Grade\" = as.character(1:5), \"Grade 1-2\" = c(\"1\", \"2\"), \"Grade 3-4\" = c(\"3\", \"4\") ), list(\"1\" = 10, \"2\" = 5, \"3\" = 0) ) #> $`Any Grade` #> [1] 15 #> #> $`Grade 1-2` #> [1] 15 #> #> $`1` #> [1] 10 #> #> $`2` #> [1] 5 #> #> $`Grade 3-4` #> [1] 0 #> #> $`3` #> [1] 0 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_col_indices.html","id":null,"dir":"Reference","previous_headings":"","what":"Obtain column indices — h_col_indices","title":"Obtain column indices — h_col_indices","text":"Helper function extract column indices VTableTree given vector column names.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_col_indices.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Obtain column indices — h_col_indices","text":"","code":"h_col_indices(table_tree, col_names)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_col_indices.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Obtain column indices — h_col_indices","text":"table_tree (VTableTree)rtables table object extract indices . col_names (character) vector column names.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_col_indices.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Obtain column indices — h_col_indices","text":"vector column indices.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_count_cumulative.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for s_count_cumulative() — h_count_cumulative","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"Helper function calculate count fraction x values lower upper tail given threshold.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_count_cumulative.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"","code":"h_count_cumulative( x, threshold, lower_tail = TRUE, include_eq = TRUE, na.rm = TRUE, .N_col )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_count_cumulative.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"x (numeric) vector numbers want analyze. threshold (numeric(1)) cutoff value threshold count values x. lower_tail (flag) whether count lower tail, default TRUE. include_eq (flag) whether include value equal threshold count, default TRUE. na.rm (flag) whether NA values removed x prior analysis. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_count_cumulative.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"named vector items: count: count values less , less equal , greater , greater equal threshold user specification. fraction: fraction count.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_count_cumulative.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for s_count_cumulative() — h_count_cumulative","text":"","code":"set.seed(1, kind = \"Mersenne-Twister\") x <- c(sample(1:10, 10), NA) .N_col <- length(x) h_count_cumulative(x, 5, .N_col = .N_col) #> count fraction #> 5.0000000 0.4545455 h_count_cumulative(x, 5, lower_tail = FALSE, include_eq = FALSE, na.rm = FALSE, .N_col = .N_col) #> count fraction #> 6.0000000 0.5454545 h_count_cumulative(x, 0, lower_tail = FALSE, .N_col = .N_col) #> count fraction #> 10.0000000 0.9090909 h_count_cumulative(x, 100, lower_tail = FALSE, .N_col = .N_col) #> count fraction #> 0 0"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_cox_regression.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for Cox proportional hazards regression — h_cox_regression","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"Helper functions used fit_coxreg_univar() fit_coxreg_multivar().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_cox_regression.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"","code":"h_coxreg_univar_formulas(variables, interaction = FALSE) h_coxreg_multivar_formula(variables) h_coxreg_univar_extract(effect, covar, data, mod, control = control_coxreg()) h_coxreg_multivar_extract(var, data, mod, control = control_coxreg())"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_cox_regression.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"variables (named list string) list additional analysis variables. interaction (flag) TRUE, model includes interaction studied treatment candidate covariate. Note univariate models without treatment arm, multivariate models, interaction can used needs FALSE. effect (string) treatment variable. covar (string) name covariate model. data (data.frame) dataset containing variables summarize. mod (coxph) Cox regression model fitted survival::coxph(). control (list) list controls returned control_coxreg(). var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_cox_regression.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"h_coxreg_univar_formulas() returns character vector coercible formulas (e.g stats::.formula()). h_coxreg_multivar_formula() returns string coercible formula (e.g stats::.formula()). h_coxreg_univar_extract() returns data.frame variables effect, term, term_label, level, n, hr, lcl, ucl, pval. h_coxreg_multivar_extract() returns data.frame variables pval, hr, lcl, ucl, level, n, term, term_label.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_cox_regression.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"h_coxreg_univar_formulas(): Helper Cox regression formula. Creates list formulas. used internally fit_coxreg_univar() comparison univariate Cox regression models. h_coxreg_multivar_formula(): Helper multivariate Cox regression formula. Creates formulas string. used internally fit_coxreg_multivar() comparison multivariate Cox regression models. Interactions included multivariate Cox regression model. h_coxreg_univar_extract(): Utility function help tabulate result univariate Cox regression model. h_coxreg_multivar_extract(): Tabulation multivariate Cox regressions. Utility function help tabulate result multivariate Cox regression model treatment/covariate variable.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_cox_regression.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for Cox proportional hazards regression — h_cox_regression","text":"","code":"# `h_coxreg_univar_formulas` ## Simple formulas. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"X\", \"y\") ) ) #> ref #> \"survival::Surv(time, status) ~ armcd\" #> X #> \"survival::Surv(time, status) ~ armcd + X\" #> y #> \"survival::Surv(time, status) ~ armcd + y\" ## Addition of an optional strata. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"X\", \"y\"), strata = \"SITE\" ) ) #> ref #> \"survival::Surv(time, status) ~ armcd + strata(SITE)\" #> X #> \"survival::Surv(time, status) ~ armcd + X + strata(SITE)\" #> y #> \"survival::Surv(time, status) ~ armcd + y + strata(SITE)\" ## Inclusion of the interaction term. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"X\", \"y\"), strata = \"SITE\" ), interaction = TRUE ) #> ref #> \"survival::Surv(time, status) ~ armcd + strata(SITE)\" #> X #> \"survival::Surv(time, status) ~ armcd * X + strata(SITE)\" #> y #> \"survival::Surv(time, status) ~ armcd * y + strata(SITE)\" ## Only covariates fitted in separate models. h_coxreg_univar_formulas( variables = list( time = \"time\", event = \"status\", covariates = c(\"X\", \"y\") ) ) #> X y #> \"survival::Surv(time, status) ~ 1 + X\" \"survival::Surv(time, status) ~ 1 + y\" # `h_coxreg_multivar_formula` h_coxreg_multivar_formula( variables = list( time = \"AVAL\", event = \"event\", arm = \"ARMCD\", covariates = c(\"RACE\", \"AGE\") ) ) #> [1] \"survival::Surv(AVAL, event) ~ ARMCD + RACE + AGE\" # Addition of an optional strata. h_coxreg_multivar_formula( variables = list( time = \"AVAL\", event = \"event\", arm = \"ARMCD\", covariates = c(\"RACE\", \"AGE\"), strata = \"SITE\" ) ) #> [1] \"survival::Surv(AVAL, event) ~ ARMCD + RACE + AGE + strata(SITE)\" # Example without treatment arm. h_coxreg_multivar_formula( variables = list( time = \"AVAL\", event = \"event\", covariates = c(\"RACE\", \"AGE\"), strata = \"SITE\" ) ) #> [1] \"survival::Surv(AVAL, event) ~ 1 + RACE + AGE + strata(SITE)\" library(survival) dta_simple <- data.frame( time = c(5, 5, 10, 10, 5, 5, 10, 10), status = c(0, 0, 1, 0, 0, 1, 1, 1), armcd = factor(LETTERS[c(1, 1, 1, 1, 2, 2, 2, 2)], levels = c(\"A\", \"B\")), var1 = c(45, 55, 65, 75, 55, 65, 85, 75), var2 = c(\"F\", \"M\", \"F\", \"M\", \"F\", \"M\", \"F\", \"U\") ) mod <- coxph(Surv(time, status) ~ armcd + var1, data = dta_simple) result <- h_coxreg_univar_extract( effect = \"armcd\", covar = \"armcd\", mod = mod, data = dta_simple ) result #> effect term term_label level n hr lcl ucl #> 1 Treatment: armcd B vs control (A) B 8 6.551448 0.4606904 93.16769 #> pval #> 1 0.165209 mod <- coxph(Surv(time, status) ~ armcd + var1, data = dta_simple) result <- h_coxreg_multivar_extract( var = \"var1\", mod = mod, data = dta_simple ) result #> pval hr lcl ucl level n term term_label #> 2 0.4456195 0.9423284 0.808931 1.097724 var1 8 var1 var1"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_data_plot.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to tidy survival fit data — h_data_plot","title":"Helper function to tidy survival fit data — h_data_plot","text":"Convert survival fit data data frame designed plotting within g_km. starts broom::tidy() result, : Post-processes strata column factor. Extends stratum additional first row time 0 probability 1 downstream plot lines start coordinates. Adds censor column. Filters rows max_time.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_data_plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to tidy survival fit data — h_data_plot","text":"","code":"h_data_plot(fit_km, armval = \"All\", max_time = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_data_plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to tidy survival fit data — h_data_plot","text":"fit_km (survfit) result survival::survfit(). armval (string) used strata name treatment arm variable one level. Default \"\". max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_data_plot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to tidy survival fit data — h_data_plot","text":"tibble columns time, n.risk, n.event, n.censor, estimate, std.error, conf.high, conf.low, strata, censor.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_data_plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to tidy survival fit data — h_data_plot","text":"","code":"library(dplyr) library(survival) # Test with multiple arms tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_data_plot() #> # A tibble: 203 × 10 #> time n.risk n.event n.censor estimate std.error conf.high conf.low strata #> #> 1 0 70 0 0 1 0 1 1 ARM A #> 2 10.4 69 1 0 0.986 0.0146 1 0.958 ARM A #> 3 20.5 68 1 0 0.971 0.0208 1 0.932 ARM A #> 4 21.5 67 1 0 0.957 0.0257 1 0.910 ARM A #> 5 25.3 66 0 1 0.957 0.0257 1 0.910 ARM A #> 6 48.1 65 1 0 0.942 0.0300 0.999 0.888 ARM A #> 7 66.6 64 0 1 0.942 0.0300 0.999 0.888 ARM A #> 8 73.9 63 0 1 0.942 0.0300 0.999 0.888 ARM A #> 9 78.9 62 0 1 0.942 0.0300 0.999 0.888 ARM A #> 10 90.3 61 1 0 0.926 0.0342 0.991 0.866 ARM A #> # ℹ 193 more rows #> # ℹ 1 more variable: censor # Test with single arm tern_ex_adtte %>% filter(PARAMCD == \"OS\", ARMCD == \"ARM B\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_data_plot(armval = \"ARM B\") #> # A tibble: 74 × 10 #> time n.risk n.event n.censor estimate std.error conf.high conf.low strata #> #> 1 0 74 0 0 1 0 1 1 ARM B #> 2 2.17 73 1 0 0.986 0.0138 1 0.960 ARM B #> 3 16.9 72 1 0 0.973 0.0196 1 0.936 ARM B #> 4 22.6 71 1 0 0.959 0.0242 1 0.914 ARM B #> 5 26.3 70 1 0 0.945 0.0282 0.999 0.894 ARM B #> 6 57.5 69 1 0 0.932 0.0317 0.991 0.875 ARM B #> 7 80.0 68 1 0 0.918 0.0350 0.983 0.857 ARM B #> 8 81.6 67 1 0 0.904 0.0381 0.974 0.839 ARM B #> 9 88.6 66 1 0 0.890 0.0411 0.965 0.822 ARM B #> 10 102. 65 1 0 0.877 0.0439 0.955 0.804 ARM B #> # ℹ 64 more rows #> # ℹ 1 more variable: censor "},{"path":"https://insightsengineering.github.io/tern/main/reference/h_decompose_gg.html","id":null,"dir":"Reference","previous_headings":"","what":"ggplot decomposition — h_decompose_gg","title":"ggplot decomposition — h_decompose_gg","text":"elements composing ggplot extracted organized list.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_decompose_gg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ggplot decomposition — h_decompose_gg","text":"","code":"h_decompose_gg(gg)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_decompose_gg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"ggplot decomposition — h_decompose_gg","text":"gg (ggplot) graphic decompose.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_decompose_gg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"ggplot decomposition — h_decompose_gg","text":"named list elements: panel: panel. yaxis: y-axis. xaxis: x-axis. xlab: x-axis label. ylab: y-axis label. guide: legend.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_decompose_gg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"ggplot decomposition — h_decompose_gg","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, yval = \"Survival\", censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"tt\", footnotes = \"ff\" ) #> Warning: `h_ggkm()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. g_el <- h_decompose_gg(gg) #> Warning: `h_decompose_gg()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"red\", fill = \"gray85\", lwd = 5)) grid::grid.draw(g_el$panel) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"royalblue\", fill = \"gray85\", lwd = 5)) grid::grid.draw(with(g_el, cbind(ylab, yaxis))) # }"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_format_row.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"","code":"h_format_row(x, format, labels = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_format_row.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"x (named list) list numerical values formatted optionally labeled. Elements x must numeric vectors. format (named character NULL) format patterns x. Names format must match names x. parameter passed directly rtables::format_rcell function format parameter. labels (named character NULL) optional labels x. Names labels must match names x. label specified element x, function tries use label names (order) attribute element (depending one exists NULL NA NaN). none attributes attached given element x, label automatically generated.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_format_row.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"single row data.frame object.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_format_row.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to format the optional g_lineplot table — h_format_row","text":"","code":"mean_ci <- c(48, 51) x <- list(mean = 50, mean_ci = mean_ci) format <- c(mean = \"xx.x\", mean_ci = \"(xx.xx, xx.xx)\") labels <- c(mean = \"My Mean\") h_format_row(x, format, labels) #> My Mean V1 #> 1 50.0 (48.00, 51.00) attr(mean_ci, \"label\") <- \"Mean 95% CI\" x <- list(mean = 50, mean_ci = mean_ci) h_format_row(x, format, labels) #> My Mean Mean 95% CI #> 1 50.0 (48.00, 51.00)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_g_ipp.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create simple line plot over time — h_g_ipp","title":"Helper function to create simple line plot over time — h_g_ipp","text":"Function generates simple line plot displaying parameter trends time.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_g_ipp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create simple line plot over time — h_g_ipp","text":"","code":"h_g_ipp( df, xvar, yvar, xlab, ylab, id_var, title = \"Individual Patient Plots\", subtitle = \"\", caption = NULL, add_baseline_hline = FALSE, yvar_baseline = \"BASE\", ggtheme = nestcolor::theme_nest(), col = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_g_ipp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create simple line plot over time — h_g_ipp","text":"df (data.frame) data set containing analysis variables. xvar (string) time point variable plotted x-axis. yvar (string) continuous analysis variable plotted y-axis. xlab (string) plot label x-axis. ylab (string) plot label y-axis. id_var (string) variable used patient identifier. title (string) title plot. subtitle (string) subtitle plot. caption (string) optional caption plot. add_baseline_hline (flag) adds horizontal line baseline y-value plot TRUE. yvar_baseline (string) variable baseline values . Ignored add_baseline_hline FALSE. ggtheme (theme) optional graphical theme function provided ggplot2 control outlook plot. Use ggplot2::theme() tweak display. col (character) line colors.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_g_ipp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create simple line plot over time — h_g_ipp","text":"ggplot line plot.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_g_ipp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create simple line plot over time — h_g_ipp","text":"","code":"library(dplyr) # Select a small sample of data to plot. adlb <- tern_ex_adlb %>% filter(PARAMCD == \"ALT\", !(AVISIT %in% c(\"SCREENING\", \"BASELINE\"))) %>% slice(1:36) p <- h_g_ipp( df = adlb, xvar = \"AVISIT\", yvar = \"AVAL\", xlab = \"Visit\", id_var = \"USUBJID\", ylab = \"SGOT/ALT (U/L)\", add_baseline_hline = TRUE ) p"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ggkm.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create a KM plot — h_ggkm","title":"Helper function to create a KM plot — h_ggkm","text":"Draw Kaplan-Meier plot using ggplot2.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ggkm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create a KM plot — h_ggkm","text":"","code":"h_ggkm( data, xticks = NULL, yval = \"Survival\", censor_show, xlab, ylab, ylim = NULL, title, footnotes = NULL, max_time = NULL, lwd = 1, lty = NULL, pch = 3, size = 2, col = NULL, ci_ribbon = FALSE, ggtheme = nestcolor::theme_nest() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ggkm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create a KM plot — h_ggkm","text":"data (data.frame) survival data pre-processed h_data_plot. xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis. NULL (default), labeling::extended() used determine optimal tick positions x-axis. yval (string) type plot, plotted y-axis. Options Survival (default) Failure probability. censor_show (flag) whether show censored observations. xlab (string) x-axis label. ylab (string) y-axis label. ylim (numeric(2)) vector containing lower upper limits y-axis, respectively. NULL (default), default scale range used. title (string) plot title. footnotes (string) plot footnotes. max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL). lwd (numeric) line width. vector given, length equal number strata survival::survfit(). lty (numeric) line type. vector given, length equal number strata survival::survfit(). pch (string) name symbol character use point symbol indicate censored cases. size (numeric(1)) size censored point symbols. col (character) lines colors. Length vector equal number strata survival::survfit(). ci_ribbon (flag) whether confidence interval drawn around Kaplan-Meier curve. ggtheme (theme) graphical theme provided ggplot2 format Kaplan-Meier plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ggkm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create a KM plot — h_ggkm","text":"ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ggkm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create a KM plot — h_ggkm","text":"","code":"# \\donttest{ library(dplyr) library(survival) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", yval = \"Survival\", ylab = \"Survival Probability\", title = \"Survival\" ) gg # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_glm_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for Poisson models — h_glm_count","title":"Helper functions for Poisson models — h_glm_count","text":"Helper functions returns results stats::glm() Poisson Quasi-Poisson distributions needed (see family parameter), MASS::glm.nb() Negative Binomial distributions. Link function GLM log.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_glm_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for Poisson models — h_glm_count","text":"","code":"h_glm_count(.var, .df_row, variables, distribution, weights) h_glm_poisson(.var, .df_row, variables, weights) h_glm_quasipoisson(.var, .df_row, variables, weights) h_glm_negbin(.var, .df_row, variables, weights)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_glm_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for Poisson models — h_glm_count","text":".var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) dataset includes variables called .var variables. variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". offset (numeric) numeric vector scalar adding offset. distribution (character) character value specifying distribution used regression (Poisson, Quasi-Poisson, negative binomial). weights (character) character vector specifying weights used averaging predictions. Number weights must equal number levels included covariates. Weights option passed emmeans::emmeans().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_glm_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for Poisson models — h_glm_count","text":"h_glm_count() returns results selected model. h_glm_poisson() returns results Poisson model. h_glm_quasipoisson() returns results Quasi-Poisson model. h_glm_negbin() returns results negative binomial model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_glm_count.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for Poisson models — h_glm_count","text":"h_glm_count(): Helper function return results selected model (Poisson, Quasi-Poisson, negative binomial). h_glm_poisson(): Helper function return results Poisson model. h_glm_quasipoisson(): Helper function return results Quasi-Poisson model. h_glm_negbin(): Helper function return results negative binomial model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_coxph.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create Cox-PH grobs — h_grob_coxph","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"Grob rtable output h_tbl_coxph_pairwise()","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_coxph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"","code":"h_grob_coxph( ..., x = 0, y = 0, width = grid::unit(0.4, \"npc\"), ttheme = gridExtra::ttheme_default(padding = grid::unit(c(1, 0.5), \"lines\"), core = list(bg_params = list(fill = c(\"grey95\", \"grey90\"), alpha = 0.5))) )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_coxph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"... arguments pass h_tbl_coxph_pairwise(). x (proportion) value 0 1 specifying x-location. y (proportion) value 0 1 specifying y-location. width (grid::unit) width (unit) use printing grob. ttheme (list) see gridExtra::ttheme_default().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_coxph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"grob table containing statistics HR, XX% CI (XX taken control_coxph_pw), p-value (log-rank).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_coxph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create Cox-PH grobs — h_grob_coxph","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"pink\", fill = \"gray85\", lwd = 1)) data <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) tbl_grob <- h_grob_coxph( df = data, variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARMCD\"), control_coxph_pw = control_coxph(conf_level = 0.9), x = 0.5, y = 0.5 ) #> Warning: `h_grob_coxph()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid::grid.draw(tbl_grob) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_median_surv.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create survival estimation grobs — h_grob_median_surv","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"survival fit transformed grob containing table groups rows characterized N, median 95% confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_median_surv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"","code":"h_grob_median_surv( fit_km, armval = \"All\", x = 0.9, y = 0.9, width = grid::unit(0.3, \"npc\"), ttheme = gridExtra::ttheme_default() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_median_surv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"fit_km (survfit) result survival::survfit(). armval (string) used strata name treatment arm variable one level. Default \"\". x (proportion) value 0 1 specifying x-location. y (proportion) value 0 1 specifying y-location. width (grid::unit) width (unit) use printing grob. ttheme (list) see gridExtra::ttheme_default().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_median_surv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"grob table containing statistics N, Median, XX% CI (XX taken fit_km).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_median_surv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create survival estimation grobs — h_grob_median_surv","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = \"pink\", fill = \"gray85\", lwd = 1)) tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_grob_median_surv() %>% grid::grid.draw() #> Warning: `h_grob_median_surv()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_tbl_at_risk.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"Two graphical objects obtained, one corresponding row labeling second table numbers patients risk. title = TRUE, third object corresponding table title also obtained.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_tbl_at_risk.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"","code":"h_grob_tbl_at_risk(data, annot_tbl, xlim, title = TRUE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_tbl_at_risk.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"data (data.frame) survival data pre-processed h_data_plot. annot_tbl (data.frame) annotation prepared survival::summary.survfit() includes number patients risk given time points. xlim (numeric(1)) maximum value x-axis (used ensure risk table aligns KM graph). title (flag) whether \"Patients Risk\" title added annot_at_risk table. effect annot_at_risk FALSE. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_tbl_at_risk.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"named list two gTree objects title = FALSE: at_risk label, three gTree objects title = TRUE: at_risk, label, title.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_tbl_at_risk.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create patient-at-risk grobs — h_grob_tbl_at_risk","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"tt\", footnotes = \"ff\", yval = \"Survival\" ) # The annotation table reports the patient at risk for a given strata and # times (`xticks`). annot_tbl <- summary(fit_km, times = xticks) if (is.null(fit_km$strata)) { annot_tbl <- with(annot_tbl, data.frame(n.risk = n.risk, time = time, strata = \"All\")) } else { strata_lst <- strsplit(sub(\"=\", \"equals\", levels(annot_tbl$strata)), \"equals\") levels(annot_tbl$strata) <- matrix(unlist(strata_lst), ncol = 2, byrow = TRUE)[, 2] annot_tbl <- data.frame( n.risk = annot_tbl$n.risk, time = annot_tbl$time, strata = annot_tbl$strata ) } # The annotation table is transformed into a grob. tbl <- h_grob_tbl_at_risk(data = data_plot, annot_tbl = annot_tbl, xlim = max(xticks)) #> Warning: `h_grob_tbl_at_risk()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. # For the representation, the layout is estimated for which the decomposition # of the graphic element is necessary. g_el <- h_decompose_gg(gg) lyt <- h_km_layout(data = data_plot, g_el = g_el, title = \"t\", footnotes = \"f\") #> Warning: `h_km_layout()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid::grid.newpage() pushViewport(viewport(layout = lyt, height = .95, width = .95)) grid.rect(gp = grid::gpar(lty = 1, col = \"purple\", fill = \"gray85\", lwd = 1)) pushViewport(viewport(layout.pos.row = 3:4, layout.pos.col = 2)) grid.rect(gp = grid::gpar(lty = 1, col = \"orange\", fill = \"gray85\", lwd = 1)) grid::grid.draw(tbl$at_risk) popViewport() pushViewport(viewport(layout.pos.row = 3:4, layout.pos.col = 1)) grid.rect(gp = grid::gpar(lty = 1, col = \"green3\", fill = \"gray85\", lwd = 1)) grid::grid.draw(tbl$label) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_y_annot.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"Build y-axis annotation decomposed ggplot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_y_annot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"","code":"h_grob_y_annot(ylab, yaxis)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_y_annot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"ylab (gtable) y-lab graphical object derived ggplot. yaxis (gtable) y-axis graphical object derived ggplot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_y_annot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"gTree object containing y-axis annotation ggplot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_grob_y_annot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create grid object with y-axis annotation — h_grob_y_annot","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"title\", footnotes = \"footnotes\", yval = \"Survival\" ) g_el <- h_decompose_gg(gg) grid::grid.newpage() pvp <- grid::plotViewport(margins = c(5, 4, 2, 20)) pushViewport(pvp) grid::grid.draw(h_grob_y_annot(ylab = g_el$ylab, yaxis = g_el$yaxis)) #> Warning: `h_grob_y_annot()` was deprecated in tern 0.9.4. #> ℹ `g_km` now generates `ggplot` objects. This function is no longer used within #> `tern`. grid.rect(gp = grid::gpar(lty = 1, col = \"gray35\", fill = NA)) # }"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_incidence_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for incidence rate — h_incidence_rate","text":"","code":"h_incidence_rate(person_years, n_events, control = control_incidence_rate()) h_incidence_rate_normal(person_years, n_events, alpha = 0.05) h_incidence_rate_normal_log(person_years, n_events, alpha = 0.05) h_incidence_rate_exact(person_years, n_events, alpha = 0.05) h_incidence_rate_byar(person_years, n_events, alpha = 0.05)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_incidence_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for incidence rate — h_incidence_rate","text":"person_years (numeric(1)) total person-years risk. n_events (integer(1)) number events observed. control (list) parameters estimation details, specified using helper function control_incidence_rate(). Possible parameter options : conf_level: (proportion) confidence level estimated incidence rate. conf_type: (string)normal (default), normal_log, exact, byar confidence interval type. input_time_unit: (string)day, week, month, year (default) indicating time unit data input. num_pt_year: (numeric) time unit desired output (person-years). alpha (numeric(1)) two-sided alpha-level confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_incidence_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for incidence rate — h_incidence_rate","text":"Estimated incidence rate, rate, associated confidence interval, rate_ci.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_incidence_rate.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for incidence rate — h_incidence_rate","text":"h_incidence_rate(): Helper function estimate incidence rate associated confidence interval. h_incidence_rate_normal(): Helper function estimate incidence rate associated confidence interval based normal approximation incidence rate. Unit one person-year. h_incidence_rate_normal_log(): Helper function estimate incidence rate associated confidence interval based normal approximation logarithm incidence rate. Unit one person-year. h_incidence_rate_exact(): Helper function estimate incidence rate associated exact confidence interval. Unit one person-year. h_incidence_rate_byar(): Helper function estimate incidence rate associated Byar's confidence interval. Unit one person-year.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_incidence_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for incidence rate — h_incidence_rate","text":"","code":"h_incidence_rate_normal(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] -0.003859038 0.023859038 #> h_incidence_rate_normal_log(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] 0.002500977 0.039984382 #> h_incidence_rate_exact(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] 0.001211046 0.036123438 #> h_incidence_rate_byar(200, 2) #> $rate #> [1] 0.01 #> #> $rate_ci #> [1] 0.001994207 0.032054171 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_km_layout.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to prepare a KM layout — h_km_layout","title":"Helper function to prepare a KM layout — h_km_layout","text":"Prepares (5 rows) x (2 cols) layout Kaplan-Meier curve.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_km_layout.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to prepare a KM layout — h_km_layout","text":"","code":"h_km_layout( data, g_el, title, footnotes, annot_at_risk = TRUE, annot_at_risk_title = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_km_layout.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to prepare a KM layout — h_km_layout","text":"data (data.frame) survival data pre-processed h_data_plot. g_el (list gtable) list obtained h_decompose_gg(). title (string) plot title. footnotes (string) plot footnotes. annot_at_risk (flag) compute add annotation table reporting number patient risk matching main grid Kaplan-Meier curve. annot_at_risk_title (flag) whether \"Patients Risk\" title added annot_at_risk table. effect annot_at_risk FALSE. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_km_layout.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to prepare a KM layout — h_km_layout","text":"grid layout.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_km_layout.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper function to prepare a KM layout — h_km_layout","text":"layout corresponds grid two columns five rows unequal dimensions. dimension fixed, curve flexible accommodate remaining free space. left column gets annotation ggplot (y-axis) names strata patient risk tabulation. main constraint width columns must allow writing strata name. right column receive ggplot, legend, x-axis patient risk table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_km_layout.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to prepare a KM layout — h_km_layout","text":"","code":"# \\donttest{ library(dplyr) library(survival) library(grid) fit_km <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) xticks <- h_xticks(data = data_plot) gg <- h_ggkm( data = data_plot, censor_show = TRUE, xticks = xticks, xlab = \"Days\", ylab = \"Survival Probability\", title = \"tt\", footnotes = \"ff\", yval = \"Survival\" ) g_el <- h_decompose_gg(gg) lyt <- h_km_layout(data = data_plot, g_el = g_el, title = \"t\", footnotes = \"f\") grid.show.layout(lyt) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for multivariate logistic regression — h_logistic_regression","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"Helper functions used calculations logistic regression.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"","code":"h_get_interaction_vars(fit_glm) h_interaction_coef_name( interaction_vars, first_var_with_level, second_var_with_level ) h_or_cat_interaction( odds_ratio_var, interaction_var, fit_glm, conf_level = 0.95 ) h_or_cont_interaction( odds_ratio_var, interaction_var, fit_glm, at = NULL, conf_level = 0.95 ) h_or_interaction( odds_ratio_var, interaction_var, fit_glm, at = NULL, conf_level = 0.95 ) h_simple_term_labels(terms, table) h_interaction_term_labels(terms1, terms2, table, any = FALSE) h_glm_simple_term_extract(x, fit_glm) h_glm_interaction_extract(x, fit_glm) h_glm_inter_term_extract(odds_ratio_var, interaction_var, fit_glm, ...) h_logistic_simple_terms(x, fit_glm, conf_level = 0.95) h_logistic_inter_terms(x, fit_glm, conf_level = 0.95, at = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"fit_glm (glm) logistic regression model fitted stats::glm() \"binomial\" family. Limited functionality also available conditional logistic regression models fitted survival::clogit(), currently used extract_rsp_biomarkers(). interaction_vars (character(2)) interaction variable names. first_var_with_level (character(2)) first variable name interaction level. second_var_with_level (character(2)) second variable name interaction level. odds_ratio_var (string) odds ratio variable. interaction_var (string) interaction variable. conf_level (proportion) confidence level interval. (numeric NULL) optional values interaction variable. Otherwise median used. terms (character) simple terms. table (table) table containing numbers terms. terms1 (character) terms first dimension (rows). terms2 (character) terms second dimension (rows). (flag) whether term1 term2 can fulfilled count number patients. case can scalar (strings). x (character) variable interaction term fit_glm (depending helper function used). ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"Vector names interaction variables. Name coefficient. Odds ratio. Odds ratio. Odds ratio. Term labels containing numbers patients. Term labels containing numbers patients. Tabulated main effect results logistic regression model. Tabulated interaction term results logistic regression model. data.frame tabulated interaction term results logistic regression model. Tabulated statistics given variable(s) logistic regression model. Tabulated statistics given variable(s) logistic regression model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"h_get_interaction_vars(): Helper function extract interaction variable names fitted model assuming one interaction term. h_interaction_coef_name(): Helper function get right coefficient name interaction variable names given levels. main value order first second variable checked interaction_vars input. h_or_cat_interaction(): Helper function calculate odds ratio estimates case odds ratio interaction variable categorical. h_or_cont_interaction(): Helper function calculate odds ratio estimates case either odds ratio interaction variable continuous. h_or_interaction(): Helper function calculate odds ratio estimates case interaction. wrapper h_or_cont_interaction() h_or_cat_interaction(). h_simple_term_labels(): Helper function construct term labels simple terms table numbers patients. h_interaction_term_labels(): Helper function construct term labels interaction terms table numbers patients. h_glm_simple_term_extract(): Helper function tabulate main effect results (conditional) logistic regression model. h_glm_interaction_extract(): Helper function tabulate interaction term results logistic regression model. h_glm_inter_term_extract(): Helper function tabulate interaction results logistic regression model. basically wrapper h_or_interaction() h_glm_simple_term_extract() puts results right data frame format. h_logistic_simple_terms(): Helper function tabulate results including odds ratios confidence intervals simple terms. h_logistic_inter_terms(): Helper function tabulate results including odds ratios confidence intervals interaction terms.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"provide function case variables continuous arise table, treatment arm variable always involved categorical.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_logistic_regression.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for multivariate logistic regression — h_logistic_regression","text":"","code":"library(dplyr) library(broom) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred h_glm_simple_term_extract(\"AGE\", mod1) #> variable variable_label term term_label interaction interaction_label #> 1 AGE Age AGE Age #> reference reference_label estimate std_error df pvalue #> 1 0.1698216 0.09524116 1 0.07457501 #> is_variable_summary is_term_summary #> 1 FALSE TRUE h_glm_simple_term_extract(\"ARMCD\", mod1) #> variable variable_label term term_label interaction #> 1 ARMCD Planned Arm Code ARM A Reference ARM A, n = 64 #> 2 ARMCD Planned Arm Code ARM B ARM B, n = 68 #> 3 ARMCD Planned Arm Code ARM C ARM C, n = 52 #> interaction_label reference reference_label estimate std_error df pvalue #> 1 2 0.3004308 #> 2 -1.774769 1.144405 1 0.1209443 #> 3 17.1922 3626.588 1 0.9962176 #> is_variable_summary is_term_summary #> 1 TRUE FALSE #> 2 FALSE TRUE #> 3 FALSE TRUE h_glm_interaction_extract(\"ARMCD:AGE\", mod2) #> variable variable_label term term_label #> 1 ARMCD:AGE Interaction of Planned Arm Code * Age ARM A Reference ARM A, n = 64 #> 2 ARMCD:AGE Interaction of Planned Arm Code * Age ARM B ARM B, n = 68 #> 3 ARMCD:AGE Interaction of Planned Arm Code * Age ARM C ARM C, n = 52 #> interaction interaction_label reference reference_label estimate std_error #> 1 #> 2 0.3081205 0.2062392 #> 3 0.02948826 548.5923 #> df pvalue is_variable_summary is_term_summary #> 1 2 0.3275837 TRUE FALSE #> 2 1 0.1351767 FALSE TRUE #> 3 1 0.9999571 FALSE TRUE h_glm_inter_term_extract(\"AGE\", \"ARMCD\", mod2) #> variable variable_label term term_label interaction interaction_label #> 1 AGE Age AGE Age #> 2 AGE Age AGE Age ARMCD Planned Arm Code #> 3 AGE Age AGE Age ARMCD Planned Arm Code #> 4 AGE Age AGE Age ARMCD Planned Arm Code #> reference reference_label estimate std_error odds_ratio lcl ucl #> 1 -0.03873898 0.1514322 NA NA NA #> 2 ARM A ARM A NA NA 0.9620018 0.7149514 1.294420 #> 3 ARM B ARM B NA NA 1.3091545 1.0021802 1.710157 #> 4 ARM C ARM C NA NA 0.9907919 0.0000000 Inf #> df pvalue is_variable_summary is_term_summary is_reference_summary #> 1 1 0.798092 FALSE TRUE FALSE #> 2 NA NA FALSE FALSE TRUE #> 3 NA NA FALSE FALSE TRUE #> 4 NA NA FALSE FALSE TRUE h_logistic_simple_terms(\"AGE\", mod1) #> variable variable_label term term_label interaction interaction_label #> 1 AGE Age AGE Age #> reference reference_label estimate std_error df pvalue #> 1 0.1698216 0.09524116 1 0.07457501 #> is_variable_summary is_term_summary odds_ratio lcl ucl #> 1 FALSE TRUE 1.185093 0.9832935 1.428308 #> ci #> 1 0.9832935, 1.4283084 h_logistic_inter_terms(c(\"RACE\", \"AGE\", \"ARMCD\", \"AGE:ARMCD\"), mod2) #> variable variable_label term #> 1 RACE Race ASIAN #> 2 RACE Race BLACK OR AFRICAN AMERICAN #> 3 RACE Race WHITE #> 13 ARMCD Planned Arm Code ARM A #> 23 ARMCD Planned Arm Code ARM B #> ARM B ARMCD Planned Arm Code ARM B #> 33 ARMCD Planned Arm Code ARM C #> ARM C ARMCD Planned Arm Code ARM C #> 11 AGE Age AGE #> 21 AGE Age AGE #> 31 AGE Age AGE #> 4 AGE Age AGE #> 12 AGE:ARMCD Interaction of Planned Arm Code * Age ARM A #> 22 AGE:ARMCD Interaction of Planned Arm Code * Age ARM B #> 32 AGE:ARMCD Interaction of Planned Arm Code * Age ARM C #> term_label interaction interaction_label reference #> 1 Reference ASIAN, n = 110 #> 2 BLACK OR AFRICAN AMERICAN, n = 40 #> 3 WHITE, n = 34 #> 13 Reference ARM A, n = 64 #> 23 ARM B, n = 68 #> ARM B ARM B, n = 68 AGE Age 35 #> 33 ARM C, n = 52 #> ARM C ARM C, n = 52 AGE Age 35 #> 11 Age #> 21 Age ARMCD Planned Arm Code ARM A #> 31 Age ARMCD Planned Arm Code ARM B #> 4 Age ARMCD Planned Arm Code ARM C #> 12 Reference ARM A, n = 64 #> 22 ARM B, n = 68 #> 32 ARM C, n = 52 #> reference_label estimate std_error df pvalue odds_ratio lcl #> 1 2 0.9361139 #> 2 18.15018 3944.701 1 0.9963288 76299564 0 #> 3 -0.3727152 1.025808 1 0.7163522 0.6888614 0.09224926 #> 13 2 0.253914 NA NA #> 23 -11.52715 6.96188 1 0.09777185 NA NA #> ARM B 35 NA NA NA NA 0.4757148 0.03361147 #> 33 16.33327 20278.39 1 0.9993573 NA NA #> ARM C 35 NA NA NA NA 34808099 0 #> 11 -0.03873898 0.1514322 1 0.798092 NA NA #> 21 ARM A NA NA NA NA 0.9620018 0.7149514 #> 31 ARM B NA NA NA NA 1.309155 1.00218 #> 4 ARM C NA NA NA NA 0.9907919 0 #> 12 NA NA NA NA #> 22 0.3081205 0.2062392 1 0.1351767 NA NA #> 32 0.02948826 548.5923 1 0.9999571 NA NA #> ucl is_variable_summary is_term_summary is_reference_summary #> 1 TRUE FALSE FALSE #> 2 Inf FALSE TRUE FALSE #> 3 5.143998 FALSE TRUE FALSE #> 13 NA TRUE FALSE FALSE #> 23 NA FALSE TRUE FALSE #> ARM B 6.732956 FALSE FALSE TRUE #> 33 NA FALSE TRUE FALSE #> ARM C Inf FALSE FALSE TRUE #> 11 NA FALSE TRUE FALSE #> 21 1.29442 FALSE FALSE TRUE #> 31 1.710157 FALSE FALSE TRUE #> 4 Inf FALSE FALSE TRUE #> 12 NA TRUE FALSE FALSE #> 22 NA FALSE TRUE FALSE #> 32 NA FALSE TRUE FALSE #> ci #> 1 #> 2 0, Inf #> 3 0.09224926, 5.14399810 #> 13 NA, NA #> 23 NA, NA #> ARM B 0.03361147, 6.73295611 #> 33 NA, NA #> ARM C 0, Inf #> 11 NA, NA #> 21 0.7149514, 1.2944200 #> 31 1.002180, 1.710157 #> 4 0, Inf #> 12 NA, NA #> 22 NA, NA #> 32 NA, NA"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_map_for_count_abnormal.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"Helper function create map data frame input dataset, can used argument trim_levels_to_map split function. Based different method, map constructed differently.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_map_for_count_abnormal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"","code":"h_map_for_count_abnormal( df, variables = list(anl = \"ANRIND\", split_rows = c(\"PARAM\"), range_low = \"ANRLO\", range_high = \"ANRHI\"), abnormal = list(low = c(\"LOW\", \"LOW LOW\"), high = c(\"HIGH\", \"HIGH HIGH\")), method = c(\"default\", \"range\"), na_str = \"\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_map_for_count_abnormal.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"df (data.frame) data set containing analysis variables. variables (named list string) list additional analysis variables. abnormal (named list) identifying abnormal range level(s) df. Based levels abnormality input dataset, can something like list(Low = \"LOW LOW\", High = \"HIGH HIGH\") abnormal = list(Low = \"LOW\", High = \"HIGH\")) method (string) indicates returned map constructed. Can \"default\" \"range\". na_str (string) string used replace NA empty values output.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_map_for_count_abnormal.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"map data.frame.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_map_for_count_abnormal.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"method \"default\", returned map abnormal directions observed df, records normal values excluded avoid error creating layout. method \"range\", returned map based rule least one observation low range > 0 low direction least one observation high range missing high direction.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_map_for_count_abnormal.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create a map data frame for trim_levels_to_map() — h_map_for_count_abnormal","text":"","code":"adlb <- df_explicit_na(tern_ex_adlb) h_map_for_count_abnormal( df = adlb, variables = list(anl = \"ANRIND\", split_rows = c(\"LBCAT\", \"PARAM\")), abnormal = list(low = c(\"LOW\"), high = c(\"HIGH\")), method = \"default\", na_str = \"\" ) #> LBCAT PARAM ANRIND #> 1 CHEMISTRY Alanine Aminotransferase Measurement LOW #> 4 CHEMISTRY Alanine Aminotransferase Measurement HIGH #> 7 CHEMISTRY Alanine Aminotransferase Measurement NORMAL #> 2 CHEMISTRY C-Reactive Protein Measurement LOW #> 3 CHEMISTRY C-Reactive Protein Measurement HIGH #> 8 CHEMISTRY C-Reactive Protein Measurement NORMAL #> 5 IMMUNOLOGY Immunoglobulin A Measurement LOW #> 6 IMMUNOLOGY Immunoglobulin A Measurement HIGH #> 9 IMMUNOLOGY Immunoglobulin A Measurement NORMAL df <- data.frame( USUBJID = c(rep(\"1\", 4), rep(\"2\", 4), rep(\"3\", 4)), AVISIT = c( rep(\"WEEK 1\", 2), rep(\"WEEK 2\", 2), rep(\"WEEK 1\", 2), rep(\"WEEK 2\", 2), rep(\"WEEK 1\", 2), rep(\"WEEK 2\", 2) ), PARAM = rep(c(\"ALT\", \"CPR\"), 6), ANRIND = c( \"NORMAL\", \"NORMAL\", \"LOW\", \"HIGH\", \"LOW\", \"LOW\", \"HIGH\", \"HIGH\", rep(\"NORMAL\", 4) ), ANRLO = rep(5, 12), ANRHI = rep(20, 12) ) df$ANRIND <- factor(df$ANRIND, levels = c(\"LOW\", \"HIGH\", \"NORMAL\")) h_map_for_count_abnormal( df = df, variables = list( anl = \"ANRIND\", split_rows = c(\"PARAM\"), range_low = \"ANRLO\", range_high = \"ANRHI\" ), abnormal = list(low = c(\"LOW\"), high = c(\"HIGH\")), method = \"range\", na_str = \"\" ) #> PARAM ANRIND #> 1 ALT LOW #> 3 ALT HIGH #> 5 ALT NORMAL #> 2 CPR LOW #> 4 CPR HIGH #> 6 CPR NORMAL"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_odds_ratio.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for odds ratio estimation — h_odds_ratio","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"Functions calculate odds ratios estimate_odds_ratio().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_odds_ratio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"","code":"or_glm(data, conf_level) or_clogit(data, conf_level, method = \"exact\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_odds_ratio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"data (data.frame) data frame containing least variables rsp grp, optionally strata or_clogit(). conf_level (proportion) confidence level interval. method (string) whether use correct (\"exact\") calculation conditional likelihood one approximations. See survival::clogit() details.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_odds_ratio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"named list elements or_ci n_tot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_odds_ratio.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"or_glm(): Estimates odds ratio based stats::glm(). Note must exactly 2 groups data specified grp variable. or_clogit(): Estimates odds ratio based survival::clogit(). done whole data set including groups, since results pairwise comparisons groups.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_odds_ratio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for odds ratio estimation — h_odds_ratio","text":"","code":"# Data with 2 groups. data <- data.frame( rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1)), grp = letters[c(1, 1, 1, 2, 2, 2, 1, 2)], strata = letters[c(1, 2, 1, 2, 2, 2, 1, 2)], stringsAsFactors = TRUE ) # Odds ratio based on glm. or_glm(data, conf_level = 0.95) #> $or_ci #> est lcl ucl #> 0.33333333 0.01669735 6.65441589 #> #> $n_tot #> n_tot #> 8 #> # Data with 3 groups. data <- data.frame( rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)), grp = letters[c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3)], strata = LETTERS[c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)], stringsAsFactors = TRUE ) # Odds ratio based on stratified estimation by conditional logistic regression. or_clogit(data, conf_level = 0.95) #> $or_ci #> $or_ci$b #> est lcl ucl #> 0.28814553 0.02981009 2.78522598 #> #> $or_ci$c #> est lcl ucl #> 0.5367919 0.0673365 4.2791881 #> #> #> $n_tot #> n_tot #> 20 #>"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_pkparam_sort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"","code":"h_pkparam_sort(pk_data, key_var = \"PARAMCD\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_pkparam_sort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"pk_data (data.frame) pharmacokinetic data frame. key_var (string) key variable used merge pk_data metadata created d_pkparam().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_pkparam_sort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"pharmacokinetic data.frame sorted PARAM variable.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_pkparam_sort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sort pharmacokinetic data by PARAM variable — h_pkparam_sort","text":"","code":"library(dplyr) adpp <- tern_ex_adpp %>% mutate(PKPARAM = factor(paste0(PARAM, \" (\", AVALU, \")\"))) pk_ordered_data <- h_pkparam_sort(adpp)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ppmeans.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to return the estimated means using predicted probabilities — h_ppmeans","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"arm level, predicted mean rate calculated using fitted model object, newdata set result stats::model.frame, reconstructed data original data, depending object formula (coming fit). confidence interval derived using conf_level parameter.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ppmeans.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"","code":"h_ppmeans(obj, .df_row, arm, conf_level)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ppmeans.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"obj (glm.fit) fitted model object used derive mean rate estimates treatment arm. .df_row (data.frame) dataset includes variables called .var variables. arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. conf_level (proportion) value used derive confidence interval rate.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_ppmeans.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to return the estimated means using predicted probabilities — h_ppmeans","text":"h_ppmeans() returns estimated means.","code":""},{"path":[]},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"","code":"prop_diff_wald(rsp, grp, conf_level = 0.95, correct = FALSE) prop_diff_ha(rsp, grp, conf_level) prop_diff_nc(rsp, grp, conf_level, correct = FALSE) prop_diff_cmh(rsp, grp, strata, conf_level = 0.95) prop_diff_strat_nc( rsp, grp, strata, weights_method = c(\"cmh\", \"wilson_h\"), conf_level = 0.95, correct = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"rsp (logical) vector indicating whether subject responder . grp (factor) vector assigning observations one two groups (e.g. reference treatment group). conf_level (proportion) confidence level interval. correct (flag) whether include continuity correction. information, see stats::prop.test(). strata (factor) variable one level per stratum length rsp. weights_method (string) weights method. Can either \"cmh\" \"heuristic\" directs way weights estimated.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"named list elements diff (proportion difference) diff_ci (proportion difference confidence interval).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"prop_diff_wald(): Wald interval follows usual textbook definition single proportion confidence interval using normal approximation. possible include continuity correction Wald's interval. prop_diff_ha(): Anderson-Hauck confidence interval. prop_diff_nc(): Newcombe confidence interval. based Wilson score confidence interval single binomial proportion. prop_diff_cmh(): Calculates weighted difference. defined difference response rates experimental treatment group control treatment group, adjusted stratification factors applying Cochran-Mantel-Haenszel (CMH) weights. CMH chi-squared test, use stats::mantelhaen.test(). prop_diff_strat_nc(): Calculates stratified Newcombe confidence interval difference response rates experimental treatment group control treatment group, adjusted stratification factors. implementation follows closely one proposed Yan2010-jt;textualtern. Weights can estimated heuristic proposed prop_strat_wilson() CMH-derived weights (see prop_diff_cmh()).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"Yan2010-jttern","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions to calculate proportion difference — h_prop_diff","text":"","code":"# Wald confidence interval set.seed(2) rsp <- sample(c(TRUE, FALSE), replace = TRUE, size = 20) grp <- factor(c(rep(\"A\", 10), rep(\"B\", 10))) prop_diff_wald(rsp = rsp, grp = grp, conf_level = 0.95, correct = FALSE) #> $diff #> [1] 0 #> #> $diff_ci #> [1] -0.4382613 0.4382613 #> # Anderson-Hauck confidence interval ## \"Mid\" case: 3/4 respond in group A, 1/2 respond in group B. rsp <- c(TRUE, FALSE, FALSE, TRUE, TRUE, TRUE) grp <- factor(c(\"A\", \"B\", \"A\", \"B\", \"A\", \"A\"), levels = c(\"B\", \"A\")) prop_diff_ha(rsp = rsp, grp = grp, conf_level = 0.90) #> $diff #> [1] 0.25 #> #> $diff_ci #> [1] -0.9195011 1.0000000 #> ## Edge case: Same proportion of response in A and B. rsp <- c(TRUE, FALSE, TRUE, FALSE) grp <- factor(c(\"A\", \"A\", \"B\", \"B\"), levels = c(\"A\", \"B\")) prop_diff_ha(rsp = rsp, grp = grp, conf_level = 0.6) #> $diff #> [1] 0 #> #> $diff_ci #> [1] -0.8451161 0.8451161 #> # Newcombe confidence interval set.seed(1) rsp <- c( sample(c(TRUE, FALSE), size = 40, prob = c(3 / 4, 1 / 4), replace = TRUE), sample(c(TRUE, FALSE), size = 40, prob = c(1 / 2, 1 / 2), replace = TRUE) ) grp <- factor(rep(c(\"A\", \"B\"), each = 40), levels = c(\"B\", \"A\")) table(rsp, grp) #> grp #> rsp B A #> FALSE 20 10 #> TRUE 20 30 prop_diff_nc(rsp = rsp, grp = grp, conf_level = 0.9) #> $diff #> [1] 0.25 #> #> $diff_ci #> [1] 0.07193388 0.40725819 #> # Cochran-Mantel-Haenszel confidence interval set.seed(2) rsp <- sample(c(TRUE, FALSE), 100, TRUE) grp <- sample(c(\"Placebo\", \"Treatment\"), 100, TRUE) grp <- factor(grp, levels = c(\"Placebo\", \"Treatment\")) strata_data <- data.frame( \"f1\" = sample(c(\"a\", \"b\"), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), stringsAsFactors = TRUE ) prop_diff_cmh( rsp = rsp, grp = grp, strata = interaction(strata_data), conf_level = 0.90 ) #> $prop #> Placebo Treatment #> 0.5331117 0.3954251 #> #> $prop_ci #> $prop_ci$Placebo #> [1] 0.4306536 0.6355698 #> #> $prop_ci$Treatment #> [1] 0.2890735 0.5017768 #> #> #> $diff #> [1] -0.1376866 #> #> $diff_ci #> [1] -0.285363076 0.009989872 #> #> $weights #> a.x b.x a.y b.y a.z b.z #> 0.1148388 0.2131696 0.1148388 0.2131696 0.1767914 0.1671918 #> #> $n1 #> a.x b.x a.y b.y a.z b.z #> 4 11 8 11 13 11 #> #> $n2 #> a.x b.x a.y b.y a.z b.z #> 8 9 4 9 6 6 #> # Stratified Newcombe confidence interval set.seed(2) data_set <- data.frame( \"rsp\" = sample(c(TRUE, FALSE), 100, TRUE), \"f1\" = sample(c(\"a\", \"b\"), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), \"grp\" = sample(c(\"Placebo\", \"Treatment\"), 100, TRUE), stringsAsFactors = TRUE ) prop_diff_strat_nc( rsp = data_set$rsp, grp = data_set$grp, strata = interaction(data_set[2:3]), weights_method = \"cmh\", conf_level = 0.90 ) #> $diff #> [1] -0.05777672 #> #> $diff_ci #> lower upper #> -0.2236537 0.1119331 #> prop_diff_strat_nc( rsp = data_set$rsp, grp = data_set$grp, strata = interaction(data_set[2:3]), weights_method = \"wilson_h\", conf_level = 0.90 ) #> $diff #> [1] -0.07771884 #> #> $diff_ci #> lower upper #> -0.2540844 0.1027720 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions to test proportion differences — h_prop_diff_test","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"Helper functions implement various tests difference two proportions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"","code":"prop_chisq(tbl) prop_cmh(ary) prop_schouten(tbl) prop_fisher(tbl)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"tbl (matrix) matrix two groups rows binary response (TRUE/FALSE) columns. ary (array, 3 dimensions) array two groups rows, binary response (TRUE/FALSE) columns, strata third dimension.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_prop_diff_test.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions to test proportion differences — h_prop_diff_test","text":"prop_chisq(): Performs Chi-Squared test. Internally calls stats::prop.test(). prop_cmh(): Performs stratified Cochran-Mantel-Haenszel test. Internally calls stats::mantelhaen.test(). Note strata less two observations automatically discarded. prop_schouten(): Performs Chi-Squared test Schouten correction. prop_fisher(): Performs Fisher's exact test. Internally calls stats::fisher.test().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for calculating proportion confidence intervals — h_proportions","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"Functions calculate different proportion confidence intervals use estimate_proportion().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"","code":"prop_wilson(rsp, conf_level, correct = FALSE) prop_strat_wilson( rsp, strata, weights = NULL, conf_level = 0.95, max_iterations = NULL, correct = FALSE ) prop_clopper_pearson(rsp, conf_level) prop_wald(rsp, conf_level, correct = FALSE) prop_agresti_coull(rsp, conf_level) prop_jeffreys(rsp, conf_level)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"rsp (logical) vector indicating whether subject responder . conf_level (proportion) confidence level interval. correct (flag) whether apply continuity correction. strata (factor) variable one level per stratum length rsp. weights (numeric NULL) weights level strata. NULL, estimated using iterative algorithm proposed Yan2010-jt;textualtern minimizes weighted squared length confidence interval. max_iterations (count) maximum number iterations iterative procedure used find estimates optimal weights.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"Confidence interval proportion.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"prop_wilson(): Calculates Wilson interval calling stats::prop.test(). Also referred Wilson score interval. prop_strat_wilson(): Calculates stratified Wilson confidence interval unequal proportions described Yan2010-jt;textualtern prop_clopper_pearson(): Calculates Clopper-Pearson interval calling stats::binom.test(). Also referred exact method. prop_wald(): Calculates Wald interval following usual textbook definition single proportion confidence interval using normal approximation. prop_agresti_coull(): Calculates Agresti-Coull interval. Constructed (95% CI) adding two successes two failures data using Wald formula construct CI. prop_jeffreys(): Calculates Jeffreys interval, equal-tailed interval based non-informative Jeffreys prior binomial proportion.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"Yan2010-jttern","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_proportions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for calculating proportion confidence intervals — h_proportions","text":"","code":"rsp <- c( TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE ) prop_wilson(rsp, conf_level = 0.9) #> [1] 0.2692718 0.7307282 # Stratified Wilson confidence interval with unequal probabilities set.seed(1) rsp <- sample(c(TRUE, FALSE), 100, TRUE) strata_data <- data.frame( \"f1\" = sample(c(\"a\", \"b\"), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), stringsAsFactors = TRUE ) strata <- interaction(strata_data) n_strata <- ncol(table(rsp, strata)) # Number of strata prop_strat_wilson( rsp = rsp, strata = strata, conf_level = 0.90 ) #> $conf_int #> lower upper #> 0.4072891 0.5647887 #> #> $weights #> a.x b.x a.y b.y a.z b.z #> 0.2074199 0.1776464 0.1915610 0.1604678 0.1351096 0.1277952 #> # Not automatic setting of weights prop_strat_wilson( rsp = rsp, strata = strata, weights = rep(1 / n_strata, n_strata), conf_level = 0.90 ) #> $conf_int #> lower upper #> 0.4190436 0.5789733 #> prop_clopper_pearson(rsp, conf_level = .95) #> [1] 0.3886442 0.5919637 prop_wald(rsp, conf_level = 0.95) #> [1] 0.3920214 0.5879786 prop_wald(rsp, conf_level = 0.95, correct = TRUE) #> [1] 0.3870214 0.5929786 prop_agresti_coull(rsp, conf_level = 0.95) #> [1] 0.3942193 0.5865206 prop_jeffreys(rsp, conf_level = 0.95) #> [1] 0.3934779 0.5870917"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"Helper functions documented separately confuse user reading user-facing functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"","code":"h_rsp_to_logistic_variables(variables, biomarker) h_logistic_mult_cont_df(variables, data, control = control_logistic()) h_tab_rsp_one_biomarker(df, vars, na_str = default_na_str(), .indent_mods = 0L)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"variables (named list string) list additional analysis variables. biomarker (string) name biomarker variable. data (data.frame) dataset containing variables summarize. control (named list) controls response definition confidence level produced control_logistic(). df (data.frame) results single biomarker, part returned extract_rsp_biomarkers() (needs couple columns added high-level function relative returned h_logistic_mult_cont_df(), see example). vars (character) names statistics reported among: n_tot: Total number patients per group. n_rsp: Total number responses per group. prop: Total response proportion per group. : Odds ratio. ci: Confidence interval odds ratio. pval: p-value effect. Note, statistics n_tot, ci required. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"h_rsp_to_logistic_variables() returns named list elements response, arm, covariates, strata. h_logistic_mult_cont_df() returns data.frame containing estimates statistics selected biomarkers. h_tab_rsp_one_biomarker() returns rtables table object given statistics arranged columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_biomarkers_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"h_rsp_to_logistic_variables(): helps converting \"response\" function variable list \"logistic regression\" variable list. reason currently inconsistency variable names accepted extract_rsp_subgroups() fit_logistic(). h_logistic_mult_cont_df(): prepares estimates number responses, patients overall response rate, well odds ratio estimates, confidence intervals p-values, multiple biomarkers given single data set. variables corresponds names variables found data, passed named list requires elements rsp biomarkers (vector continuous biomarker variables) optionally covariates strata. h_tab_rsp_one_biomarker(): Prepares single sub-table given df_sub containing results single biomarker.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating biomarker effects on binary response by subgroup — h_response_biomarkers_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% mutate(rsp = AVALC == \"CR\") formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") # This is how the variable list is converted internally. h_rsp_to_logistic_variables( variables = list( rsp = \"RSP\", covariates = c(\"A\", \"B\"), strata = \"D\" ), biomarker = \"AGE\" ) #> $response #> [1] \"RSP\" #> #> $arm #> [1] \"AGE\" #> #> $covariates #> [1] \"A\" \"B\" #> #> $strata #> [1] \"D\" #> # For a single population, estimate separately the effects # of two biomarkers. df <- h_logistic_mult_cont_df( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\" ), data = adrs_f ) df #> biomarker biomarker_label n_tot n_rsp prop or lcl #> 1 BMRKR1 Continuous Level Biomarker 1 200 164 0.82 0.9755036 0.8804862 #> 2 AGE Age 200 164 0.82 0.9952416 0.9462617 #> ucl conf_level pval pval_label #> 1 1.080775 0.95 0.6352602 p-value (Wald) #> 2 1.046757 0.95 0.8530389 p-value (Wald) # If the data set is empty, still the corresponding rows with missings are returned. h_coxreg_mult_cont_df( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", strata = \"STRATA1\" ), data = adrs_f[NULL, ] ) #> biomarker biomarker_label n_tot n_tot_events median hr lcl ucl #> 1 BMRKR1 Continuous Level Biomarker 1 0 0 NA NA NA NA #> 2 AGE Age 0 0 NA NA NA NA #> conf_level pval pval_label #> 1 0.95 NA p-value (Wald) #> 2 0.95 NA p-value (Wald) # Starting from above `df`, zoom in on one biomarker and add required columns. df1 <- df[1, ] df1$subgroup <- \"All patients\" df1$row_type <- \"content\" df1$var <- \"ALL\" df1$var_label <- \"All patients\" h_tab_rsp_one_biomarker( df1, vars = c(\"n_tot\", \"n_rsp\", \"prop\", \"or\", \"ci\", \"pval\") ) #> Total n Responders Response (%) Odds Ratio 95% CI p-value (Wald) #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> All patients 200 164 82.0% 0.98 (0.88, 1.08) 0.6353"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"Helper functions tabulate data frame statistics response rate odds ratio population subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"","code":"h_proportion_df(rsp, arm) h_proportion_subgroups_df( variables, data, groups_lists = list(), label_all = \"All Patients\" ) h_odds_ratio_df(rsp, arm, strata_data = NULL, conf_level = 0.95, method = NULL) h_odds_ratio_subgroups_df( variables, data, groups_lists = list(), conf_level = 0.95, method = NULL, label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"rsp (logical) vector indicating whether subject responder . arm (factor) treatment group variable. variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all (string) label total population analysis. strata_data (factor, data.frame, NULL) required stratified analysis performed. conf_level (proportion) confidence level interval. method (string NULL) specifies test used calculate p-value difference two proportions. options, see test_proportion_diff(). Default NULL test performed.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"h_proportion_df() returns data.frame columns arm, n, n_rsp, prop. h_proportion_subgroups_df() returns data.frame columns arm, n, n_rsp, prop, subgroup, var, var_label, row_type. h_odds_ratio_df() returns data.frame columns arm, n_tot, , lcl, ucl, conf_level, optionally pval pval_label. h_odds_ratio_subgroups_df() returns data.frame columns arm, n_tot, , lcl, ucl, conf_level, subgroup, var, var_label, row_type.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"Main functionality prepare data use layout-creating function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"h_proportion_df(): Helper prepare data frame binary responses arm. h_proportion_subgroups_df(): Summarizes proportion binary responses arm across subgroups data frame. variables corresponds names variables found data, passed named list requires elements rsp, arm optionally subgroups. groups_lists optionally specifies groupings subgroups variables. h_odds_ratio_df(): Helper prepare data frame estimates odds ratio treatment control arm. h_odds_ratio_subgroups_df(): Summarizes estimates odds ratio treatment control arm across subgroups data frame. variables corresponds names variables found data, passed named list requires elements rsp, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_response_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating binary response by subgroup — h_response_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>% droplevels() %>% mutate( # Reorder levels of factor to make the placebo group the reference arm. ARM = fct_relevel(ARM, \"B: Placebo\"), rsp = AVALC == \"CR\" ) formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") h_proportion_df( c(TRUE, FALSE, FALSE), arm = factor(c(\"A\", \"A\", \"B\"), levels = c(\"A\", \"B\")) ) #> arm n n_rsp prop #> 1 A 2 1 0.5 #> 2 B 1 0 0.0 h_proportion_subgroups_df( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f ) #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2 #> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2 #> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2 #> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2 #> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2 #> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Define groupings for BMRKR2 levels. h_proportion_subgroups_df( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 low BMRKR2 #> 8 A: Drug X 26 21 0.8076923 low BMRKR2 #> 9 B: Placebo 47 30 0.6382979 low/medium BMRKR2 #> 10 A: Drug X 52 44 0.8461538 low/medium BMRKR2 #> 11 B: Placebo 73 50 0.6849315 low/medium/high BMRKR2 #> 12 A: Drug X 69 59 0.8550725 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Unstratatified analysis. h_odds_ratio_df( c(TRUE, FALSE, FALSE, TRUE), arm = factor(c(\"A\", \"A\", \"B\", \"B\"), levels = c(\"A\", \"B\")) ) #> arm n_tot or lcl ucl conf_level #> 1 4 1 0.01984252 50.39681 0.95 # Include p-value. h_odds_ratio_df(adrs_f$rsp, adrs_f$ARM, method = \"chisq\") #> arm n_tot or lcl ucl conf_level pval #> 1 142 2.714 1.180449 6.239827 0.95 0.01643036 #> pval_label #> 1 p-value (Chi-Squared Test) # Stratatified analysis. h_odds_ratio_df( rsp = adrs_f$rsp, arm = adrs_f$ARM, strata_data = adrs_f[, c(\"STRATA1\", \"STRATA2\")], method = \"cmh\" ) #> arm n_tot or lcl ucl conf_level pval #> 1 142 2.665586 1.146149 6.199324 0.95 0.02019665 #> pval_label #> 1 p-value (Cochran-Mantel-Haenszel Test) # Unstratified analysis. h_odds_ratio_subgroups_df( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f ) #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.1804488 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.2669576 51.452218 0.95 F SEX #> 3 64 0.920000 0.2966470 2.853223 0.95 M SEX #> 4 50 3.553846 1.0047370 12.570277 0.95 LOW BMRKR2 #> 5 49 2.705882 0.5911718 12.385232 0.95 MEDIUM BMRKR2 #> 6 43 2.250000 0.3970298 12.750933 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis # Stratified analysis. h_odds_ratio_subgroups_df( variables = list( rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\"), strata = c(\"STRATA1\", \"STRATA2\") ), data = adrs_f ) #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.6655860 1.1461490 6.199324 0.95 All Patients ALL #> 2 78 7.7065093 1.5817529 37.547132 0.95 F SEX #> 3 64 0.9572284 0.2990954 3.063525 0.95 M SEX #> 4 50 3.0323726 0.8833232 10.409875 0.95 LOW BMRKR2 #> 5 49 2.1264996 0.4312008 10.486995 0.95 MEDIUM BMRKR2 #> 6 43 2.5134820 0.4351747 14.517370 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis # Define groupings of BMRKR2 levels. h_odds_ratio_subgroups_df( variables = list( rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.180449 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.266958 51.452218 0.95 F SEX #> 3 64 0.920000 0.296647 2.853223 0.95 M SEX #> 4 50 3.553846 1.004737 12.570277 0.95 low BMRKR2 #> 5 99 3.116667 1.193409 8.139385 0.95 low/medium BMRKR2 #> 6 142 2.714000 1.180449 6.239827 0.95 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_by_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Split data frame by subgroups — h_split_by_subgroups","title":"Split data frame by subgroups — h_split_by_subgroups","text":"Split data frame non-nested list subsets.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_by_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split data frame by subgroups — h_split_by_subgroups","text":"","code":"h_split_by_subgroups(data, subgroups, groups_lists = list())"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_by_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split data frame by subgroups — h_split_by_subgroups","text":"data (data.frame) dataset split. subgroups (character) names factor variables data used create subsets. Unused levels present data dropped. Note order vector determines order downstream table. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_by_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split data frame by subgroups — h_split_by_subgroups","text":"list subset data (df) metadata subset (df_labels).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_by_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Split data frame by subgroups — h_split_by_subgroups","text":"Main functionality prepare data use forest plot layouts.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_by_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split data frame by subgroups — h_split_by_subgroups","text":"","code":"df <- data.frame( x = c(1:5), y = factor(c(\"A\", \"B\", \"A\", \"B\", \"A\"), levels = c(\"A\", \"B\", \"C\")), z = factor(c(\"C\", \"C\", \"D\", \"D\", \"D\"), levels = c(\"D\", \"C\")) ) formatters::var_labels(df) <- paste(\"label for\", names(df)) h_split_by_subgroups( data = df, subgroups = c(\"y\", \"z\") ) #> $y.A #> $y.A$df #> x y z #> 1 1 A C #> 2 3 A D #> 3 5 A D #> #> $y.A$df_labels #> subgroup var var_label #> 1 A y label for y #> #> #> $y.B #> $y.B$df #> x y z #> 1 2 B C #> 2 4 B D #> #> $y.B$df_labels #> subgroup var var_label #> 1 B y label for y #> #> #> $z.D #> $z.D$df #> x y z #> 1 3 A D #> 2 4 B D #> 3 5 A D #> #> $z.D$df_labels #> subgroup var var_label #> 1 D z label for z #> #> #> $z.C #> $z.C$df #> x y z #> 1 1 A C #> 2 2 B C #> #> $z.C$df_labels #> subgroup var var_label #> 1 C z label for z #> #> h_split_by_subgroups( data = df, subgroups = c(\"y\", \"z\"), groups_lists = list( y = list(\"AB\" = c(\"A\", \"B\"), \"C\" = \"C\") ) ) #> $y.AB #> $y.AB$df #> x y z #> 1 1 A C #> 2 2 B C #> 3 3 A D #> 4 4 B D #> 5 5 A D #> #> $y.AB$df_labels #> subgroup var var_label #> 1 AB y label for y #> #> #> $z.D #> $z.D$df #> x y z #> 1 3 A D #> 2 4 B D #> 3 5 A D #> #> $z.D$df_labels #> subgroup var var_label #> 1 D z label for z #> #> #> $z.C #> $z.C$df #> x y z #> 1 1 A C #> 2 2 B C #> #> $z.C$df_labels #> subgroup var var_label #> 1 C z label for z #> #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_param.html","id":null,"dir":"Reference","previous_headings":"","what":"Split parameters — h_split_param","title":"Split parameters — h_split_param","text":"divides data vector param groups defined f based specified values. relevant rtables layers distribute parameters .stats ' .formats lists items corresponding specific analysis function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_param.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split parameters — h_split_param","text":"","code":"h_split_param(param, value, f)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_param.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split parameters — h_split_param","text":"param (vector) parameter split. value (vector) value used split. f (list) reference make split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_param.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split parameters — h_split_param","text":"named list element names f, containing elements specified .stats.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_split_param.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split parameters — h_split_param","text":"","code":"f <- list( surv = c(\"pt_at_risk\", \"event_free_rate\", \"rate_se\", \"rate_ci\"), surv_diff = c(\"rate_diff\", \"rate_diff_ci\", \"ztest_pval\") ) .stats <- c(\"pt_at_risk\", \"rate_diff\") h_split_param(.stats, .stats, f = f) #> $surv #> [1] \"pt_at_risk\" #> #> $surv_diff #> [1] \"rate_diff\" #> # $surv # [1] \"pt_at_risk\" # # $surv_diff # [1] \"rate_diff\" .formats <- c(\"pt_at_risk\" = \"xx\", \"event_free_rate\" = \"xxx\") h_split_param(.formats, names(.formats), f = f) #> $surv #> pt_at_risk event_free_rate #> \"xx\" \"xxx\" #> #> $surv_diff #> NULL #> # $surv # pt_at_risk event_free_rate # \"xx\" \"xxx\" # # $surv_diff # NULL"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_stack_by_baskets.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"Helper function create new SMQ variable ADAE consists adverse events belonging selected Standardized/Customized queries. new dataset contain records adverse events belonging selected baskets. Remember na_str must match needed pre-processing done df_explicit_na() desired output.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_stack_by_baskets.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"","code":"h_stack_by_baskets( df, baskets = grep(\"^(SMQ|CQ).+NAM$\", names(df), value = TRUE), smq_varlabel = \"Standardized MedDRA Query\", keys = c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"AEDECOD\", \"AESEQ\"), aag_summary = NULL, na_str = \"\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_stack_by_baskets.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"df (data.frame) data set containing analysis variables. baskets (character) variable names selected Standardized/Customized queries. smq_varlabel (string) label new variable created. keys (character) names key variables returned along new variable created. aag_summary (data.frame) containing SMQ baskets levels interest final SMQ variable. useful levels interest observed df dataset. two columns dataset named basket basket_name. na_str (string) string used replace NA empty values output.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_stack_by_baskets.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"data.frame variables keys taken df new variable SMQ containing records belonging baskets selected via baskets argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_stack_by_baskets.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records. — h_stack_by_baskets","text":"","code":"adae <- tern_ex_adae[1:20, ] %>% df_explicit_na() h_stack_by_baskets(df = adae) #> # A tibble: 8 × 6 #> STUDYID USUBJID ASTDTM AEDECOD AESEQ SMQ #> #> 1 AB12345 AB12345-BRA-11-id-8 2021-12-05 02:02:07 dcd D.2.1.5.3 2 D.2.1.5… #> 2 AB12345 AB12345-BRA-12-id-120 2020-02-05 01:42:29 dcd D.2.1.5.3 2 D.2.1.5… #> 3 AB12345 AB12345-BRA-1-id-171 2022-11-29 12:18:31 dcd C.1.1.1.3 2 C.1.1.1… #> 4 AB12345 AB12345-BRA-1-id-23 2020-07-10 07:32:49 dcd B.2.2.3.1 3 C.1.1.1… #> 5 AB12345 AB12345-BRA-1-id-59 2021-10-10 23:54:46 dcd C.1.1.1.3 4 C.1.1.1… #> 6 AB12345 AB12345-BRA-1-id-9 2021-06-01 14:39:09 dcd C.1.1.1.3 1 C.1.1.1… #> 7 AB12345 AB12345-BRA-11-id-8 2021-12-21 02:02:07 dcd C.1.1.1.3 3 C.1.1.1… #> 8 AB12345 AB12345-BRA-12-id-120 2020-10-01 01:42:29 dcd C.1.1.1.3 3 C.1.1.1… aag <- data.frame( NAMVAR = c(\"CQ01NAM\", \"CQ02NAM\", \"SMQ01NAM\", \"SMQ02NAM\"), REFNAME = c( \"D.2.1.5.3/A.1.1.1.1 aesi\", \"X.9.9.9.9/Y.8.8.8.8 aesi\", \"C.1.1.1.3/B.2.2.3.1 aesi\", \"C.1.1.1.3/B.3.3.3.3 aesi\" ), SCOPE = c(\"\", \"\", \"BROAD\", \"BROAD\"), stringsAsFactors = FALSE ) basket_name <- character(nrow(aag)) cq_pos <- grep(\"^(CQ).+NAM$\", aag$NAMVAR) smq_pos <- grep(\"^(SMQ).+NAM$\", aag$NAMVAR) basket_name[cq_pos] <- aag$REFNAME[cq_pos] basket_name[smq_pos] <- paste0( aag$REFNAME[smq_pos], \"(\", aag$SCOPE[smq_pos], \")\" ) aag_summary <- data.frame( basket = aag$NAMVAR, basket_name = basket_name, stringsAsFactors = TRUE ) result <- h_stack_by_baskets(df = adae, aag_summary = aag_summary) all(levels(aag_summary$basket_name) %in% levels(result$SMQ)) #> [1] TRUE h_stack_by_baskets( df = adae, aag_summary = NULL, keys = c(\"STUDYID\", \"USUBJID\", \"AEDECOD\", \"ARM\"), baskets = \"SMQ01NAM\" ) #> # A tibble: 6 × 5 #> STUDYID USUBJID AEDECOD ARM SMQ #> #> 1 AB12345 AB12345-BRA-1-id-171 dcd C.1.1.1.3 B: Placebo C.1.1.1.3/B.2.2.3.… #> 2 AB12345 AB12345-BRA-1-id-23 dcd B.2.2.3.1 A: Drug X C.1.1.1.3/B.2.2.3.… #> 3 AB12345 AB12345-BRA-1-id-59 dcd C.1.1.1.3 A: Drug X C.1.1.1.3/B.2.2.3.… #> 4 AB12345 AB12345-BRA-1-id-9 dcd C.1.1.1.3 C: Combination C.1.1.1.3/B.2.2.3.… #> 5 AB12345 AB12345-BRA-11-id-8 dcd C.1.1.1.3 A: Drug X C.1.1.1.3/B.2.2.3.… #> 6 AB12345 AB12345-BRA-12-id-120 dcd C.1.1.1.3 A: Drug X C.1.1.1.3/B.2.2.3.…"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_step.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"Helper functions used internally STEP calculations.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"","code":"h_step_window(x, control = control_step()) h_step_trt_effect(data, model, variables, x) h_step_survival_formula(variables, control = control_step()) h_step_survival_est( formula, data, variables, x, subset = rep(TRUE, nrow(data)), control = control_coxph() ) h_step_rsp_formula(variables, control = c(control_step(), control_logistic())) h_step_rsp_est( formula, data, variables, x, subset = rep(TRUE, nrow(data)), control = control_logistic() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"x (numeric) biomarker value(s) use (without NA). control (named list) output control_step(). data (data.frame) dataset containing variables summarize. model (coxph glm) regression model object. variables (named list string) list additional analysis variables. formula (formula) regression model formula. subset (logical) subset vector.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"h_step_window() returns list containing window-selection matrix sel interval information matrix interval. h_step_trt_effect() returns vector elements est se. h_step_survival_formula() returns model formula. h_step_survival_est() returns matrix number observations n, events, log hazard ratio estimates loghr, standard error se, Wald confidence interval bounds ci_lower ci_upper. One row included biomarker value x. h_step_rsp_formula() returns model formula. h_step_rsp_est() returns matrix number observations n, log odds ratio estimates logor, standard error se, Wald confidence interval bounds ci_lower ci_upper. One row included biomarker value x.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_step.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for subgroup treatment effect pattern (STEP) calculations — h_step","text":"h_step_window(): Creates windows STEP, based control settings provided. h_step_trt_effect(): Calculates estimated treatment effect estimate linear predictor scale corresponding standard error STEP model fitted data given variables specification, single biomarker value x. works coxph glm models, .e. calculating log hazard ratio log odds ratio estimates. h_step_survival_formula(): Builds model formula used survival STEP calculations. h_step_survival_est(): Estimates model formula built based variables data given subset control parameters Cox regression. h_step_rsp_formula(): Builds model formula used response STEP calculations. h_step_rsp_est(): Estimates model formula built based variables data given subset control parameters logistic regression.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"Helper functions documented separately confuse user reading user-facing functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"","code":"h_surv_to_coxreg_variables(variables, biomarker) h_coxreg_mult_cont_df(variables, data, control = control_coxreg()) h_tab_surv_one_biomarker( df, vars, time_unit, na_str = default_na_str(), .indent_mods = 0L, ... )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"variables (named list string) list additional analysis variables. biomarker (string) name biomarker variable. data (data.frame) dataset containing variables summarize. control (list) list parameters returned helper function control_coxreg(). df (data.frame) results single biomarker, part returned extract_survival_biomarkers() (needs couple columns added high-level function relative returned h_coxreg_mult_cont_df(), see example). vars (character) names statistics reported among: n_tot_events: Total number events per group. n_tot: Total number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. time_unit (string) label unit median survival time. Default NULL skips displaying unit. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"h_surv_to_coxreg_variables() returns named list elements time, event, arm, covariates, strata. h_coxreg_mult_cont_df() returns data.frame containing estimates statistics selected biomarkers. h_tab_surv_one_biomarker() returns rtables table object given statistics arranged columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_biomarkers_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"h_surv_to_coxreg_variables(): Helps converting \"survival\" function variable list \"Cox regression\" variable list. reason currently inconsistency variable names accepted extract_survival_subgroups() fit_coxreg_multivar(). h_coxreg_mult_cont_df(): Prepares estimates number events, patients median survival times, well hazard ratio estimates, confidence intervals p-values, multiple biomarkers given single data set. variables corresponds names variables found data, passed named list requires elements tte, is_event, biomarkers (vector continuous biomarker variables) optionally subgroups strata. h_tab_surv_one_biomarker(): Prepares single sub-table given df_sub containing results single biomarker.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating biomarker effects on survival by subgroup — h_survival_biomarkers_subgroups","text":"","code":"library(dplyr) library(forcats) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte, fill = FALSE) adtte_f <- adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- c(\"AVALU\" = adtte_labels[[\"AVALU\"]], \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels # This is how the variable list is converted internally. h_surv_to_coxreg_variables( variables = list( tte = \"AVAL\", is_event = \"EVNT\", covariates = c(\"A\", \"B\"), strata = \"D\" ), biomarker = \"AGE\" ) #> $time #> [1] \"AVAL\" #> #> $event #> [1] \"EVNT\" #> #> $arm #> [1] \"AGE\" #> #> $covariates #> [1] \"A\" \"B\" #> #> $strata #> [1] \"D\" #> # For a single population, estimate separately the effects # of two biomarkers. df <- h_coxreg_mult_cont_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", strata = c(\"STRATA1\", \"STRATA2\") ), data = adtte_f ) df #> biomarker biomarker_label n_tot n_tot_events median hr #> 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.000189 #> 2 AGE Age 200 141 753.5176 1.008267 #> lcl ucl conf_level pval pval_label #> 1 0.9511092 1.051802 0.95 0.9941244 p-value (Wald) #> 2 0.9845155 1.032591 0.95 0.4984743 p-value (Wald) # If the data set is empty, still the corresponding rows with missings are returned. h_coxreg_mult_cont_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"REGION1\", strata = c(\"STRATA1\", \"STRATA2\") ), data = adtte_f[NULL, ] ) #> biomarker biomarker_label n_tot n_tot_events median hr lcl ucl #> 1 BMRKR1 Continuous Level Biomarker 1 0 0 NA NA NA NA #> 2 AGE Age 0 0 NA NA NA NA #> conf_level pval pval_label #> 1 0.95 NA p-value (Wald) #> 2 0.95 NA p-value (Wald) # Starting from above `df`, zoom in on one biomarker and add required columns. df1 <- df[1, ] df1$subgroup <- \"All patients\" df1$row_type <- \"content\" df1$var <- \"ALL\" df1$var_label <- \"All patients\" h_tab_surv_one_biomarker( df1, vars = c(\"n_tot\", \"n_tot_events\", \"median\", \"hr\", \"ci\", \"pval\"), time_unit = \"days\" ) #> Total n Total Events Median (days) Hazard Ratio 95% Wald CI p-value (Wald) #> ———————————————————————————————————————————————————————————————————————————————————————————————————— #> All patients 200 141 753.5 1.00 (0.95, 1.05) 0.9941"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"Helper functions tabulate data frame statistics median survival time hazard ratio population subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"","code":"h_survtime_df(tte, is_event, arm) h_survtime_subgroups_df( variables, data, groups_lists = list(), label_all = \"All Patients\" ) h_coxph_df(tte, is_event, arm, strata_data = NULL, control = control_coxph()) h_coxph_subgroups_df( variables, data, groups_lists = list(), control = control_coxph(), label_all = \"All Patients\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"tte (numeric) vector time--event duration values. is_event (flag)TRUE event, FALSE time event censored. arm (factor) treatment group variable. variables (named list string) list additional analysis variables. data (data.frame) dataset containing variables summarize. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all (string) label total population analysis. strata_data (factor, data.frame, NULL) required stratified analysis performed. control (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing null hypothesis hazard ratio = 1. Default method \"log-rank\" comes survival::survdiff(), can also set \"wald\" \"likelihood\" (survival::coxph()). ties (string) specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval HR.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"h_survtime_df() returns data.frame columns arm, n, n_events, median. h_survtime_subgroups_df() returns data.frame columns arm, n, n_events, median, subgroup, var, var_label, row_type. h_coxph_df() returns data.frame columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval pval_label. h_coxph_subgroups_df() returns data.frame columns arm, n_tot, n_tot_events, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, row_type.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"Main functionality prepare data use layout-creating function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"h_survtime_df(): Helper prepare data frame median survival times arm. h_survtime_subgroups_df(): Summarizes median survival times arm across subgroups data frame. variables corresponds names variables found data, passed named list requires elements tte, is_event, arm optionally subgroups. groups_lists optionally specifies groupings subgroups variables. h_coxph_df(): Helper prepare data frame estimates treatment hazard ratio. h_coxph_subgroups_df(): Summarizes estimates treatment hazard ratio across subgroups data frame. variables corresponds names variables found data, passed named list requires elements tte, is_event, arm optionally subgroups strata. groups_lists optionally specifies groupings subgroups variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_survival_duration_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for tabulating survival duration by subgroup — h_survival_duration_subgroups","text":"","code":"library(dplyr) library(forcats) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) adtte_f <- adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\"), SEX %in% c(\"M\", \"F\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(fct_relevel(ARM, \"B: Placebo\")), SEX = droplevels(SEX), is_event = CNSR == 0 ) labels <- c(\"ARM\" = adtte_labels[[\"ARM\"]], \"SEX\" = adtte_labels[[\"SEX\"]], \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels # Extract median survival time for one group. h_survtime_df( tte = adtte_f$AVAL, is_event = adtte_f$is_event, arm = adtte_f$ARM ) #> arm n n_events median #> 1 B: Placebo 73 57 727.8043 #> 2 A: Drug X 69 44 974.6402 # Extract median survival time for multiple groups. h_survtime_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f ) #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 All Patients ALL #> 2 A: Drug X 69 44 974.6402 All Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 LOW BMRKR2 #> 8 A: Drug X 26 15 974.6402 LOW BMRKR2 #> 9 B: Placebo 23 14 731.8352 MEDIUM BMRKR2 #> 10 A: Drug X 26 17 964.2197 MEDIUM BMRKR2 #> 11 B: Placebo 26 22 654.8245 HIGH BMRKR2 #> 12 A: Drug X 17 12 1016.2982 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Define groupings for BMRKR2 levels. h_survtime_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 All Patients ALL #> 2 A: Drug X 69 44 974.6402 All Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 low BMRKR2 #> 8 A: Drug X 26 15 974.6402 low BMRKR2 #> 9 B: Placebo 47 35 735.4722 low/medium BMRKR2 #> 10 A: Drug X 52 32 964.2197 low/medium BMRKR2 #> 11 B: Placebo 73 57 727.8043 low/medium/high BMRKR2 #> 12 A: Drug X 69 44 974.6402 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis # Extract hazard ratio for one group. h_coxph_df(adtte_f$AVAL, adtte_f$is_event, adtte_f$ARM) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.057337 0.95 0.09049511 #> pval_label #> 1 p-value (log-rank) # Extract hazard ratio for one group with stratification factor. h_coxph_df(adtte_f$AVAL, adtte_f$is_event, adtte_f$ARM, strata_data = adtte_f$STRATA1) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.6646586 0.4399495 1.00414 0.95 0.05089188 #> pval_label #> 1 p-value (log-rank) # Extract hazard ratio for multiple groups. h_coxph_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f ) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 49 31 0.7651261 0.3641277 1.6077269 0.95 0.47860004 #> 6 43 34 0.6662356 0.3257413 1.3626456 0.95 0.26285846 #> pval_label subgroup var var_label row_type #> 1 p-value (log-rank) All Patients ALL All Patients content #> 2 p-value (log-rank) F SEX Sex analysis #> 3 p-value (log-rank) M SEX Sex analysis #> 4 p-value (log-rank) LOW BMRKR2 Continuous Level Biomarker 2 analysis #> 5 p-value (log-rank) MEDIUM BMRKR2 Continuous Level Biomarker 2 analysis #> 6 p-value (log-rank) HIGH BMRKR2 Continuous Level Biomarker 2 analysis # Define groupings of BMRKR2 levels. h_coxph_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 99 67 0.7472958 0.4600419 1.2139136 0.95 0.23764314 #> 6 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> pval_label subgroup var var_label #> 1 p-value (log-rank) All Patients ALL All Patients #> 2 p-value (log-rank) F SEX Sex #> 3 p-value (log-rank) M SEX Sex #> 4 p-value (log-rank) low BMRKR2 Continuous Level Biomarker 2 #> 5 p-value (log-rank) low/medium BMRKR2 Continuous Level Biomarker 2 #> 6 p-value (log-rank) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 analysis #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis # Extract hazard ratio for multiple groups with stratification factors. h_coxph_subgroups_df( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\"), strata = c(\"STRATA1\", \"STRATA2\") ), data = adtte_f ) #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.6126133 0.3913507 0.9589739 0.95 0.03086774 #> 2 78 55 0.3934024 0.2027682 0.7632630 0.95 0.00469167 #> 3 64 46 0.9501768 0.4730073 1.9087145 0.95 0.88580522 #> 4 50 36 0.7378635 0.3140465 1.7336363 0.95 0.48408079 #> 5 49 31 0.9408062 0.4172095 2.1215148 0.95 0.88305965 #> 6 43 34 0.5125617 0.2125140 1.2362459 0.95 0.13124382 #> pval_label subgroup var var_label row_type #> 1 p-value (log-rank) All Patients ALL All Patients content #> 2 p-value (log-rank) F SEX Sex analysis #> 3 p-value (log-rank) M SEX Sex analysis #> 4 p-value (log-rank) LOW BMRKR2 Continuous Level Biomarker 2 analysis #> 5 p-value (log-rank) MEDIUM BMRKR2 Continuous Level Biomarker 2 analysis #> 6 p-value (log-rank) HIGH BMRKR2 Continuous Level Biomarker 2 analysis"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tab_one_biomarker.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"Please see h_tab_surv_one_biomarker() h_tab_rsp_one_biomarker(), use function examples. function wrapper rtables::summarize_row_groups().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tab_one_biomarker.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"","code":"h_tab_one_biomarker( df, afuns, colvars, na_str = default_na_str(), .indent_mods = 0L, ... )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tab_one_biomarker.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"df (data.frame) results single biomarker. afuns (named list function) analysis functions. colvars (named list) named list elements vars (variables tabulate) labels (labels). na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tab_one_biomarker.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for tabulation of a single biomarker result — h_tab_one_biomarker","text":"rtables table object statistics columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_coxph_pairwise.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"Create data.frame pairwise stratified unstratified Cox-PH analysis results.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_coxph_pairwise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"","code":"h_tbl_coxph_pairwise( df, variables, ref_group_coxph = NULL, control_coxph_pw = control_coxph(), annot_coxph_ref_lbls = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_coxph_pairwise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"df (data.frame) data set containing analysis variables. variables (named list) variable names. Details : tte (numeric) variable indicating time--event duration values. is_event (logical) event variable. TRUE event, FALSE time event censored. arm (factor) treatment group variable. strata (character NULL) variable names indicating stratification factors. ref_group_coxph (string NULL) level arm variable use reference group calculations annot_coxph table. NULL (default), uses first level arm variable. control_coxph_pw (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing hazard ratio = 1. Default method \"log-rank\", can also set \"wald\" \"likelihood\". ties (string) method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph() conf_level (proportion) confidence level interval HR. annot_coxph_ref_lbls (flag) whether reference group explicitly printed labels annot_coxph table. FALSE (default), comparison groups printed annot_coxph table labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_coxph_pairwise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"data.frame containing statistics HR, XX% CI (XX taken control_coxph_pw), p-value (log-rank).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_coxph_pairwise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for generating a pairwise Cox-PH table — h_tbl_coxph_pairwise","text":"","code":"library(dplyr) adtte <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) h_tbl_coxph_pairwise( df = adtte, variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\"), control_coxph_pw = control_coxph(conf_level = 0.9) ) #> HR 90% CI p-value (log-rank) #> B: Placebo 1.41 (1.01, 1.96) 0.0905 #> C: Combination 1.81 (1.24, 2.64) 0.0086"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_median_surv.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for survival estimations — h_tbl_median_surv","title":"Helper function for survival estimations — h_tbl_median_surv","text":"Transform survival fit table groups rows characterized N, median confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_median_surv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for survival estimations — h_tbl_median_surv","text":"","code":"h_tbl_median_surv(fit_km, armval = \"All\")"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_median_surv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for survival estimations — h_tbl_median_surv","text":"fit_km (survfit) result survival::survfit(). armval (string) used strata name treatment arm variable one level. Default \"\".","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_median_surv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for survival estimations — h_tbl_median_surv","text":"summary table statistics N, Median, XX% CI (XX taken fit_km).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_tbl_median_surv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for survival estimations — h_tbl_median_surv","text":"","code":"library(dplyr) library(survival) adtte <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") fit <- survfit( formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = adtte ) h_tbl_median_surv(fit_km = fit) #> N Median 95% CI #> ARM A 69 974.6 (687, 1625) #> ARM B 73 727.8 (555.8, 1156) #> ARM C 58 632.3 (393, 1001)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_worsen_counter.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"Helper function count number patients fraction patients according highest post-baseline lab grade variable .var, baseline lab grade variable baseline_var, direction interest specified direction_var.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_worsen_counter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"","code":"h_worsen_counter(df, id, .var, baseline_var, direction_var)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_worsen_counter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"df (data.frame) data set containing analysis variables. id (string) subject variable name. .var (string) single variable name passed rtables requested statistics function. baseline_var (string) name baseline lab grade variable. direction_var (string) name direction variable specifying direction shift table interest. lab records flagged L, H B included shift table. L: low direction H: high direction B: low high directions","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_worsen_counter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"counts fraction patients whose worst post-baseline lab grades worse baseline grades, post-baseline worst grades \"1\", \"2\", \"3\", \"4\" \"\".","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/h_worsen_counter.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline() — h_worsen_counter","text":"","code":"library(dplyr) # The direction variable, GRADDR, is based on metadata adlb <- tern_ex_adlb %>% mutate( GRADDR = case_when( PARAMCD == \"ALT\" ~ \"B\", PARAMCD == \"CRP\" ~ \"L\", PARAMCD == \"IGA\" ~ \"H\" ) ) %>% filter(SAFFL == \"Y\" & ONTRTFL == \"Y\" & GRADDR != \"\") df <- h_adlb_worsen( adlb, worst_flag_low = c(\"WGRLOFL\" = \"Y\"), worst_flag_high = c(\"WGRHIFL\" = \"Y\"), direction_var = \"GRADDR\" ) # `h_worsen_counter` h_worsen_counter( df %>% filter(PARAMCD == \"CRP\" & GRADDR == \"Low\"), id = \"USUBJID\", .var = \"ATOXGR\", baseline_var = \"BTOXGR\", direction_var = \"GRADDR\" ) #> $fraction #> $fraction$`1` #> num denom #> 25 180 #> #> $fraction$`2` #> num denom #> 15 186 #> #> $fraction$`3` #> num denom #> 18 191 #> #> $fraction$`4` #> num denom #> 17 196 #> #> $fraction$Any #> num denom #> 75 196 #> #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_xticks.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function to calculate x-tick positions — h_xticks","title":"Helper function to calculate x-tick positions — h_xticks","text":"Calculate positions ticks x-axis. However, xticks already exists kept . based function ggplot2 relies , required graphic patient--risk annotation table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_xticks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function to calculate x-tick positions — h_xticks","text":"","code":"h_xticks(data, xticks = NULL, max_time = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/h_xticks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function to calculate x-tick positions — h_xticks","text":"data (data.frame) survival data pre-processed h_data_plot. xticks (numeric NULL) numeric vector tick positions single number spacing ticks x-axis. NULL (default), labeling::extended() used determine optimal tick positions x-axis. max_time (numeric(1)) maximum value show x-axis. data values less threshold value plotted (defaults NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_xticks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function to calculate x-tick positions — h_xticks","text":"vector positions use x-axis ticks ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/h_xticks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function to calculate x-tick positions — h_xticks","text":"","code":"library(dplyr) library(survival) data <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% h_data_plot() h_xticks(data) #> [1] 0 1000 2000 3000 4000 5000 h_xticks(data, xticks = seq(0, 3000, 500)) #> [1] 0 500 1000 1500 2000 2500 3000 h_xticks(data, xticks = 500) #> [1] 0 500 1000 1500 2000 2500 3000 3500 4000 4500 h_xticks(data, xticks = 500, max_time = 6000) #> [1] 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 h_xticks(data, xticks = c(0, 500), max_time = 300) #> [1] 0 500 h_xticks(data, xticks = 500, max_time = 300) #> [1] 0 500 1000 1500 2000 2500 3000 3500 4000 4500"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/imputation_rule.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply 1/3 or 1/2 imputation rule to data — imputation_rule","text":"","code":"imputation_rule( df, x_stats, stat, imp_rule, post = FALSE, avalcat_var = \"AVALCAT1\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/imputation_rule.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply 1/3 or 1/2 imputation rule to data — imputation_rule","text":"df (data.frame) data set containing analysis variables. x_stats (named list) named list statistics, typically results s_summary(). stat (string) statistic return value/NA level according imputation rule applied. imp_rule (string) imputation rule setting. Set \"1/3\" implement 1/3 imputation rule \"1/2\" implement 1/2 imputation rule. post (flag) whether data corresponds post-dose time-point (defaults FALSE). parameter used imp_rule set \"1/3\". avalcat_var (string) name variable indicates whether row df corresponds analysis value category \"BLQ\", \"LTR\", \" $val #> max #> 0.9919061 #> #> $na_str #> [1] \"ND\" #> imputation_rule(df, x_stats, \"geom_mean\", \"1/3\") #> $val #> [1] NA #> #> $na_str #> [1] \"NE\" #> imputation_rule(df, x_stats, \"mean\", \"1/2\") #> $val #> [1] NA #> #> $na_str #> [1] \"ND\" #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/incidence_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Incidence rate estimation — incidence_rate","title":"Incidence rate estimation — incidence_rate","text":"analyze function estimate_incidence_rate() creates layout element estimate event rate adjusted person-years risk, otherwise known incidence rate. primary analysis variable specified via vars person-years risk. addition variable, n_events variable number events observed (value 1 means event observed 0 means event observed) must also specified.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/incidence_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Incidence rate estimation — incidence_rate","text":"","code":"estimate_incidence_rate( lyt, vars, n_events, id_var = \"USUBJID\", control = control_incidence_rate(), na_str = default_na_str(), nested = TRUE, summarize = FALSE, label_fmt = \"%s - %.labels\", ..., show_labels = \"hidden\", table_names = vars, .stats = c(\"person_years\", \"n_events\", \"rate\", \"rate_ci\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_incidence_rate( df, .var, n_events, is_event = lifecycle::deprecated(), id_var = \"USUBJID\", control = control_incidence_rate() ) a_incidence_rate( df, labelstr = \"\", .var, .df_row, n_events, id_var = \"USUBJID\", control = control_incidence_rate(), .stats = NULL, .formats = c(person_years = \"xx.x\", n_events = \"xx\", rate = \"xx.xx\", rate_ci = \"(xx.xx, xx.xx)\", n_unique = \"xx\", n_rate = \"xx (xx.x)\"), .labels = NULL, .indent_mods = NULL, na_str = default_na_str(), label_fmt = \"%s - %.labels\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/incidence_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Incidence rate estimation — incidence_rate","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . n_events (string) name integer variable indicating whether event observed (1) (0). id_var (string) name variable used patient identifier \"n_unique\" included .stats. Defaults \"USUBJID\". control (list) parameters estimation details, specified using helper function control_incidence_rate(). Possible parameter options : conf_level (proportion) confidence level estimated incidence rate. conf_type (string)normal (default), normal_log, exact, byar confidence interval type. input_time_unit (string)day, week, month, year (default) indicating time unit data input. num_pt_year (numeric) time unit desired output (person-years). na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. summarize (flag) whether function act analyze function (summarize = FALSE), summarize function (summarize = TRUE). Defaults FALSE. label_fmt (string) labels formatted row split occurs summarize = TRUE. string use \"%s\" represent row split levels, \"%.labels\" represent labels supplied .labels argument. Defaults \"%s - %.labels\". ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'person_years', 'n_events', 'rate', 'rate_ci', 'n_unique', 'n_rate' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. is_event (flag)TRUE event, FALSE time event censored. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/incidence_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Incidence rate estimation — incidence_rate","text":"estimate_incidence_rate() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_incidence_rate() table layout. s_incidence_rate() returns following statistics: person_years: Total person-years risk. n_events: Total number events observed. rate: Estimated incidence rate. rate_ci: Confidence interval incidence rate. n_unique: Total number patients least one event observed. n_rate: Total number events observed & estimated incidence rate. a_incidence_rate() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/incidence_rate.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Incidence rate estimation — incidence_rate","text":"estimate_incidence_rate(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_incidence_rate(): Statistics function estimates incidence rate associated confidence interval. a_incidence_rate(): Formatted analysis function used afun estimate_incidence_rate().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/incidence_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Incidence rate estimation — incidence_rate","text":"","code":"df <- data.frame( USUBJID = as.character(seq(6)), CNSR = c(0, 1, 1, 0, 0, 0), AVAL = c(10.1, 20.4, 15.3, 20.8, 18.7, 23.4), ARM = factor(c(\"A\", \"A\", \"A\", \"B\", \"B\", \"B\")), STRATA1 = factor(c(\"X\", \"Y\", \"Y\", \"X\", \"X\", \"Y\")) ) df$n_events <- 1 - df$CNSR basic_table(show_colcounts = TRUE) %>% split_cols_by(\"ARM\") %>% estimate_incidence_rate( vars = \"AVAL\", n_events = \"n_events\", control = control_incidence_rate( input_time_unit = \"month\", num_pt_year = 100 ) ) %>% build_table(df) #> A B #> (N=3) (N=3) #> ————————————————————————————————————————————————————————————————————— #> Total patient-years at risk 3.8 5.2 #> Number of adverse events observed 1 3 #> AE rate per 100 patient-years 26.20 57.23 #> 95% CI (-25.15, 77.55) (-7.53, 122.00) # summarize = TRUE basic_table(show_colcounts = TRUE) %>% split_cols_by(\"ARM\") %>% split_rows_by(\"STRATA1\", child_labels = \"visible\") %>% estimate_incidence_rate( vars = \"AVAL\", n_events = \"n_events\", .stats = c(\"n_unique\", \"n_rate\"), summarize = TRUE, label_fmt = \"%.labels\" ) %>% build_table(df) #> A B #> (N=3) (N=3) #> ——————————————————————————————————————————————————————————————————————————————————————— #> X #> Total number of patients with at least one adverse event 1 2 #> Number of adverse events observed (AE rate per 100 patient-years) 1 (9.9) 2 (5.1) #> Y #> Total number of patients with at least one adverse event 0 1 #> Number of adverse events observed (AE rate per 100 patient-years) 0 (0.0) 1 (4.3) a_incidence_rate( df, .var = \"AVAL\", .df_row = df, n_events = \"n_events\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod #> 1 person_years 108.7 0 #> 2 n_events 4 0 #> 3 rate 3.68 0 #> 4 rate_ci (0.07, 7.29) 0 #> 5 n_unique 4 0 #> 6 n_rate 4 (3.7) 0 #> row_label #> 1 Total patient-years at risk #> 2 Number of adverse events observed #> 3 AE rate per 100 patient-years #> 4 95% CI #> 5 Total number of patients with at least one adverse event #> 6 Number of adverse events observed (AE rate per 100 patient-years)"},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_or_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Labels or names of list elements — labels_or_names","title":"Labels or names of list elements — labels_or_names","text":"Internal helper function working nested statistic function results typically labels names can use.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_or_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Labels or names of list elements — labels_or_names","text":"","code":"labels_or_names(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_or_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Labels or names of list elements — labels_or_names","text":"x (list) list.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_or_names.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Labels or names of list elements — labels_or_names","text":"character vector labels names list elements.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_use_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Update labels according to control specifications — labels_use_control","title":"Update labels according to control specifications — labels_use_control","text":"Given list statistic labels list control parameters, updates labels relevant control specification. example, control element conf_level set 0.9, default label statistic mean_ci updated \"Mean 90% CI\". labels supplied via labels_custom updated regardless control.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_use_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update labels according to control specifications — labels_use_control","text":"","code":"labels_use_control(labels_default, control, labels_custom = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_use_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update labels according to control specifications — labels_use_control","text":"labels_default (named character) named vector statistic labels modify according control specifications. Labels explicitly defined labels_custom affected. control (named list) list control parameters apply adjust default labels. labels_custom (named character) named vector labels customized user affected control.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_use_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update labels according to control specifications — labels_use_control","text":"named character vector labels control specifications applied relevant labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/labels_use_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Update labels according to control specifications — labels_use_control","text":"","code":"control <- list(conf_level = 0.80, quantiles = c(0.1, 0.83), test_mean = 0.57) get_labels_from_stats(c(\"mean_ci\", \"quantiles\", \"mean_pval\")) %>% labels_use_control(control = control) #> mean_ci quantiles #> \"Mean 80% CI\" \"10% and 83%-ile\" #> mean_pval #> \"Mean p-value (H0: mean = 0.57)\""},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_regression_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Logistic regression multivariate column layout function — logistic_regression_cols","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"Layout-creating function creates multivariate column layout summarizing logistic regression results. function wrapper rtables::split_cols_by_multivar().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_regression_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"","code":"logistic_regression_cols(lyt, conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_regression_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"lyt (PreDataTableLayouts) layout analyses added . conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_regression_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logistic regression multivariate column layout function — logistic_regression_cols","text":"layout object suitable passing layouting functions. Adding function rtable layout split table columns corresponding statistics df, estimate, std_error, odds_ratio, ci, pvalue.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_summary_by_flag.html","id":null,"dir":"Reference","previous_headings":"","what":"Logistic regression summary table — logistic_summary_by_flag","title":"Logistic regression summary table — logistic_summary_by_flag","text":"Constructor content functions used summarize_logistic() summarize logistic regression results. function wrapper rtables::summarize_row_groups().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_summary_by_flag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logistic regression summary table — logistic_summary_by_flag","text":"","code":"logistic_summary_by_flag( flag_var, na_str = default_na_str(), .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_summary_by_flag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logistic regression summary table — logistic_summary_by_flag","text":"flag_var (string) variable name identifying row used content function. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/logistic_summary_by_flag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logistic regression summary table — logistic_summary_by_flag","text":"content function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/make_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Make names without dots — make_names","title":"Make names without dots — make_names","text":"Make names without dots","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/make_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Make names without dots — make_names","text":"","code":"make_names(nams)"},{"path":"https://insightsengineering.github.io/tern/main/reference/make_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Make names without dots — make_names","text":"nams (character) vector original names.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/make_names.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Make names without dots — make_names","text":"character vector proper names, use dots contrast make.names().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/month2day.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion of months to days — month2day","title":"Conversion of months to days — month2day","text":"Conversion months days. approximative calculation considers month average 30.4375 days.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/month2day.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion of months to days — month2day","text":"","code":"month2day(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/month2day.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conversion of months to days — month2day","text":"x (numeric(1)) time months.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/month2day.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conversion of months to days — month2day","text":"numeric vector time days.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/month2day.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conversion of months to days — month2day","text":"","code":"x <- c(13.25, 8.15, 1, 2.834) month2day(x) #> [1] 403.29688 248.06563 30.43750 86.25988"},{"path":"https://insightsengineering.github.io/tern/main/reference/muffled_car_anova.html","id":null,"dir":"Reference","previous_headings":"","what":"Muffled car::Anova — muffled_car_anova","title":"Muffled car::Anova — muffled_car_anova","text":"Applied survival models, car::Anova() signal strata terms dropped model formula present, function deliberately muffles message.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/muffled_car_anova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Muffled car::Anova — muffled_car_anova","text":"","code":"muffled_car_anova(mod, test_statistic)"},{"path":"https://insightsengineering.github.io/tern/main/reference/muffled_car_anova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Muffled car::Anova — muffled_car_anova","text":"mod (coxph) Cox regression model fitted survival::coxph(). test_statistic (string) method used estimation p.values; wald (default) likelihood.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/muffled_car_anova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Muffled car::Anova — muffled_car_anova","text":"output car::Anova(), convergence message muffled.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/n_available.html","id":null,"dir":"Reference","previous_headings":"","what":"Number of available (non-missing entries) in a vector — n_available","title":"Number of available (non-missing entries) in a vector — n_available","text":"Small utility function better readability.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/n_available.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Number of available (non-missing entries) in a vector — n_available","text":"","code":"n_available(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/n_available.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Number of available (non-missing entries) in a vector — n_available","text":"x (vector) vector count non-missing values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/n_available.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Number of available (non-missing entries) in a vector — n_available","text":"Number non-missing values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":null,"dir":"Reference","previous_headings":"","what":"Odds ratio estimation — odds_ratio","title":"Odds ratio estimation — odds_ratio","text":"analyze function estimate_odds_ratio() creates layout element compare bivariate responses two groups estimating odds ratio confidence interval. primary analysis variable specified vars group variable. Additional variables can included analysis via variables argument, accepts arm, arm variable, strata, stratification variable. two arm levels present, can combined two groups using groups_list argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Odds ratio estimation — odds_ratio","text":"","code":"estimate_odds_ratio( lyt, vars, variables = list(arm = NULL, strata = NULL), conf_level = 0.95, groups_list = NULL, na_str = default_na_str(), nested = TRUE, method = \"exact\", show_labels = \"hidden\", table_names = vars, var_labels = vars, .stats = \"or_ci\", .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_odds_ratio( df, .var, .ref_group, .in_ref_col, .df_row, variables = list(arm = NULL, strata = NULL), conf_level = 0.95, groups_list = NULL, method = \"exact\" ) a_odds_ratio( df, .var, .ref_group, .in_ref_col, .df_row, variables = list(arm = NULL, strata = NULL), conf_level = 0.95, groups_list = NULL, method = \"exact\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Odds ratio estimation — odds_ratio","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. conf_level (proportion) confidence level interval. groups_list (named list character) specifies new group levels via names levels belong character vectors elements list. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. method (string) whether use correct (\"exact\") calculation conditional likelihood one approximations. See survival::clogit() details. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. var_labels (character) variable labels. .stats (character) statistics select table. Options : 'or_ci', 'n_tot' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Odds ratio estimation — odds_ratio","text":"estimate_odds_ratio() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_odds_ratio() table layout. s_odds_ratio() returns named list statistics or_ci (containing est, lcl, ucl) n_tot. a_odds_ratio() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Odds ratio estimation — odds_ratio","text":"estimate_odds_ratio(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_odds_ratio(): Statistics function estimates odds ratio treatment control. variables list arm strata variable names must passed stratified analysis required. a_odds_ratio(): Formatted analysis function used afun estimate_odds_ratio().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Odds ratio estimation — odds_ratio","text":"function uses logistic regression unstratified analyses, conditional logistic regression stratified analyses. Wald confidence interval calculated specified confidence level. stratified analyses, currently implementation conditional likelihood confidence intervals, therefore likelihood confidence interval available option. vars contains responders non-responders odds ratio estimation possible returned values NA.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/odds_ratio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Odds ratio estimation — odds_ratio","text":"","code":"set.seed(12) dta <- data.frame( rsp = sample(c(TRUE, FALSE), 100, TRUE), grp = factor(rep(c(\"A\", \"B\"), each = 50), levels = c(\"A\", \"B\")), strata = factor(sample(c(\"C\", \"D\"), 100, TRUE)) ) l <- basic_table() %>% split_cols_by(var = \"grp\", ref_group = \"B\") %>% estimate_odds_ratio(vars = \"rsp\") build_table(l, df = dta) #> A B #> ———————————————————————————————————————————— #> Odds Ratio (95% CI) 0.85 (0.38 - 1.88) # Unstratified analysis. s_odds_ratio( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, .df_row = dta ) #> $or_ci #> est lcl ucl #> 0.8484848 0.3831831 1.8788053 #> attr(,\"label\") #> [1] \"Odds Ratio (95% CI)\" #> #> $n_tot #> n_tot #> 100 #> attr(,\"label\") #> [1] \"Total n\" #> # Stratified analysis. s_odds_ratio( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, .df_row = dta, variables = list(arm = \"grp\", strata = \"strata\") ) #> $or_ci #> est lcl ucl #> 0.7689750 0.3424155 1.7269154 #> attr(,\"label\") #> [1] \"Odds Ratio (95% CI)\" #> #> $n_tot #> n_tot #> 100 #> attr(,\"label\") #> [1] \"Total n\" #> a_odds_ratio( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, .df_row = dta ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 or_ci 0.85 (0.38 - 1.88) 1 Odds Ratio (95% CI) #> 2 n_tot 100 0 Total n"},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Proportion difference estimation — prop_diff","title":"Proportion difference estimation — prop_diff","text":"analysis function estimate_proportion_diff() creates layout element estimate difference proportion responders within studied population. primary analysis variable, vars, logical variable indicating whether response occurred record. See method parameter options methods use constructing confidence interval proportion difference. stratification variable can supplied via strata element variables argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Proportion difference estimation — prop_diff","text":"","code":"estimate_proportion_diff( lyt, vars, variables = list(strata = NULL), conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"cmh\", \"ha\", \"newcombe\", \"newcombecc\", \"strat_newcombe\", \"strat_newcombecc\"), weights_method = \"cmh\", na_str = default_na_str(), nested = TRUE, ..., var_labels = vars, show_labels = \"hidden\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"cmh\", \"ha\", \"newcombe\", \"newcombecc\", \"strat_newcombe\", \"strat_newcombecc\"), weights_method = \"cmh\" ) a_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), conf_level = 0.95, method = c(\"waldcc\", \"wald\", \"cmh\", \"ha\", \"newcombe\", \"newcombecc\", \"strat_newcombe\", \"strat_newcombecc\"), weights_method = \"cmh\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Proportion difference estimation — prop_diff","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. conf_level (proportion) confidence level interval. method (string) method used confidence interval estimation. weights_method (string) weights method. Can either \"cmh\" \"heuristic\" directs way weights estimated. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'diff', 'diff_ci' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Proportion difference estimation — prop_diff","text":"estimate_proportion_diff() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_proportion_diff() table layout. s_proportion_diff() returns named list elements diff diff_ci. a_proportion_diff() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Proportion difference estimation — prop_diff","text":"estimate_proportion_diff(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_proportion_diff(): Statistics function estimating difference terms responder proportion. a_proportion_diff(): Formatted analysis function used afun estimate_proportion_diff().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Proportion difference estimation — prop_diff","text":"performing unstratified analysis, methods \"cmh\", \"strat_newcombe\", \"strat_newcombecc\" permitted.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Proportion difference estimation — prop_diff","text":"","code":"## \"Mid\" case: 4/4 respond in group A, 1/2 respond in group B. nex <- 100 # Number of example rows dta <- data.frame( \"rsp\" = sample(c(TRUE, FALSE), nex, TRUE), \"grp\" = sample(c(\"A\", \"B\"), nex, TRUE), \"f1\" = sample(c(\"a1\", \"a2\"), nex, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), nex, TRUE), stringsAsFactors = TRUE ) l <- basic_table() %>% split_cols_by(var = \"grp\", ref_group = \"B\") %>% estimate_proportion_diff( vars = \"rsp\", conf_level = 0.90, method = \"ha\" ) build_table(l, df = dta) #> A B #> —————————————————————————————————————————————————— #> Difference in Response rate (%) 12.0 #> 90% CI (Anderson-Hauck) (-5.4, 29.4) s_proportion_diff( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, conf_level = 0.90, method = \"ha\" ) #> $diff #> [1] 12 #> attr(,\"label\") #> [1] \"Difference in Response rate (%)\" #> #> $diff_ci #> [1] -5.374519 29.374519 #> attr(,\"label\") #> [1] \"90% CI (Anderson-Hauck)\" #> # CMH example with strata s_proportion_diff( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, variables = list(strata = c(\"f1\", \"f2\")), conf_level = 0.90, method = \"cmh\" ) #> $diff #> [1] 12.05847 #> attr(,\"label\") #> [1] \"Difference in Response rate (%)\" #> #> $diff_ci #> [1] -2.67057 26.78750 #> attr(,\"label\") #> [1] \"90% CI (CMH, without correction)\" #> a_proportion_diff( df = subset(dta, grp == \"A\"), .var = \"rsp\", .ref_group = subset(dta, grp == \"B\"), .in_ref_col = FALSE, conf_level = 0.90, method = \"ha\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 diff 12.0 0 Difference in Response rate (%) #> 2 diff_ci (-5.4, 29.4) 1 90% CI (Anderson-Hauck)"},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Difference test for two proportions — prop_diff_test","title":"Difference test for two proportions — prop_diff_test","text":"analyze function test_proportion_diff() creates layout element test difference two proportions. primary analysis variable, vars, indicates whether response occurred record. See method parameter options methods use calculate p-value. Additionally, stratification variable can supplied via strata element variables argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Difference test for two proportions — prop_diff_test","text":"","code":"test_proportion_diff( lyt, vars, variables = list(strata = NULL), method = c(\"chisq\", \"schouten\", \"fisher\", \"cmh\"), na_str = default_na_str(), nested = TRUE, ..., var_labels = vars, show_labels = \"hidden\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_test_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), method = c(\"chisq\", \"schouten\", \"fisher\", \"cmh\") ) a_test_proportion_diff( df, .var, .ref_group, .in_ref_col, variables = list(strata = NULL), method = c(\"chisq\", \"schouten\", \"fisher\", \"cmh\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Difference test for two proportions — prop_diff_test","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. method (string) one chisq, cmh, fisher, schouten; specifies test used calculate p-value. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'pval' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Difference test for two proportions — prop_diff_test","text":"test_proportion_diff() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_test_proportion_diff() table layout. s_test_proportion_diff() returns named list single item pval attribute label describing method used. p-value tests null hypothesis proportions two groups . a_test_proportion_diff() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff_test.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Difference test for two proportions — prop_diff_test","text":"test_proportion_diff(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_test_proportion_diff(): Statistics function tests difference two proportions. a_test_proportion_diff(): Formatted analysis function used afun test_proportion_diff().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/prop_diff_test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Difference test for two proportions — prop_diff_test","text":"","code":"dta <- data.frame( rsp = sample(c(TRUE, FALSE), 100, TRUE), grp = factor(rep(c(\"A\", \"B\"), each = 50)), strata = factor(rep(c(\"V\", \"W\", \"X\", \"Y\", \"Z\"), each = 20)) ) # With `rtables` pipelines. l <- basic_table() %>% split_cols_by(var = \"grp\", ref_group = \"B\") %>% test_proportion_diff( vars = \"rsp\", method = \"cmh\", variables = list(strata = \"strata\") ) build_table(l, df = dta) #> A B #> ————————————————————————————————————————————————————— #> p-value (Cochran-Mantel-Haenszel Test) 1.0000"},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":null,"dir":"Reference","previous_headings":"","what":"Occurrence table pruning — prune_occurrences","title":"Occurrence table pruning — prune_occurrences","text":"Family constructor condition functions flexibly prune occurrence tables. condition functions always return whether row result higher threshold. Since class CombinationFunction() can logically combined condition functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Occurrence table pruning — prune_occurrences","text":"","code":"keep_rows(row_condition) keep_content_rows(content_row_condition) has_count_in_cols(atleast, ...) has_count_in_any_col(atleast, ...) has_fraction_in_cols(atleast, ...) has_fraction_in_any_col(atleast, ...) has_fractions_difference(atleast, ...) has_counts_difference(atleast, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Occurrence table pruning — prune_occurrences","text":"row_condition (CombinationFunction) condition function works individual analysis rows flags whether kept pruned table. content_row_condition (CombinationFunction) condition function works individual first content rows leaf tables flags whether leaf tables kept pruned table. atleast (numeric(1)) threshold met order keep row. ... arguments row column access, see rtables_access: either col_names (character) including names columns used, alternatively col_indices (integer) giving indices directly instead.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Occurrence table pruning — prune_occurrences","text":"keep_rows() returns pruning function can used rtables::prune_table() prune rtables table. keep_content_rows() returns pruning function checks condition first content row leaf tables table. has_count_in_cols() returns condition function sums counts specified column. has_count_in_any_col() returns condition function compares counts specified columns threshold. has_fraction_in_cols() returns condition function sums counts specified column, computes fraction dividing total column counts. has_fraction_in_any_col() returns condition function looks fractions specified columns checks whether fulfill threshold. has_fractions_difference() returns condition function extracts fractions specified column, computes difference minimum maximum. has_counts_difference() returns condition function extracts counts specified column, computes difference minimum maximum.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Occurrence table pruning — prune_occurrences","text":"keep_rows(): Constructor creating pruning functions based row condition function. removes analysis rows (TableRow) pruned, .e., fulfill row condition. removes sub-tree children left. keep_content_rows(): Constructor creating pruning functions based condition (first) content row leaf tables. removes leaf tables first content row fulfill condition. check individual rows. proceeds recursively removing sub tree children left. has_count_in_cols(): Constructor creating condition functions total counts specified columns. has_count_in_any_col(): Constructor creating condition functions counts specified columns satisfying threshold. has_fraction_in_cols(): Constructor creating condition functions total fraction specified columns. has_fraction_in_any_col(): Constructor creating condition functions fraction specified columns. has_fractions_difference(): Constructor creating condition function checks difference fractions reported specified column. has_counts_difference(): Constructor creating condition function checks difference counts reported specified column.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Occurrence table pruning — prune_occurrences","text":"Since table specifications worded positively, name constructor condition functions positively, . However, note result keep_rows() says pruned, conform rtables::prune_table() interface.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/prune_occurrences.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Occurrence table pruning — prune_occurrences","text":"","code":"# \\donttest{ tab <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"RACE\") %>% split_rows_by(\"STRATA1\") %>% summarize_row_groups() %>% analyze_vars(\"COUNTRY\", .stats = \"count_fraction\") %>% build_table(DM) # } # \\donttest{ # `keep_rows` is_non_empty <- !CombinationFunction(all_zero_or_na) prune_table(tab, keep_rows(is_non_empty)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # `keep_content_rows` # \\donttest{ more_than_twenty <- has_count_in_cols(atleast = 20L, col_names = names(tab)) prune_table(tab, keep_content_rows(more_than_twenty)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> CHE 0 0 0 #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> CAN 0 0 0 #> CHE 0 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> GBR 0 0 0 #> CAN 0 0 0 #> CHE 0 0 0 #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> RUS 0 0 0 #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> CAN 0 0 0 #> CHE 0 0 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> NGA 0 0 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> CHE 0 0 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> JPN 0 0 0 #> GBR 0 0 0 #> CAN 0 0 0 #> CHE 0 0 0 # } # \\donttest{ more_than_one <- has_count_in_cols(atleast = 1L, col_names = names(tab)) prune_table(tab, keep_rows(more_than_one)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ # `has_count_in_any_col` any_more_than_one <- has_count_in_any_col(atleast = 1L, col_names = names(tab)) prune_table(tab, keep_rows(any_more_than_one)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ # `has_fraction_in_cols` more_than_five_percent <- has_fraction_in_cols(atleast = 0.05, col_names = names(tab)) prune_table(tab, keep_rows(more_than_five_percent)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> BLACK OR AFRICAN AMERICAN #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) # } # \\donttest{ # `has_fraction_in_any_col` any_atleast_five_percent <- has_fraction_in_any_col(atleast = 0.05, col_names = names(tab)) prune_table(tab, keep_rows(any_atleast_five_percent)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ # `has_fractions_difference` more_than_five_percent_diff <- has_fractions_difference(atleast = 0.05, col_names = names(tab)) prune_table(tab, keep_rows(more_than_five_percent_diff)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> PAK 1 (8.3%) 1 (9.1%) 1 (14.3%) #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # } # \\donttest{ more_than_one_diff <- has_counts_difference(atleast = 1L, col_names = names(tab)) prune_table(tab, keep_rows(more_than_one_diff)) #> A: Drug X B: Placebo C: Combination #> ———————————————————————————————————————————————————————————————————— #> ASIAN #> A 27 (22.3%) 20 (18.9%) 31 (24.0%) #> CHN 14 (51.9%) 9 (45%) 12 (38.7%) #> USA 2 (7.4%) 1 (5%) 8 (25.8%) #> BRA 1 (3.7%) 4 (20%) 1 (3.2%) #> PAK 3 (11.1%) 2 (10%) 2 (6.5%) #> NGA 3 (11.1%) 1 (5%) 3 (9.7%) #> RUS 2 (7.4%) 1 (5%) 1 (3.2%) #> JPN 0 1 (5%) 2 (6.5%) #> GBR 0 1 (5%) 1 (3.2%) #> CAN 2 (7.4%) 0 1 (3.2%) #> B 24 (19.8%) 29 (27.4%) 22 (17.1%) #> CHN 12 (50%) 13 (44.8%) 11 (50%) #> USA 2 (8.3%) 5 (17.2%) 1 (4.5%) #> BRA 4 (16.7%) 3 (10.3%) 1 (4.5%) #> PAK 2 (8.3%) 2 (6.9%) 4 (18.2%) #> NGA 2 (8.3%) 1 (3.4%) 3 (13.6%) #> RUS 1 (4.2%) 1 (3.4%) 2 (9.1%) #> JPN 0 4 (13.8%) 0 #> GBR 1 (4.2%) 0 0 #> C 28 (23.1%) 19 (17.9%) 31 (24.0%) #> CHN 13 (46.4%) 10 (52.6%) 16 (51.6%) #> USA 3 (10.7%) 3 (15.8%) 4 (12.9%) #> BRA 1 (3.6%) 1 (5.3%) 4 (12.9%) #> PAK 1 (3.6%) 1 (5.3%) 3 (9.7%) #> NGA 4 (14.3%) 1 (5.3%) 2 (6.5%) #> RUS 4 (14.3%) 2 (10.5%) 1 (3.2%) #> JPN 2 (7.1%) 1 (5.3%) 1 (3.2%) #> BLACK OR AFRICAN AMERICAN #> A 6 (5.0%) 7 (6.6%) 8 (6.2%) #> CHN 3 (50%) 3 (42.9%) 5 (62.5%) #> USA 2 (33.3%) 1 (14.3%) 1 (12.5%) #> BRA 0 1 (14.3%) 0 #> PAK 0 0 1 (12.5%) #> NGA 0 0 1 (12.5%) #> JPN 1 (16.7%) 0 0 #> GBR 0 2 (28.6%) 0 #> B 10 (8.3%) 6 (5.7%) 12 (9.3%) #> CHN 3 (30%) 2 (33.3%) 8 (66.7%) #> USA 1 (10%) 0 1 (8.3%) #> BRA 2 (20%) 1 (16.7%) 1 (8.3%) #> PAK 0 1 (16.7%) 0 #> RUS 0 1 (16.7%) 0 #> JPN 2 (20%) 0 1 (8.3%) #> GBR 1 (10%) 0 1 (8.3%) #> CAN 1 (10%) 1 (16.7%) 0 #> C 12 (9.9%) 11 (10.4%) 7 (5.4%) #> CHN 8 (66.7%) 5 (45.5%) 5 (71.4%) #> USA 1 (8.3%) 2 (18.2%) 1 (14.3%) #> BRA 1 (8.3%) 2 (18.2%) 0 #> NGA 0 1 (9.1%) 0 #> RUS 1 (8.3%) 0 0 #> WHITE #> A 3 (2.5%) 6 (5.7%) 6 (4.7%) #> CHN 2 (66.7%) 2 (33.3%) 3 (50%) #> USA 1 (33.3%) 1 (16.7%) 0 #> PAK 0 1 (16.7%) 1 (16.7%) #> NGA 0 1 (16.7%) 0 #> RUS 0 0 1 (16.7%) #> JPN 0 1 (16.7%) 0 #> CAN 0 0 1 (16.7%) #> B 7 (5.8%) 5 (4.7%) 4 (3.1%) #> CHN 4 (57.1%) 1 (20%) 3 (75%) #> USA 0 1 (20%) 0 #> BRA 0 1 (20%) 0 #> PAK 1 (14.3%) 0 0 #> NGA 1 (14.3%) 0 0 #> RUS 1 (14.3%) 0 1 (25%) #> JPN 0 1 (20%) 0 #> CAN 0 1 (20%) 0 #> C 4 (3.3%) 3 (2.8%) 8 (6.2%) #> CHN 3 (75%) 3 (100%) 6 (75%) #> USA 1 (25%) 0 1 (12.5%) #> JPN 0 0 1 (12.5%) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/range_noinf.html","id":null,"dir":"Reference","previous_headings":"","what":"Re-implemented range() default S3 method for numerical objects — range_noinf","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"function returns c(NA, NA) instead c(-Inf, Inf) zero-length data without warnings.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/range_noinf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"","code":"range_noinf(x, na.rm = FALSE, finite = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/range_noinf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"x (numeric) sequence numbers range computed. na.rm (flag) flag indicating NA omitted. finite (flag) flag indicating non-finite elements removed.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/range_noinf.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Re-implemented range() default S3 method for numerical objects — range_noinf","text":"2-element vector class numeric.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/reapply_varlabels.html","id":null,"dir":"Reference","previous_headings":"","what":"Reapply variable labels — reapply_varlabels","title":"Reapply variable labels — reapply_varlabels","text":"helper function used tests.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/reapply_varlabels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reapply variable labels — reapply_varlabels","text":"","code":"reapply_varlabels(x, varlabels, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/reapply_varlabels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reapply variable labels — reapply_varlabels","text":"x (vector) vector elements needs new labels. varlabels (character) vector labels x. ... parameters added list.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/reapply_varlabels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reapply variable labels — reapply_varlabels","text":"x variable labels reapplied.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"tabulate_rsp_biomarkers() function creates layout element tabulate estimated biomarker effects binary response endpoint across subgroups, returning statistics including response rate odds ratio population subgroup. table created df, list data frames returned extract_rsp_biomarkers(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"","code":"tabulate_rsp_biomarkers( df, vars = c(\"n_tot\", \"n_rsp\", \"prop\", \"or\", \"ci\", \"pval\"), na_str = default_na_str(), .indent_mods = 0L )"},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"df (data.frame) containing analysis variables, returned extract_rsp_biomarkers(). vars (character) names statistics reported among: n_tot: Total number patients per group. n_rsp: Total number responses per group. prop: Total response proportion per group. : Odds ratio. ci: Confidence interval odds ratio. pval: p-value effect. Note, statistics n_tot, ci required. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"rtables table summarizing biomarker effects binary response subgroup.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"functions create layout starting data frame contains required statistics. tables typically used input forest plots.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"contrast tabulate_rsp_subgroups() tabulation function start input layout lyt. internally table created combining multiple subtables.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/response_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate biomarker effects on binary response by subgroup — response_biomarkers_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% mutate(rsp = AVALC == \"CR\") formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") df <- extract_rsp_biomarkers( variables = list( rsp = \"rsp\", biomarkers = c(\"BMRKR1\", \"AGE\"), covariates = \"SEX\", subgroups = \"BMRKR2\" ), data = adrs_f ) # \\donttest{ ## Table with default columns. tabulate_rsp_biomarkers(df) #> Total n Responders Response (%) Odds Ratio 95% CI p-value (Wald) #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Age #> All Patients 200 164 82.0% 1.00 (0.95, 1.05) 0.8530 #> Continuous Level Biomarker 2 #> LOW 70 53 75.7% 0.93 (0.85, 1.01) 0.0845 #> MEDIUM 68 58 85.3% 0.99 (0.88, 1.11) 0.8190 #> HIGH 62 53 85.5% 1.06 (0.96, 1.18) 0.2419 #> Continuous Level Biomarker 1 #> All Patients 200 164 82.0% 0.98 (0.88, 1.08) 0.6353 #> Continuous Level Biomarker 2 #> LOW 70 53 75.7% 1.15 (0.95, 1.40) 0.1584 #> MEDIUM 68 58 85.3% 0.88 (0.73, 1.06) 0.1700 #> HIGH 62 53 85.5% 0.88 (0.72, 1.08) 0.2104 ## Table with a manually chosen set of columns: leave out \"pval\", reorder. tab <- tabulate_rsp_biomarkers( df = df, vars = c(\"n_rsp\", \"ci\", \"n_tot\", \"prop\", \"or\") ) ## Finally produce the forest plot. g_forest(tab, xlim = c(0.7, 1.4)) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate binary response by subgroup — response_subgroups","title":"Tabulate binary response by subgroup — response_subgroups","text":"tabulate_rsp_subgroups() function creates layout element tabulate binary response subgroup, returning statistics including response rate odds ratio population subgroup. table created df, list data frames returned extract_rsp_subgroups(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate binary response by subgroup — response_subgroups","text":"","code":"tabulate_rsp_subgroups( lyt, df, vars = c(\"n_tot\", \"n\", \"prop\", \"or\", \"ci\"), groups_lists = list(), label_all = \"All Patients\", riskdiff = NULL, na_str = default_na_str(), .formats = c(n = \"xx\", n_rsp = \"xx\", prop = \"xx.x%\", n_tot = \"xx\", or = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\") ) a_response_subgroups( .formats = list(n = \"xx\", n_rsp = \"xx\", prop = \"xx.x%\", n_tot = \"xx\", or = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\", riskdiff = \"xx.x (xx.x - xx.x)\"), na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate binary response by subgroup — response_subgroups","text":"lyt (PreDataTableLayouts) layout analyses added . df (list) list data frames containing analysis variables. List created using extract_rsp_subgroups(). vars (character) names statistics reported among: n: Total number observations per group. n_rsp: Number responders per group. prop: Proportion responders. n_tot: Total number observations. : Odds ratio. ci : Confidence interval odds ratio. pval: p-value effect. Note, statistics n_tot, , ci required. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all (string) label total population analysis. riskdiff (list) risk (proportion) difference column added, list settings apply within column. See control_riskdiff() details. NULL, risk difference column added. riskdiff$arm_x riskdiff$arm_y NULL, first level df$prop$arm used arm_x second level arm_y. na_str (string) string used replace NA empty values output. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate binary response by subgroup — response_subgroups","text":"rtables table summarizing binary response subgroup. a_response_subgroups() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate binary response by subgroup — response_subgroups","text":"functions create layout starting data frame contains required statistics. Tables typically used part forest plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Tabulate binary response by subgroup — response_subgroups","text":"tabulate_rsp_subgroups(): Table-creating function creates table summarizing binary response subgroup. function wrapper rtables::analyze_colvars() rtables::summarize_row_groups(). a_response_subgroups(): Formatted analysis function used afun tabulate_rsp_subgroups().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/response_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate binary response by subgroup — response_subgroups","text":"","code":"library(dplyr) library(forcats) adrs <- tern_ex_adrs adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>% droplevels() %>% mutate( # Reorder levels of factor to make the placebo group the reference arm. ARM = fct_relevel(ARM, \"B: Placebo\"), rsp = AVALC == \"CR\" ) formatters::var_labels(adrs_f) <- c(adrs_labels, \"Response\") # Unstratified analysis. df <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f ) df #> $prop #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2 #> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2 #> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2 #> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2 #> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2 #> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $or #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.1804488 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.2669576 51.452218 0.95 F SEX #> 3 64 0.920000 0.2966470 2.853223 0.95 M SEX #> 4 50 3.553846 1.0047370 12.570277 0.95 LOW BMRKR2 #> 5 49 2.705882 0.5911718 12.385232 0.95 MEDIUM BMRKR2 #> 6 43 2.250000 0.3970298 12.750933 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> # Stratified analysis. df_strat <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\"), strata = \"STRATA1\"), data = adrs_f ) df_strat #> $prop #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2 #> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2 #> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2 #> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2 #> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2 #> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $or #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.6343899 1.1537821 6.015009 0.95 All Patients ALL #> 2 78 9.5946605 2.0379337 45.171985 0.95 F SEX #> 3 64 0.8947158 0.2936803 2.725809 0.95 M SEX #> 4 50 3.5976656 1.0101319 12.813374 0.95 LOW BMRKR2 #> 5 49 2.6242168 0.5162572 13.339308 0.95 MEDIUM BMRKR2 #> 6 43 2.2816865 0.4116391 12.647228 0.95 HIGH BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> # Grouping of the BMRKR2 levels. df_grouped <- extract_rsp_subgroups( variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")), data = adrs_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) df_grouped #> $prop #> arm n n_rsp prop subgroup var #> 1 B: Placebo 73 50 0.6849315 All Patients ALL #> 2 A: Drug X 69 59 0.8550725 All Patients ALL #> 3 B: Placebo 40 25 0.6250000 F SEX #> 4 A: Drug X 38 36 0.9473684 F SEX #> 5 B: Placebo 33 25 0.7575758 M SEX #> 6 A: Drug X 31 23 0.7419355 M SEX #> 7 B: Placebo 24 13 0.5416667 low BMRKR2 #> 8 A: Drug X 26 21 0.8076923 low BMRKR2 #> 9 B: Placebo 47 30 0.6382979 low/medium BMRKR2 #> 10 A: Drug X 52 44 0.8461538 low/medium BMRKR2 #> 11 B: Placebo 73 50 0.6849315 low/medium/high BMRKR2 #> 12 A: Drug X 69 59 0.8550725 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $or #> arm n_tot or lcl ucl conf_level subgroup var #> 1 142 2.714000 1.180449 6.239827 0.95 All Patients ALL #> 2 78 10.800000 2.266958 51.452218 0.95 F SEX #> 3 64 0.920000 0.296647 2.853223 0.95 M SEX #> 4 50 3.553846 1.004737 12.570277 0.95 low BMRKR2 #> 5 99 3.116667 1.193409 8.139385 0.95 low/medium BMRKR2 #> 6 142 2.714000 1.180449 6.239827 0.95 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 Sex analysis #> 3 Sex analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> # Table with default columns basic_table() %>% tabulate_rsp_subgroups(df) #> B: Placebo A: Drug X #> Baseline Risk Factors Total n n Response (%) n Response (%) Odds Ratio 95% CI #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————— #> All Patients 142 73 68.5% 69 85.5% 2.71 (1.18, 6.24) #> Sex #> F 78 40 62.5% 38 94.7% 10.80 (2.27, 51.45) #> M 64 33 75.8% 31 74.2% 0.92 (0.30, 2.85) #> Continuous Level Biomarker 2 #> LOW 50 24 54.2% 26 80.8% 3.55 (1.00, 12.57) #> MEDIUM 49 23 73.9% 26 88.5% 2.71 (0.59, 12.39) #> HIGH 43 26 76.9% 17 88.2% 2.25 (0.40, 12.75) # Table with selected columns basic_table() %>% tabulate_rsp_subgroups( df = df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\") ) #> B: Placebo A: Drug X #> Baseline Risk Factors Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> All Patients 142 73 50 68.5% 69 59 85.5% 2.71 (1.18, 6.24) #> Sex #> F 78 40 25 62.5% 38 36 94.7% 10.80 (2.27, 51.45) #> M 64 33 25 75.8% 31 23 74.2% 0.92 (0.30, 2.85) #> Continuous Level Biomarker 2 #> LOW 50 24 13 54.2% 26 21 80.8% 3.55 (1.00, 12.57) #> MEDIUM 49 23 17 73.9% 26 23 88.5% 2.71 (0.59, 12.39) #> HIGH 43 26 20 76.9% 17 15 88.2% 2.25 (0.40, 12.75) # Table with risk difference column added basic_table() %>% tabulate_rsp_subgroups( df, riskdiff = control_riskdiff( arm_x = levels(df$prop$arm)[1], arm_y = levels(df$prop$arm)[2] ) ) #> B: Placebo A: Drug X #> Baseline Risk Factors Total n n Response (%) n Response (%) Odds Ratio 95% CI Risk Difference (%) (95% CI) #> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> All Patients 142 73 68.5% 69 85.5% 2.71 (1.18, 6.24) -17.0 (-30.5 - -3.5) #> Sex #> F 78 40 62.5% 38 94.7% 10.80 (2.27, 51.45) -32.2 (-48.8 - -15.6) #> M 64 33 75.8% 31 74.2% 0.92 (0.30, 2.85) 1.6 (-19.7 - 22.8) #> Continuous Level Biomarker 2 #> LOW 50 24 54.2% 26 80.8% 3.55 (1.00, 12.57) -26.6 (-51.6 - -1.6) #> MEDIUM 49 23 73.9% 26 88.5% 2.71 (0.59, 12.39) -14.5 (-36.3 - 7.2) #> HIGH 43 26 76.9% 17 88.2% 2.25 (0.40, 12.75) -11.3 (-33.6 - 11.0)"},{"path":"https://insightsengineering.github.io/tern/main/reference/rtable2gg.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert rtable objects to ggplot objects — rtable2gg","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"Given rtables::rtable() object, performs basic conversion ggplot2::ggplot() object built using functions ggplot2 package. table titles /footnotes ignored.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/rtable2gg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"","code":"rtable2gg(tbl, fontsize = 12, colwidths = NULL, lbl_col_padding = 0)"},{"path":"https://insightsengineering.github.io/tern/main/reference/rtable2gg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"tbl (VTableTree)rtables table object. fontsize (numeric(1)) font size. colwidths (numeric NULL) vector column widths. element's position colwidths corresponds column tbl position. NULL, column widths calculated according maximum number characters per column. lbl_col_padding (numeric) additional padding use calculating spacing first (label) column second column tbl. colwidths specified, width first column becomes colwidths[1] + lbl_col_padding. Defaults 0.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/rtable2gg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"ggplot object.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/rtable2gg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert rtable objects to ggplot objects — rtable2gg","text":"","code":"dta <- data.frame( ARM = rep(LETTERS[1:3], rep(6, 3)), AVISIT = rep(paste0(\"V\", 1:3), 6), AVAL = c(9:1, rep(NA, 9)) ) lyt <- basic_table() %>% split_cols_by(var = \"ARM\") %>% split_rows_by(var = \"AVISIT\") %>% analyze_vars(vars = \"AVAL\") tbl <- build_table(lyt, df = dta) rtable2gg(tbl) rtable2gg(tbl, fontsize = 15, colwidths = c(2, 1, 1, 1))"},{"path":"https://insightsengineering.github.io/tern/main/reference/rtables_access.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper functions for accessing information from rtables — rtables_access","title":"Helper functions for accessing information from rtables — rtables_access","text":"couple functions help accessing data rtables objects. Currently work occurrence tables, defined count first element fraction second element cell.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/rtables_access.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper functions for accessing information from rtables — rtables_access","text":"","code":"h_row_first_values(table_row, col_names = NULL, col_indices = NULL) h_row_counts(table_row, col_names = NULL, col_indices = NULL) h_row_fractions(table_row, col_names = NULL, col_indices = NULL) h_col_counts(table, col_names = NULL, col_indices = NULL) h_content_first_row(table) is_leaf_table(table) check_names_indices(table_row, col_names = NULL, col_indices = NULL)"},{"path":"https://insightsengineering.github.io/tern/main/reference/rtables_access.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper functions for accessing information from rtables — rtables_access","text":"table_row (TableRow) analysis row occurrence table. col_names (character) names columns extract . col_indices (integer) indices columns extract . col_names provided, inferred names table_row. Note currently works well single column split. table (VTableNodeInfo) occurrence table row.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/rtables_access.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper functions for accessing information from rtables — rtables_access","text":"h_row_first_values() returns vector numeric values. h_row_counts() returns vector numeric values. h_row_fractions() returns vector proportions. h_col_counts() returns vector column counts. h_content_first_row() returns row rtables table. is_leaf_table() returns logical value indicating whether current table leaf. check_names_indices returns column indices.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/rtables_access.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Helper functions for accessing information from rtables — rtables_access","text":"h_row_first_values(): Helper function extract first values content cell specified columns TableRow. Defaults columns. h_row_counts(): Helper function extracts row values checks convertible integers (integerish values). h_row_fractions(): Helper function extract fractions specified columns TableRow. specifically extracts second values content cell checks fraction. h_col_counts(): Helper function extract column counts specified columns table. h_content_first_row(): Helper function get first row content table current table. is_leaf_table(): Helper function says whether current table leaf tree. check_names_indices(): Internal helper function tests standard inputs column indices.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/rtables_access.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper functions for accessing information from rtables — rtables_access","text":"","code":"tbl <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"RACE\") %>% analyze(\"AGE\", function(x) { list( \"mean (sd)\" = rcell(c(mean(x), sd(x)), format = \"xx.x (xx.x)\"), \"n\" = length(x), \"frac\" = rcell(c(0.1, 0.1), format = \"xx (xx)\") ) }) %>% build_table(tern_ex_adsl) %>% prune_table() tree_row_elem <- collect_leaves(tbl[2, ])[[1]] result <- max(h_row_first_values(tree_row_elem)) result #> [1] 35.31214 # Row counts (integer values) # h_row_counts(tree_row_elem) # Fails because there are no integers # Using values with integers tree_row_elem <- collect_leaves(tbl[3, ])[[1]] result <- h_row_counts(tree_row_elem) # result # Row fractions tree_row_elem <- collect_leaves(tbl[4, ])[[1]] h_row_fractions(tree_row_elem) #> A: Drug X B: Placebo C: Combination #> 0.1 0.1 0.1"},{"path":"https://insightsengineering.github.io/tern/main/reference/s_bland_altman.html","id":null,"dir":"Reference","previous_headings":"","what":"Bland-Altman analysis — s_bland_altman","title":"Bland-Altman analysis — s_bland_altman","text":"Statistics function uses Bland-Altman method assess agreement two numerical vectors calculates variety statistics.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/s_bland_altman.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bland-Altman analysis — s_bland_altman","text":"","code":"s_bland_altman(x, y, conf_level = 0.95)"},{"path":"https://insightsengineering.github.io/tern/main/reference/s_bland_altman.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bland-Altman analysis — s_bland_altman","text":"x (numeric) vector numbers want analyze. y (numeric) vector numbers want analyze, compared x. conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/s_bland_altman.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bland-Altman analysis — s_bland_altman","text":"named list following elements: df difference_mean ci_mean difference_sd difference_se upper_agreement_limit lower_agreement_limit agreement_limit_se upper_agreement_limit_ci lower_agreement_limit_ci t_value n","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/s_bland_altman.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Bland-Altman analysis — s_bland_altman","text":"","code":"x <- seq(1, 60, 5) y <- seq(5, 50, 4) s_bland_altman(x, y, conf_level = 0.9) #> $df #> average difference #> 1 3.0 -4 #> 2 7.5 -3 #> 3 12.0 -2 #> 4 16.5 -1 #> 5 21.0 0 #> 6 25.5 1 #> 7 30.0 2 #> 8 34.5 3 #> 9 39.0 4 #> 10 43.5 5 #> 11 48.0 6 #> 12 52.5 7 #> #> $difference_mean #> [1] 1.5 #> #> $ci_mean #> [1] -0.3692162 3.3692162 #> #> $difference_sd #> [1] 3.605551 #> #> $difference_se #> [1] 1.040833 #> #> $upper_agreement_limit #> [1] 7.430604 #> #> $lower_agreement_limit #> [1] -4.430604 #> #> $agreement_limit_se #> [1] 1.802776 #> #> $upper_agreement_limit_ci #> [1] 4.193027 10.668181 #> #> $lower_agreement_limit_ci #> [1] -7.668181 -1.193027 #> #> $t_value #> [1] 1.795885 #> #> $n #> [1] 12 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/s_cox_multivariate.html","id":null,"dir":"Reference","previous_headings":"","what":"Multivariate Cox model - summarized results — s_cox_multivariate","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"Analyses based multivariate Cox model usually performed Controlled Substance Reporting regulatory documents serve exploratory purposes (e.g., publication). practice, model usually includes main effects (without interaction terms). produces hazard ratio estimates covariates included model. analysis follows principles (e.g., stratified vs. unstratified analysis tie handling) usual Cox model analysis. Since usually pre-specified hypothesis testing analysis, p.values need interpreted caution. (Statistical Analysis Clinical Trials Data R, NEST's bookdown)","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/s_cox_multivariate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"","code":"s_cox_multivariate( formula, data, conf_level = 0.95, pval_method = c(\"wald\", \"likelihood\"), ... )"},{"path":"https://insightsengineering.github.io/tern/main/reference/s_cox_multivariate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"formula (formula) formula corresponding investigated survival::Surv() survival model including covariates. data (data.frame) data frame includes variable formula covariates. conf_level (proportion) confidence level hazard ratio interval estimations. Default 0.95. pval_method (string) method used estimation p-values, one \"wald\" (default) \"likelihood\". ... optional parameters passed survival::coxph(). Can include ties, character string specifying method tie handling, one exact (default), efron, breslow.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/s_cox_multivariate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"list elements mod, msum, aov, coef_inter.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/s_cox_multivariate.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"output limited single effect terms. Work ongoing estimation interaction terms scope defined Global Data Standards Repository (GDS_Standard_TLG_Specs_Tables_2.doc).","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/s_cox_multivariate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multivariate Cox model - summarized results — s_cox_multivariate","text":"","code":"library(dplyr) adtte <- tern_ex_adtte adtte_f <- subset(adtte, PARAMCD == \"OS\") # _f: filtered adtte_f <- filter( adtte_f, PARAMCD == \"OS\" & SEX %in% c(\"F\", \"M\") & RACE %in% c(\"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"WHITE\") ) adtte_f$SEX <- droplevels(adtte_f$SEX) adtte_f$RACE <- droplevels(adtte_f$RACE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/sas_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert strings to NA — sas_na","title":"Convert strings to NA — sas_na","text":"SAS imports missing data empty strings strings whitespaces . helper function can used convert values NAs.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/sas_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert strings to NA — sas_na","text":"","code":"sas_na(x, empty = TRUE, whitespaces = TRUE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/sas_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert strings to NA — sas_na","text":"x (factor character) values missing values substituted. empty (flag) TRUE, empty strings get replaced NA. whitespaces (flag) TRUE, strings made whitespaces get replaced NA.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/sas_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert strings to NA — sas_na","text":"x \"\" /whitespace-values substituted NA, depending values empty whitespaces.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/sas_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert strings to NA — sas_na","text":"","code":"sas_na(c(\"1\", \"\", \" \", \" \", \"b\")) #> [1] \"1\" NA NA NA \"b\" sas_na(factor(c(\"\", \" \", \"b\"))) #> [1] b #> Levels: b is.na(sas_na(c(\"1\", \"\", \" \", \" \", \"b\"))) #> [1] FALSE TRUE TRUE TRUE FALSE"},{"path":"https://insightsengineering.github.io/tern/main/reference/score_occurrences.html","id":null,"dir":"Reference","previous_headings":"","what":"Occurrence table sorting — score_occurrences","title":"Occurrence table sorting — score_occurrences","text":"Functions score occurrence table subtables rows can used sorting occurrence tables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/score_occurrences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Occurrence table sorting — score_occurrences","text":"","code":"score_occurrences(table_row) score_occurrences_cols(...) score_occurrences_subtable(...) score_occurrences_cont_cols(...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/score_occurrences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Occurrence table sorting — score_occurrences","text":"table_row (TableRow) analysis row occurrence table. ... arguments row column access, see rtables_access: either col_names (character) including names columns used, alternatively col_indices (integer) giving indices directly instead.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/score_occurrences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Occurrence table sorting — score_occurrences","text":"score_occurrences() returns sum counts across columns table row. score_occurrences_cols() returns function sums counts across specified columns table row. score_occurrences_subtable() returns function sums counts subtable across specified columns. score_occurrences_cont_cols() returns function sums counts first content row specified columns.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/score_occurrences.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Occurrence table sorting — score_occurrences","text":"score_occurrences(): Scoring function sums counts across columns. fail anything else counts used. score_occurrences_cols(): Scoring functions can produced constructor include specific columns scoring. See h_row_counts() information. score_occurrences_subtable(): Scoring functions produced constructor can used subtables: sum specified column counts subtable. useful available content row summing counts. score_occurrences_cont_cols(): Produces score function sorting table summing first content row specified columns. Note extending rtables::cont_n_onecol() rtables::cont_n_allcols().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/score_occurrences.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Occurrence table sorting — score_occurrences","text":"","code":"lyt <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% analyze_num_patients( vars = \"USUBJID\", .stats = c(\"unique\"), .labels = c(\"Total number of patients with at least one event\") ) %>% split_rows_by(\"AEBODSYS\", child_labels = \"visible\", nested = FALSE) %>% summarize_num_patients( var = \"USUBJID\", .stats = c(\"unique\", \"nonunique\"), .labels = c( \"Total number of patients with at least one event\", \"Total number of events\" ) ) %>% count_occurrences(vars = \"AEDECOD\") tbl <- build_table(lyt, tern_ex_adae, alt_counts_df = tern_ex_adsl) %>% prune_table() tbl_sorted <- tbl %>% sort_at_path(path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"), scorefun = score_occurrences) tbl_sorted #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> cl D.1 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 20 (34.5%) #> Total number of events 39 35 28 #> dcd D.1.1.4.2 16 (23.2%) 13 (17.8%) 16 (27.6%) #> dcd D.1.1.1.1 17 (24.6%) 18 (24.7%) 7 (12.1%) #> cl C.1 #> Total number of patients with at least one event 15 (21.7%) 13 (17.8%) 18 (31.0%) #> Total number of events 17 15 19 #> dcd C.1.1.1.3 15 (21.7%) 13 (17.8%) 18 (31.0%) #> cl C.2 #> Total number of patients with at least one event 20 (29.0%) 14 (19.2%) 10 (17.2%) #> Total number of events 21 15 14 #> dcd C.2.1.2.1 20 (29.0%) 14 (19.2%) 10 (17.2%) #> cl B.2 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 24 (41.4%) #> Total number of events 40 38 33 #> dcd B.2.2.3.1 17 (24.6%) 15 (20.5%) 16 (27.6%) #> dcd B.2.1.2.1 17 (24.6%) 16 (21.9%) 13 (22.4%) #> cl B.1 #> Total number of patients with at least one event 15 (21.7%) 19 (26.0%) 15 (25.9%) #> Total number of events 19 19 18 #> dcd B.1.1.1.1 15 (21.7%) 19 (26.0%) 15 (25.9%) #> cl D.2 #> Total number of patients with at least one event 21 (30.4%) 20 (27.4%) 12 (20.7%) #> Total number of events 27 22 15 #> dcd D.2.1.5.3 21 (30.4%) 20 (27.4%) 12 (20.7%) #> cl A.1 #> Total number of patients with at least one event 31 (44.9%) 24 (32.9%) 27 (46.6%) #> Total number of events 39 33 35 #> dcd A.1.1.1.1 17 (24.6%) 17 (23.3%) 14 (24.1%) #> dcd A.1.1.1.2 17 (24.6%) 14 (19.2%) 17 (29.3%) score_cols_a_and_b <- score_occurrences_cols(col_names = c(\"A: Drug X\", \"B: Placebo\")) # Note that this here just sorts the AEDECOD inside the AEBODSYS. The AEBODSYS are not sorted. # That would require a second pass of `sort_at_path`. tbl_sorted <- tbl %>% sort_at_path(path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"), scorefun = score_cols_a_and_b) tbl_sorted #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> cl D.1 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 20 (34.5%) #> Total number of events 39 35 28 #> dcd D.1.1.1.1 17 (24.6%) 18 (24.7%) 7 (12.1%) #> dcd D.1.1.4.2 16 (23.2%) 13 (17.8%) 16 (27.6%) #> cl C.1 #> Total number of patients with at least one event 15 (21.7%) 13 (17.8%) 18 (31.0%) #> Total number of events 17 15 19 #> dcd C.1.1.1.3 15 (21.7%) 13 (17.8%) 18 (31.0%) #> cl C.2 #> Total number of patients with at least one event 20 (29.0%) 14 (19.2%) 10 (17.2%) #> Total number of events 21 15 14 #> dcd C.2.1.2.1 20 (29.0%) 14 (19.2%) 10 (17.2%) #> cl B.2 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 24 (41.4%) #> Total number of events 40 38 33 #> dcd B.2.1.2.1 17 (24.6%) 16 (21.9%) 13 (22.4%) #> dcd B.2.2.3.1 17 (24.6%) 15 (20.5%) 16 (27.6%) #> cl B.1 #> Total number of patients with at least one event 15 (21.7%) 19 (26.0%) 15 (25.9%) #> Total number of events 19 19 18 #> dcd B.1.1.1.1 15 (21.7%) 19 (26.0%) 15 (25.9%) #> cl D.2 #> Total number of patients with at least one event 21 (30.4%) 20 (27.4%) 12 (20.7%) #> Total number of events 27 22 15 #> dcd D.2.1.5.3 21 (30.4%) 20 (27.4%) 12 (20.7%) #> cl A.1 #> Total number of patients with at least one event 31 (44.9%) 24 (32.9%) 27 (46.6%) #> Total number of events 39 33 35 #> dcd A.1.1.1.1 17 (24.6%) 17 (23.3%) 14 (24.1%) #> dcd A.1.1.1.2 17 (24.6%) 14 (19.2%) 17 (29.3%) score_subtable_all <- score_occurrences_subtable(col_names = names(tbl)) # Note that this code just sorts the AEBODSYS, not the AEDECOD within AEBODSYS. That # would require a second pass of `sort_at_path`. tbl_sorted <- tbl %>% sort_at_path(path = c(\"AEBODSYS\"), scorefun = score_subtable_all, decreasing = FALSE) tbl_sorted #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ————————————————————————————————————————————————————————————————————————————————————————————— #> Total number of patients with at least one event 59 (85.5%) 57 (78.1%) 48 (82.8%) #> cl C.2 #> Total number of patients with at least one event 20 (29.0%) 14 (19.2%) 10 (17.2%) #> Total number of events 21 15 14 #> dcd C.2.1.2.1 20 (29.0%) 14 (19.2%) 10 (17.2%) #> cl C.1 #> Total number of patients with at least one event 15 (21.7%) 13 (17.8%) 18 (31.0%) #> Total number of events 17 15 19 #> dcd C.1.1.1.3 15 (21.7%) 13 (17.8%) 18 (31.0%) #> cl B.1 #> Total number of patients with at least one event 15 (21.7%) 19 (26.0%) 15 (25.9%) #> Total number of events 19 19 18 #> dcd B.1.1.1.1 15 (21.7%) 19 (26.0%) 15 (25.9%) #> cl D.2 #> Total number of patients with at least one event 21 (30.4%) 20 (27.4%) 12 (20.7%) #> Total number of events 27 22 15 #> dcd D.2.1.5.3 21 (30.4%) 20 (27.4%) 12 (20.7%) #> cl D.1 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 20 (34.5%) #> Total number of events 39 35 28 #> dcd D.1.1.1.1 17 (24.6%) 18 (24.7%) 7 (12.1%) #> dcd D.1.1.4.2 16 (23.2%) 13 (17.8%) 16 (27.6%) #> cl B.2 #> Total number of patients with at least one event 29 (42.0%) 27 (37.0%) 24 (41.4%) #> Total number of events 40 38 33 #> dcd B.2.1.2.1 17 (24.6%) 16 (21.9%) 13 (22.4%) #> dcd B.2.2.3.1 17 (24.6%) 15 (20.5%) 16 (27.6%) #> cl A.1 #> Total number of patients with at least one event 31 (44.9%) 24 (32.9%) 27 (46.6%) #> Total number of events 39 33 35 #> dcd A.1.1.1.1 17 (24.6%) 17 (23.3%) 14 (24.1%) #> dcd A.1.1.1.2 17 (24.6%) 14 (19.2%) 17 (29.3%)"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/split_cols_by_groups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split columns by groups of levels — split_cols_by_groups","text":"","code":"split_cols_by_groups(lyt, var, groups_list = NULL, ref_group = NULL, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/split_cols_by_groups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split columns by groups of levels — split_cols_by_groups","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. groups_list (named list character) specifies new group levels via names levels belong character vectors elements list. ref_group (data.frame vector) data corresponding reference group. ... additional arguments rtables::split_cols_by() order. instance, control formats (format), add joint column groups (incl_all).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/split_cols_by_groups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split columns by groups of levels — split_cols_by_groups","text":"layout object suitable passing layouting functions. Adding function rtable layout add column split including given groups table layout.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/split_cols_by_groups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split columns by groups of levels — split_cols_by_groups","text":"","code":"# 1 - Basic use # Without group combination `split_cols_by_groups` is # equivalent to [rtables::split_cols_by()]. basic_table() %>% split_cols_by_groups(\"ARM\") %>% add_colcounts() %>% analyze(\"AGE\") %>% build_table(DM) #> A: Drug X B: Placebo C: Combination #> (N=121) (N=106) (N=129) #> —————————————————————————————————————————————— #> Mean 34.91 33.02 34.57 # Add a reference column. basic_table() %>% split_cols_by_groups(\"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% analyze( \"AGE\", afun = function(x, .ref_group, .in_ref_col) { if (.in_ref_col) { in_rows(\"Diff Mean\" = rcell(NULL)) } else { in_rows(\"Diff Mean\" = rcell(mean(x) - mean(.ref_group), format = \"xx.xx\")) } } ) %>% build_table(DM) #> A: Drug X B: Placebo C: Combination #> (N=121) (N=106) (N=129) #> ——————————————————————————————————————————————————— #> Diff Mean 1.89 1.55 # 2 - Adding group specification # Manual preparation of the groups. groups <- list( \"Arms A+B\" = c(\"A: Drug X\", \"B: Placebo\"), \"Arms A+C\" = c(\"A: Drug X\", \"C: Combination\") ) # Use of split_cols_by_groups without reference column. basic_table() %>% split_cols_by_groups(\"ARM\", groups) %>% add_colcounts() %>% analyze(\"AGE\") %>% build_table(DM) #> Arms A+B Arms A+C #> (N=227) (N=250) #> —————————————————————————— #> Mean 34.03 34.73 # Including differentiated output in the reference column. basic_table() %>% split_cols_by_groups(\"ARM\", groups_list = groups, ref_group = \"Arms A+B\") %>% analyze( \"AGE\", afun = function(x, .ref_group, .in_ref_col) { if (.in_ref_col) { in_rows(\"Diff. of Averages\" = rcell(NULL)) } else { in_rows(\"Diff. of Averages\" = rcell(mean(x) - mean(.ref_group), format = \"xx.xx\")) } } ) %>% build_table(DM) #> Arms A+B Arms A+C #> ——————————————————————————————————————— #> Diff. of Averages 0.71 # 3 - Binary list dividing factor levels into reference and treatment # `combine_groups` defines reference and treatment. groups <- combine_groups( fct = DM$ARM, ref = c(\"A: Drug X\", \"B: Placebo\") ) groups #> $`A: Drug X/B: Placebo` #> [1] \"A: Drug X\" \"B: Placebo\" #> #> $`C: Combination` #> [1] \"C: Combination\" #> # Use group definition without reference column. basic_table() %>% split_cols_by_groups(\"ARM\", groups_list = groups) %>% add_colcounts() %>% analyze(\"AGE\") %>% build_table(DM) #> A: Drug X/B: Placebo C: Combination #> (N=227) (N=129) #> ———————————————————————————————————————————— #> Mean 34.03 34.57 # Use group definition with reference column (first item of groups). basic_table() %>% split_cols_by_groups(\"ARM\", groups, ref_group = names(groups)[1]) %>% add_colcounts() %>% analyze( \"AGE\", afun = function(x, .ref_group, .in_ref_col) { if (.in_ref_col) { in_rows(\"Diff Mean\" = rcell(NULL)) } else { in_rows(\"Diff Mean\" = rcell(mean(x) - mean(.ref_group), format = \"xx.xx\")) } } ) %>% build_table(DM) #> A: Drug X/B: Placebo C: Combination #> (N=227) (N=129) #> ————————————————————————————————————————————————— #> Diff Mean 0.54"},{"path":"https://insightsengineering.github.io/tern/main/reference/split_text_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Split text according to available text width — split_text_grob","title":"Split text according to available text width — split_text_grob","text":"Dynamically wrap text.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/split_text_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split text according to available text width — split_text_grob","text":"","code":"split_text_grob( text, x = grid::unit(0.5, \"npc\"), y = grid::unit(0.5, \"npc\"), width = grid::unit(1, \"npc\"), just = \"centre\", hjust = NULL, vjust = NULL, default.units = \"npc\", name = NULL, gp = grid::gpar(), vp = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/split_text_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Split text according to available text width — split_text_grob","text":"text (string) text wrap. x numeric vector unit object specifying x-values. y numeric vector unit object specifying y-values. width (grid::unit) unit object specifying maximum width text. just justification text relative (x, y) location. two values, first value specifies horizontal justification second value specifies vertical justification. Possible string values : \"left\", \"right\", \"centre\", \"center\", \"bottom\", \"top\". numeric values, 0 means left (bottom) alignment 1 means right (top) alignment. hjust numeric vector specifying horizontal justification. specified, overrides just setting. vjust numeric vector specifying vertical justification. specified, overrides just setting. default.units string indicating default units use x y given numeric vectors. name character identifier. gp object class \"gpar\", typically output call function gpar. basically list graphical parameter settings. vp Grid viewport object (NULL).","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/split_text_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Split text according to available text width — split_text_grob","text":"text grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/split_text_grob.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Split text according to available text width — split_text_grob","text":"code taken R Graphics Paul Murell, 2nd edition","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stack_grobs.html","id":null,"dir":"Reference","previous_headings":"","what":"Stack multiple grobs — stack_grobs","title":"Stack multiple grobs — stack_grobs","text":"Stack grobs new grob 1 column multiple rows layout.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stack_grobs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stack multiple grobs — stack_grobs","text":"","code":"stack_grobs( ..., grobs = list(...), padding = grid::unit(2, \"line\"), vp = NULL, gp = NULL, name = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/stack_grobs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stack multiple grobs — stack_grobs","text":"... grobs. grobs (list grob) list grobs. padding (grid::unit) unit length 1, space grob. vp (viewport NULL) viewport() object (NULL). gp (gpar) gpar() object. name (string) character identifier grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stack_grobs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stack multiple grobs — stack_grobs","text":"grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stack_grobs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stack multiple grobs — stack_grobs","text":"","code":"library(grid) g1 <- circleGrob(gp = gpar(col = \"blue\")) g2 <- circleGrob(gp = gpar(col = \"red\")) g3 <- textGrob(\"TEST TEXT\") grid.newpage() grid.draw(stack_grobs(g1, g2, g3)) showViewport() grid.newpage() pushViewport(viewport(layout = grid.layout(1, 2))) vp1 <- viewport(layout.pos.row = 1, layout.pos.col = 2) grid.draw(stack_grobs(g1, g2, g3, vp = vp1, name = \"test\")) showViewport() grid.ls(grobs = TRUE, viewports = TRUE, print = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence interval for mean — stat_mean_ci","title":"Confidence interval for mean — stat_mean_ci","text":"Convenient function calculating mean confidence interval. calculates arithmetic well geometric mean. can used ggplot helper function plotting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence interval for mean — stat_mean_ci","text":"","code":"stat_mean_ci( x, conf_level = 0.95, na.rm = TRUE, n_min = 2, gg_helper = TRUE, geom_mean = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence interval for mean — stat_mean_ci","text":"x (numeric) vector numbers want analyze. conf_level (proportion) confidence level interval. na.rm (flag) whether NA values removed x prior analysis. n_min (numeric(1)) minimum number non-missing x estimate confidence interval mean. gg_helper (flag) whether output aligned use ggplots. geom_mean (flag) whether geometric mean calculated.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence interval for mean — stat_mean_ci","text":"named vector values mean_ci_lwr mean_ci_upr.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence interval for mean — stat_mean_ci","text":"","code":"stat_mean_ci(sample(10), gg_helper = FALSE) #> mean_ci_lwr mean_ci_upr #> 3.334149 7.665851 p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) + ggplot2::geom_point() p + ggplot2::stat_summary( fun.data = stat_mean_ci, geom = \"errorbar\" ) p + ggplot2::stat_summary( fun.data = stat_mean_ci, fun.args = list(conf_level = 0.5), geom = \"errorbar\" ) p + ggplot2::stat_summary( fun.data = stat_mean_ci, fun.args = list(conf_level = 0.5, geom_mean = TRUE), geom = \"errorbar\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_pval.html","id":null,"dir":"Reference","previous_headings":"","what":"p-Value of the mean — stat_mean_pval","title":"p-Value of the mean — stat_mean_pval","text":"Convenient function calculating two-sided p-value mean.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_pval.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"p-Value of the mean — stat_mean_pval","text":"","code":"stat_mean_pval(x, na.rm = TRUE, n_min = 2, test_mean = 0)"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_pval.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"p-Value of the mean — stat_mean_pval","text":"x (numeric) vector numbers want analyze. na.rm (flag) whether NA values removed x prior analysis. n_min (numeric(1)) minimum number non-missing x estimate p-value mean. test_mean (numeric(1)) mean value test null hypothesis.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_pval.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"p-Value of the mean — stat_mean_pval","text":"p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_mean_pval.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"p-Value of the mean — stat_mean_pval","text":"","code":"stat_mean_pval(sample(10)) #> p_value #> 0.000278196 stat_mean_pval(rnorm(10), test_mean = 0.5) #> p_value #> 0.04235675"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_median_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence interval for median — stat_median_ci","title":"Confidence interval for median — stat_median_ci","text":"Convenient function calculating median confidence interval. can used ggplot helper function plotting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_median_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence interval for median — stat_median_ci","text":"","code":"stat_median_ci(x, conf_level = 0.95, na.rm = TRUE, gg_helper = TRUE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_median_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence interval for median — stat_median_ci","text":"x (numeric) vector numbers want analyze. conf_level (proportion) confidence level interval. na.rm (flag) whether NA values removed x prior analysis. gg_helper (flag) whether output aligned use ggplots.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_median_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence interval for median — stat_median_ci","text":"named vector values median_ci_lwr median_ci_upr.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_median_ci.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Confidence interval for median — stat_median_ci","text":"function adapted DescTools/versions/0.99.35/source","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_median_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence interval for median — stat_median_ci","text":"","code":"stat_median_ci(sample(10), gg_helper = FALSE) #> median_ci_lwr median_ci_upr #> 2 9 #> attr(,\"conf_level\") #> [1] 0.9785156 p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) + ggplot2::geom_point() p + ggplot2::stat_summary( fun.data = stat_median_ci, geom = \"errorbar\" )"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_propdiff_ci.html","id":null,"dir":"Reference","previous_headings":"","what":"Proportion difference and confidence interval — stat_propdiff_ci","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"Function calculating proportion (risk) difference confidence interval arm X (reference group) arm Y. Risk difference calculated subtracting cumulative incidence arm Y cumulative incidence arm X.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_propdiff_ci.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"","code":"stat_propdiff_ci( x, y, N_x, N_y, list_names = NULL, conf_level = 0.95, pct = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_propdiff_ci.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"x (list integer) list number occurrences arm X (reference group). y (list integer) list number occurrences arm Y. Must equal length x. N_x (numeric(1)) total number records arm X. N_y (numeric(1)) total number records arm Y. list_names (character) names variable/level corresponding pair proportions x y. Must equal length x y. conf_level (proportion) confidence level interval. pct (flag) whether output returned percentages. Defaults TRUE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_propdiff_ci.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"List proportion differences CIs corresponding pair number occurrences x y. list element consists 3 statistics: proportion difference, CI lower bound, CI upper bound.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/stat_propdiff_ci.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Proportion difference and confidence interval — stat_propdiff_ci","text":"","code":"stat_propdiff_ci( x = list(0.375), y = list(0.01), N_x = 5, N_y = 5, list_names = \"x\", conf_level = 0.9 ) #> $x #> [1] 7.30000 -12.35184 26.95184 #> stat_propdiff_ci( x = list(0.5, 0.75, 1), y = list(0.25, 0.05, 0.5), N_x = 10, N_y = 20, pct = FALSE ) #> [[1]] #> [1] 0.0375000 -0.1060891 0.1810891 #> #> [[2]] #> [1] 0.07250000 -0.09220915 0.23720915 #> #> [[3]] #> [1] 0.0750000 -0.1231285 0.2731285 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/strata_normal_quantile.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"function wraps estimation stratified percentiles assume approximation large numbers. necessary case proportions strata unequal.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/strata_normal_quantile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"","code":"strata_normal_quantile(vars, weights, conf_level)"},{"path":"https://insightsengineering.github.io/tern/main/reference/strata_normal_quantile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"vars (character) variable names primary analysis variable iterated . weights (numeric NULL) weights level strata. NULL, estimated using iterative algorithm proposed Yan2010-jt;textualtern minimizes weighted squared length confidence interval. conf_level (proportion) confidence level interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/strata_normal_quantile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"Stratified quantile.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/strata_normal_quantile.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for the estimation of stratified quantiles — strata_normal_quantile","text":"","code":"strata_data <- table(data.frame( \"f1\" = sample(c(TRUE, FALSE), 100, TRUE), \"f2\" = sample(c(\"x\", \"y\", \"z\"), 100, TRUE), stringsAsFactors = TRUE )) ns <- colSums(strata_data) ests <- strata_data[\"TRUE\", ] / ns vars <- ests * (1 - ests) / ns weights <- rep(1 / length(ns), length(ns)) strata_normal_quantile(vars, weights, 0.95) #> [1] 1.14181"},{"path":"https://insightsengineering.github.io/tern/main/reference/study_arm.html","id":null,"dir":"Reference","previous_headings":"","what":"Indicate study arm variable in formula — study_arm","title":"Indicate study arm variable in formula — study_arm","text":"use study_arm indicate study arm variable tern formulas.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/study_arm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Indicate study arm variable in formula — study_arm","text":"","code":"study_arm(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/study_arm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Indicate study arm variable in formula — study_arm","text":"x arm information","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/study_arm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Indicate study arm variable in formula — study_arm","text":"x","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_ancova.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"analyze function summarize_ancova() creates layout element summarize ANCOVA results. function can used analyze multiple endpoints /multiple timepoints within response variable(s) specified vars. Additional variables analysis, namely arm (grouping) variable covariate variables, can defined via variables argument. See details specify variables. interaction term can implemented model needed. interaction variable interact arm variable specified via interaction_term parameter, specific value interaction_term extract ANCOVA results via interaction_y parameter.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_ancova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"","code":"summarize_ancova( lyt, vars, variables, conf_level, interaction_y = FALSE, interaction_item = NULL, var_labels, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"visible\", table_names = vars, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_ancova( df, .var, .df_row, variables, .ref_group, .in_ref_col, conf_level, interaction_y = FALSE, interaction_item = NULL ) a_ancova( df, .var, .df_row, variables, .ref_group, .in_ref_col, conf_level, interaction_y = FALSE, interaction_item = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_ancova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". conf_level (proportion) confidence level interval. interaction_y (string flag) selected item inside interaction_item variable used select specific ANCOVA results. interaction needed, default option FALSE. interaction_item (string NULL) name variable interactions arm. interaction needed, default option NULL. var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'lsmean', 'lsmean_diff', 'lsmean_diff_ci', 'pval' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) data set includes variables called .var variables. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_ancova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"summarize_ancova() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_ancova() table layout. s_ancova() returns named list 5 statistics: n: Count complete sample size group. lsmean: Estimated marginal means group. lsmean_diff: Difference estimated marginal means comparison reference group. working reference group, empty. lsmean_diff_ci: Confidence level difference estimated marginal means comparison reference group. pval: p-value (adjusted multiple comparisons). a_ancova() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_ancova.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"summarize_ancova(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_ancova(): Statistics function produces named list results investigated linear model. a_ancova(): Formatted analysis function used afun summarize_ancova().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_ancova.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize analysis of covariance (ANCOVA) results — summarize_ancova","text":"","code":"basic_table() %>% split_cols_by(\"Species\", ref_group = \"setosa\") %>% add_colcounts() %>% summarize_ancova( vars = \"Petal.Length\", variables = list(arm = \"Species\", covariates = NULL), table_names = \"unadj\", conf_level = 0.95, var_labels = \"Unadjusted comparison\", .labels = c(lsmean = \"Mean\", lsmean_diff = \"Difference in Means\") ) %>% summarize_ancova( vars = \"Petal.Length\", variables = list(arm = \"Species\", covariates = c(\"Sepal.Length\", \"Sepal.Width\")), table_names = \"adj\", conf_level = 0.95, var_labels = \"Adjusted comparison (covariates: Sepal.Length and Sepal.Width)\" ) %>% build_table(iris) #> setosa versicolor virginica #> (N=50) (N=50) (N=50) #> ————————————————————————————————————————————————————————————————————————————————————————————————————— #> Unadjusted comparison #> n 50 50 50 #> Mean 1.46 4.26 5.55 #> Difference in Means 2.80 4.09 #> 95% CI (2.63, 2.97) (3.92, 4.26) #> p-value <0.0001 <0.0001 #> Adjusted comparison (covariates: Sepal.Length and Sepal.Width) #> n 50 50 50 #> Adjusted Mean 2.02 4.19 5.07 #> Difference in Adjusted Means 2.17 3.05 #> 95% CI (1.96, 2.38) (2.81, 3.29) #> p-value <0.0001 <0.0001"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize change from baseline values or absolute baseline values — summarize_change","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"analyze function summarize_change() creates layout element summarize change baseline absolute baseline values. primary analysis variable vars indicates numerical change baseline results. Required secondary analysis variables value baseline_flag can supplied function via variables argument. value element name analysis value variable, baseline_flag element name flag variable indicates whether records contain baseline values. Depending baseline flag given, either absolute baseline values (baseline) change baseline values (post-baseline) summarized.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"","code":"summarize_change( lyt, vars, variables, var_labels = vars, na_str = default_na_str(), na_rm = TRUE, nested = TRUE, show_labels = \"default\", table_names = vars, section_div = NA_character_, ..., .stats = c(\"n\", \"mean_sd\", \"median\", \"range\"), .formats = c(n = \"xx\", mean_sd = \"xx.xx (xx.xx)\", mean_se = \"xx.xx (xx.xx)\", median = \"xx.xx\", range = \"xx.xx - xx.xx\", mean_ci = \"(xx.xx, xx.xx)\", median_ci = \"(xx.xx, xx.xx)\", mean_pval = \"xx.xx\"), .labels = c(mean_sd = \"Mean (SD)\", mean_se = \"Mean (SE)\", median = \"Median\", range = \"Min - Max\"), .indent_mods = NULL ) s_change_from_baseline(df, ...) a_change_from_baseline( df, ..., .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables. var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. section_div (string) string repeated section divider group defined split instruction, NA_character_ (default) section divider. ... additional arguments lower level functions. .stats (character) statistics select table. Options : 'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"summarize_change() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_change_from_baseline() table layout. s_change_from_baseline() returns values returned s_summary.numeric(). a_change_from_baseline() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"summarize_change(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_change_from_baseline(): Statistics function summarizes baseline post-baseline visits. a_change_from_baseline(): Formatted analysis function used afun summarize_change().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"used split visits layout, data subset contains either baseline post-baseline data. data df must either baseline post-baseline visits. Otherwise error thrown.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_change.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize change from baseline values or absolute baseline values — summarize_change","text":"","code":"library(dplyr) # Fabricate dataset dta_test <- data.frame( USUBJID = rep(1:6, each = 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)) ) %>% mutate(ABLFLL = AVISIT == \"V1\") %>% group_by(USUBJID) %>% mutate( BLVAL = AVAL[ABLFLL], CHG = AVAL - BLVAL ) %>% ungroup() results <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% summarize_change(\"CHG\", variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\")) %>% build_table(dta_test) results #> A B C #> ——————————————————————————————————————————————————————————— #> V1 #> n 2 1 0 #> Mean (SD) 7.50 (2.12) 3.00 () #> Median 7.50 3.00 #> Min - Max 6.00 - 9.00 3.00 - 3.00 #> V2 #> n 2 1 0 #> Mean (SD) -1.00 (0.00) -1.00 () #> Median -1.00 -1.00 #> Min - Max -1.00 - -1.00 -1.00 - -1.00 #> V3 #> n 2 1 0 #> Mean (SD) -2.00 (0.00) -2.00 () #> Median -2.00 -2.00 #> Min - Max -2.00 - -2.00 -2.00 - -2.00 "},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_colvars.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize variables in columns — summarize_colvars","title":"Summarize variables in columns — summarize_colvars","text":"analyze function summarize_colvars() uses statistics function s_summary() analyze variables arranged columns. variables analyze specified table layout via column splits (see rtables::split_cols_by() rtables::split_cols_by_multivar()) prior using summarize_colvars(). function minimal wrapper rtables::analyze_colvars(), function typically used apply different analysis methods rows column variable. use analysis methods column labels, please refer analyze_vars_in_cols() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_colvars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize variables in columns — summarize_colvars","text":"","code":"summarize_colvars( lyt, ..., na_str = default_na_str(), .stats = c(\"n\", \"mean_sd\", \"median\", \"range\", \"count_fraction\"), .formats = NULL, .labels = NULL, .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_colvars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize variables in columns — summarize_colvars","text":"lyt (PreDataTableLayouts) layout analyses added . ... arguments passed s_summary(). na_str (string) string used replace NA empty values output. .stats (character) statistics select table. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named vector integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_colvars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize variables in columns — summarize_colvars","text":"layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout summarize given variables, arrange output columns, add table layout.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_colvars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize variables in columns — summarize_colvars","text":"","code":"dta_test <- data.frame( USUBJID = rep(1:6, each = 3), PARAMCD = rep(\"lab\", 6 * 3), AVISIT = rep(paste0(\"V\", 1:3), 6), ARM = rep(LETTERS[1:3], rep(6, 3)), AVAL = c(9:1, rep(NA, 9)), CHG = c(1:9, rep(NA, 9)) ) ## Default output within a `rtables` pipeline. basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% split_cols_by_multivar(vars = c(\"AVAL\", \"CHG\")) %>% summarize_colvars() %>% build_table(dta_test) #> A B C #> AVAL CHG AVAL CHG AVAL CHG #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> V1 #> n 2 2 1 1 0 0 #> Mean (SD) 7.5 (2.1) 2.5 (2.1) 3.0 () 7.0 () #> Median 7.5 2.5 3.0 7.0 #> Min - Max 6.0 - 9.0 1.0 - 4.0 3.0 - 3.0 7.0 - 7.0 #> V2 #> n 2 2 1 1 0 0 #> Mean (SD) 6.5 (2.1) 3.5 (2.1) 2.0 () 8.0 () #> Median 6.5 3.5 2.0 8.0 #> Min - Max 5.0 - 8.0 2.0 - 5.0 2.0 - 2.0 8.0 - 8.0 #> V3 #> n 2 2 1 1 0 0 #> Mean (SD) 5.5 (2.1) 4.5 (2.1) 1.0 () 9.0 () #> Median 5.5 4.5 1.0 9.0 #> Min - Max 4.0 - 7.0 3.0 - 6.0 1.0 - 1.0 9.0 - 9.0 ## Selection of statistics, formats and labels also work. basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% split_cols_by_multivar(vars = c(\"AVAL\", \"CHG\")) %>% summarize_colvars( .stats = c(\"n\", \"mean_sd\"), .formats = c(\"mean_sd\" = \"xx.x, xx.x\"), .labels = c(n = \"n\", mean_sd = \"Mean, SD\") ) %>% build_table(dta_test) #> A B C #> AVAL CHG AVAL CHG AVAL CHG #> —————————————————————————————————————————————————————————————————————————————————————————— #> V1 #> n 2 2 1 1 0 0 #> Mean, SD 7.5, 2.1 2.5, 2.1 3.0, 7.0, #> V2 #> n 2 2 1 1 0 0 #> Mean, SD 6.5, 2.1 3.5, 2.1 2.0, 8.0, #> V3 #> n 2 2 1 1 0 0 #> Mean, SD 5.5, 2.1 4.5, 2.1 1.0, 9.0, ## Use arguments interpreted by `s_summary`. basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"AVISIT\") %>% split_cols_by_multivar(vars = c(\"AVAL\", \"CHG\")) %>% summarize_colvars(na.rm = FALSE) %>% build_table(dta_test) #> A B C #> AVAL CHG AVAL CHG AVAL CHG #> ——————————————————————————————————————————————————————————————————————————————————————————————— #> V1 #> n 2 2 1 1 0 0 #> Mean (SD) 7.5 (2.1) 2.5 (2.1) 3.0 () 7.0 () #> Median 7.5 2.5 3.0 7.0 #> Min - Max 6.0 - 9.0 1.0 - 4.0 3.0 - 3.0 7.0 - 7.0 #> V2 #> n 2 2 1 1 0 0 #> Mean (SD) 6.5 (2.1) 3.5 (2.1) 2.0 () 8.0 () #> Median 6.5 3.5 2.0 8.0 #> Min - Max 5.0 - 8.0 2.0 - 5.0 2.0 - 2.0 8.0 - 8.0 #> V3 #> n 2 2 1 1 0 0 #> Mean (SD) 5.5 (2.1) 4.5 (2.1) 1.0 () 9.0 () #> Median 5.5 4.5 1.0 9.0 #> Min - Max 4.0 - 7.0 3.0 - 6.0 1.0 - 1.0 9.0 - 9.0 "},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_functions.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize functions — summarize_functions","title":"Summarize functions — summarize_functions","text":"functions wrappers rtables::summarize_row_groups(), applying corresponding tern content functions add summary rows given table layout:","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_functions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize functions — summarize_functions","text":"add_rowcounts() estimate_multinomial_response() (rtables::analyze()) h_tab_one_biomarker() (probably deprecate) logistic_summary_by_flag() summarize_num_patients() summarize_occurrences() summarize_occurrences_by_grade() summarize_patients_events_in_cols() summarize_patients_exposure_in_cols() Additionally, summarize_coxreg() function utilizes rtables::summarize_row_groups() (combination several rtables functions like rtables::analyze_colvars()) output Cox regression summary table.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize Poisson negative binomial regression — summarize_glm_count","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"Summarize results Poisson negative binomial regression. can used analyze count /frequency data using linear model. specifically useful analyzing count data (using Poisson Negative Binomial distribution) result generalized linear model one (e.g. arm) covariates.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"","code":"summarize_glm_count( lyt, vars, variables, distribution, conf_level, rate_mean_method = c(\"emmeans\", \"ppmeans\")[1], weights = stats::weights, scale = 1, var_labels, na_str = default_na_str(), nested = TRUE, ..., show_labels = \"visible\", table_names = vars, .stats = get_stats(\"summarize_glm_count\"), .formats = NULL, .labels = NULL, .indent_mods = c(n = 0L, rate = 0L, rate_ci = 1L, rate_ratio = 0L, rate_ratio_ci = 1L, pval = 1L) ) s_glm_count( df, .var, .df_row, variables, .ref_group, .in_ref_col, distribution, conf_level, rate_mean_method, weights, scale = 1 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . variables (named list string) list additional analysis variables, expected elements: arm (string) group variable, covariate adjusted means multiple groups summarized. Specifically, first level arm variable taken reference group. covariates (character) vector can contain single variable names (\"X1\"), /interaction terms indicated \"X1 * X2\". offset (numeric) numeric vector scalar adding offset. distribution (character) character value specifying distribution used regression (Poisson, Quasi-Poisson, negative binomial). conf_level (proportion) confidence level interval. rate_mean_method (character(1)) method used estimate mean odds ratio. Defaults emmeans. see details information. weights (character) character vector specifying weights used averaging predictions. Number weights must equal number levels included covariates. Weights option passed emmeans::emmeans(). scale (numeric(1)) linear scaling factor rate confidence intervals. Defaults 1. var_labels (character) variable labels. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'n', 'rate', 'rate_ci', 'rate_ratio', 'rate_ratio_ci', 'pval' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .df_row (data.frame) dataset includes variables called .var variables. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"summarize_glm_count() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_glm_count() table layout. s_glm_count() returns named list 5 statistics: n: Count complete sample size group. rate: Estimated event rate per follow-time. rate_ci: Confidence level estimated rate per follow-time. rate_ratio: Ratio event rates treatment arm reference arm. rate_ratio_ci: Confidence level rate ratio. pval: p-value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"summarize_glm_count() uses s_glm_count() calculate statistics table. analysis function uses h_glm_count() estimate GLM stats::glm() Poisson Quasi-Poisson distributions MASS::glm.nb() Negative Binomial distribution. methods assume logarithmic link function. point, rates confidence intervals estimated model using either emmeans::emmeans() rate_mean_method = \"emmeans\" h_ppmeans() rate_mean_method = \"ppmeans\". reference group specified building table split_cols_by(ref_group), rate ratio p-value calculated. Otherwise, use emmeans::contrast() calculate rate ratio p-value reference group. Values always estimated method = \"trt.vs.ctrl\" ref equal first arm value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"summarize_glm_count(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_glm_count(): Statistics function produces named list results investigated Poisson model.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_glm_count.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize Poisson negative binomial regression — summarize_glm_count","text":"","code":"library(dplyr) anl <- tern_ex_adtte %>% filter(PARAMCD == \"TNE\") anl$AVAL_f <- as.factor(anl$AVAL) lyt <- basic_table() %>% split_cols_by(\"ARM\", ref_group = \"B: Placebo\") %>% add_colcounts() %>% analyze_vars( \"AVAL_f\", var_labels = \"Number of exacerbations per patient\", .stats = c(\"count_fraction\"), .formats = c(\"count_fraction\" = \"xx (xx.xx%)\"), .labels = c(\"Number of exacerbations per patient\") ) %>% summarize_glm_count( vars = \"AVAL\", variables = list(arm = \"ARM\", offset = \"lgTMATRSK\", covariates = NULL), conf_level = 0.95, distribution = \"poisson\", rate_mean_method = \"emmeans\", var_labels = \"Adjusted (P) exacerbation rate (per year)\", table_names = \"adjP\", .stats = c(\"rate\"), .labels = c(rate = \"Rate\") ) %>% summarize_glm_count( vars = \"AVAL\", variables = list(arm = \"ARM\", offset = \"lgTMATRSK\", covariates = c(\"REGION1\")), conf_level = 0.95, distribution = \"quasipoisson\", rate_mean_method = \"ppmeans\", var_labels = \"Adjusted (QP) exacerbation rate (per year)\", table_names = \"adjQP\", .stats = c(\"rate\", \"rate_ci\", \"rate_ratio\", \"rate_ratio_ci\", \"pval\"), .labels = c( rate = \"Rate\", rate_ci = \"Rate CI\", rate_ratio = \"Rate Ratio\", rate_ratio_ci = \"Rate Ratio CI\", pval = \"p value\" ) ) build_table(lyt = lyt, df = anl) #> A: Drug X B: Placebo C: Combination #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————————————————————————— #> Number of exacerbations per patient #> 0 3 (4.35%) 8 (10.96%) 6 (10.34%) #> 1 11 (15.94%) 9 (12.33%) 6 (10.34%) #> 2 18 (26.09%) 15 (20.55%) 9 (15.52%) #> 3 14 (20.29%) 11 (15.07%) 15 (25.86%) #> 4 10 (14.49%) 9 (12.33%) 9 (15.52%) #> 5 7 (10.14%) 9 (12.33%) 8 (13.79%) #> 6 4 (5.80%) 4 (5.48%) 4 (6.90%) #> 7 2 (2.90%) 8 (10.96%) 0 (0.00%) #> 10 0 (0.00%) 0 (0.00%) 1 (1.72%) #> Adjusted (P) exacerbation rate (per year) #> Rate 8.2061 9.1554 7.8551 #> Adjusted (QP) exacerbation rate (per year) #> Rate 3.1214 3.4860 2.6152 #> Rate CI (1.7307, 5.6294) (1.9833, 6.1272) (1.3661, 5.0065) #> Rate Ratio 0.8954 0.7502 #> Rate Ratio CI (0.3975, 2.0170) (0.3067, 1.8348) #> p value 0.7897 0.5288"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_logistic.html","id":null,"dir":"Reference","previous_headings":"","what":"Multivariate logistic regression table — summarize_logistic","title":"Multivariate logistic regression table — summarize_logistic","text":"Layout-creating function summarizes logistic variable regression binary outcome categorical/continuous covariates model statement. covariate category (categorical) specified values (continuous), present degrees freedom, regression parameter estimate standard error (SE) relative reference group category. Report odds ratios covariate category specified values corresponding Wald confidence intervals default allow user specify confidence levels. Report p-value Wald chi-square test null hypothesis covariate effect response model containing specified covariates. Allow option include one two-way interaction present similar output interaction degree freedom.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_logistic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multivariate logistic regression table — summarize_logistic","text":"","code":"summarize_logistic( lyt, conf_level, drop_and_remove_str = \"\", .indent_mods = NULL )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_logistic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multivariate logistic regression table — summarize_logistic","text":"lyt (PreDataTableLayouts) layout analyses added . conf_level (proportion) confidence level interval. drop_and_remove_str (string) string dropped removed. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_logistic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multivariate logistic regression table — summarize_logistic","text":"layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add logistic regression variable summary table layout.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_logistic.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Multivariate logistic regression table — summarize_logistic","text":"formula, variable names need standard data.frame column names without special characters.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_logistic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multivariate logistic regression table — summarize_logistic","text":"","code":"library(dplyr) library(broom) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred df <- tidy(mod1, conf_level = 0.99) df2 <- tidy(mod2, conf_level = 0.99) # flagging empty strings with \"_\" df <- df_explicit_na(df, na_level = \"_\") df2 <- df_explicit_na(df2, na_level = \"_\") result1 <- basic_table() %>% summarize_logistic( conf_level = 0.95, drop_and_remove_str = \"_\" ) %>% build_table(df = df) result1 #> Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Planned Arm Code 2 0.3004 #> Reference ARM A, n = 64 #> ARM B, n = 68 1 -1.775 1.144 0.17 (<0.01, 3.23) 0.1209 #> ARM C, n = 52 1 17.192 3626.588 >999.99 (0.00, >999.99) 0.9962 #> Age #> Age 1 0.170 0.095 1.19 (0.93, 1.51) 0.0746 #> Race 2 0.7967 #> Reference ASIAN, n = 110 #> BLACK OR AFRICAN AMERICAN, n = 40 1 17.923 4001.705 >999.99 (0.00, >999.99) 0.9964 #> WHITE, n = 34 1 -0.656 0.974 0.52 (0.04, 6.37) 0.5002 result2 <- basic_table() %>% summarize_logistic( conf_level = 0.95, drop_and_remove_str = \"_\" ) %>% build_table(df = df2) result2 #> Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value #> ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Race 2 0.9361 #> Reference ASIAN, n = 110 #> BLACK OR AFRICAN AMERICAN, n = 40 1 18.150 3944.701 >999.99 (0.00, >999.99) 0.9963 #> WHITE, n = 34 1 -0.373 1.026 0.69 (0.05, 9.68) 0.7164 #> Planned Arm Code 2 0.2539 #> Reference ARM A, n = 64 #> ARM B, n = 68 1 -11.527 6.962 0.0978 #> Age #> 35 0.48 (0.01, 15.48) #> ARM C, n = 52 1 16.333 20278.387 0.9994 #> Age #> 35 >999.99 (0.00, >999.99) #> Age #> Age 1 -0.039 0.151 0.7981 #> Planned Arm Code #> ARM A 0.96 (0.65, 1.42) #> ARM B 1.31 (0.92, 1.86) #> ARM C 0.99 (0.00, >999.99) #> Interaction of Planned Arm Code * Age 2 0.3276 #> Reference ARM A, n = 64 #> ARM B, n = 68 1 0.308 0.206 0.1352 #> ARM C, n = 52 1 0.029 548.592 1.0000"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":null,"dir":"Reference","previous_headings":"","what":"Count number of patients — summarize_num_patients","title":"Count number of patients — summarize_num_patients","text":"analyze function analyze_num_patients() creates layout element count total numbers unique non-unique patients. primary analysis variable vars used uniquely identify patients. count_by variable can used identify non-unique patients number patients unique combination values vars count_by returned instead nonunique statistic. required variable can used specify variable required non-missing record included counts. summarize function summarize_num_patients() performs function analyze_num_patients() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count number of patients — summarize_num_patients","text":"","code":"analyze_num_patients( lyt, vars, required = NULL, count_by = NULL, unique_count_suffix = TRUE, na_str = default_na_str(), nested = TRUE, .stats = NULL, .formats = NULL, .labels = c(unique = \"Number of patients with at least one event\", nonunique = \"Number of events\"), show_labels = c(\"default\", \"visible\", \"hidden\"), .indent_mods = 0L, riskdiff = FALSE, ... ) summarize_num_patients( lyt, var, required = NULL, count_by = NULL, unique_count_suffix = TRUE, na_str = default_na_str(), .stats = NULL, .formats = NULL, .labels = c(unique = \"Number of patients with at least one event\", nonunique = \"Number of events\"), .indent_mods = 0L, riskdiff = FALSE, ... ) s_num_patients( x, labelstr, .N_col, count_by = NULL, unique_count_suffix = TRUE ) s_num_patients_content( df, labelstr = \"\", .N_col, .var, required = NULL, count_by = NULL, unique_count_suffix = TRUE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count number of patients — summarize_num_patients","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . required (character NULL) name variable required non-missing. count_by (character NULL) name variable combined vars counting nonunique records. unique_count_suffix (flag) whether \"(n)\" suffix added unique_count labels. Defaults TRUE. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. .stats (character) statistics select table. Options : 'unique', 'nonunique', 'unique_count' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. riskdiff (flag) whether risk difference column present. set TRUE, add_riskdiff() must used split_fun prior column split table layout, specifying columns compared. See stat_propdiff_ci() details risk difference calculation. ... additional arguments lower level functions. x (character factor) vector patient IDs. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. df (data.frame) data set containing analysis variables. .var, var (string) single variable name passed rtables requested statistics function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count number of patients — summarize_num_patients","text":"analyze_num_patients() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_num_patients_content() table layout. summarize_num_patients() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_num_patients_content() table layout. s_num_patients() returns named list 3 statistics: unique: Vector counts percentages. nonunique: Vector counts. unique_count: Counts. s_num_patients_content() returns values s_num_patients().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Count number of patients — summarize_num_patients","text":"general, functions starts analyze* expected work like rtables::analyze(), functions starts summarize* based upon rtables::summarize_row_groups(). latter provides value dividing split row column space, , bound fundamental splits, repeated design every page pagination involved.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count number of patients — summarize_num_patients","text":"analyze_num_patients(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). summarize_num_patients(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::summarize_row_groups(). s_num_patients(): Statistics function counts number unique patients, corresponding percentage taken respect total number patients, number non-unique patients. s_num_patients_content(): Statistics function counts number unique patients column (variable), corresponding percentage taken respect total number patients, number non-unique patients column.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count number of patients — summarize_num_patients","text":"opposed summarize_num_patients(), function repeat produced rows.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_num_patients.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count number of patients — summarize_num_patients","text":"","code":"df <- data.frame( USUBJID = as.character(c(1, 2, 1, 4, NA, 6, 6, 8, 9)), ARM = c(\"A\", \"A\", \"A\", \"A\", \"A\", \"B\", \"B\", \"B\", \"B\"), AGE = c(10, 15, 10, 17, 8, 11, 11, 19, 17), SEX = c(\"M\", \"M\", \"M\", \"F\", \"F\", \"F\", \"M\", \"F\", \"M\") ) # analyze_num_patients tbl <- basic_table() %>% split_cols_by(\"ARM\") %>% add_colcounts() %>% analyze_num_patients(\"USUBJID\", .stats = c(\"unique\")) %>% build_table(df) tbl #> A B #> (N=5) (N=4) #> —————————————————————————————————————————————————————————————————— #> Number of patients with at least one event 3 (60.0%) 3 (75.0%) # summarize_num_patients tbl <- basic_table() %>% split_cols_by(\"ARM\") %>% split_rows_by(\"SEX\") %>% summarize_num_patients(\"USUBJID\", .stats = \"unique_count\") %>% build_table(df) tbl #> A B #> ————————————— #> M (n) 2 2 #> F (n) 1 2 # Use the statistics function to count number of unique and nonunique patients. s_num_patients(x = as.character(c(1, 1, 1, 2, 4, NA)), labelstr = \"\", .N_col = 6L) #> $unique #> [1] 3.0 0.5 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 5 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #> s_num_patients( x = as.character(c(1, 1, 1, 2, 4, NA)), labelstr = \"\", .N_col = 6L, count_by = c(1, 1, 2, 1, 1, 1) ) #> $unique #> [1] 3.0 0.5 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 4 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #> # Count number of unique and non-unique patients. df <- data.frame( USUBJID = as.character(c(1, 2, 1, 4, NA)), EVENT = as.character(c(10, 15, 10, 17, 8)) ) s_num_patients_content(df, .N_col = 5, .var = \"USUBJID\") #> $unique #> [1] 3.0 0.6 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 4 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #> df_by_event <- data.frame( USUBJID = as.character(c(1, 2, 1, 4, NA)), EVENT = c(10, 15, 10, 17, 8) ) s_num_patients_content(df_by_event, .N_col = 5, .var = \"USUBJID\", count_by = \"EVENT\") #> $unique #> [1] 3.0 0.6 #> attr(,\"label\") #> [1] \"\" #> #> $nonunique #> [1] 3 #> attr(,\"label\") #> [1] \"\" #> #> $unique_count #> [1] 3 #> attr(,\"label\") #> [1] \"(n)\" #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"analyze function analyze_patients_exposure_in_cols() creates layout element count total numbers patients sum analysis value (.e. exposure) across patients columns. primary analysis variable ex_var exposure variable used calculate sum_exposure statistic. id variable used uniquely identify patients data unique patients counted n_patients statistic, var variable used create row split needed. percentage returned part n_patients statistic proportion records correspond unique patient. summarize function summarize_patients_exposure_in_cols() performs function analyze_patients_exposure_in_cols() except creates content rows, data rows, summarize current table row/column context operates level latest row split root table row splits occurred. column split yet performed table, col_split must set TRUE first call analyze_patients_exposure_in_cols() summarize_patients_exposure_in_cols().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"","code":"analyze_patients_exposure_in_cols( lyt, var = NULL, ex_var = \"AVAL\", id = \"USUBJID\", add_total_level = FALSE, custom_label = NULL, col_split = TRUE, na_str = default_na_str(), .stats = c(\"n_patients\", \"sum_exposure\"), .labels = c(n_patients = \"Patients\", sum_exposure = \"Person time\"), .indent_mods = 0L, ... ) summarize_patients_exposure_in_cols( lyt, var, ex_var = \"AVAL\", id = \"USUBJID\", add_total_level = FALSE, custom_label = NULL, col_split = TRUE, na_str = default_na_str(), ..., .stats = c(\"n_patients\", \"sum_exposure\"), .labels = c(n_patients = \"Patients\", sum_exposure = \"Person time\"), .indent_mods = NULL ) s_count_patients_sum_exposure( df, ex_var = \"AVAL\", id = \"USUBJID\", labelstr = \"\", .stats = c(\"n_patients\", \"sum_exposure\"), .N_col, custom_label = NULL ) a_count_patients_sum_exposure( df, var = NULL, ex_var = \"AVAL\", id = \"USUBJID\", add_total_level = FALSE, custom_label = NULL, labelstr = \"\", .N_col, .stats, .formats = list(n_patients = \"xx (xx.x%)\", sum_exposure = \"xx\") )"},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"lyt (PreDataTableLayouts) layout analyses added . var (string) single variable name passed rtables requested statistics function. ex_var (string) name variable df containing exposure values. id (string) subject variable name. add_total_level (flag) adds \"total\" level others includes levels constitute split. custom label can set level via custom_label argument. custom_label (string NULL) provided labelstr empty, used label. col_split (flag) whether columns split. Set FALSE required column split done already earlier layout pipe. na_str (string) string used replace NA empty values output. .stats (character) statistics select table. Options : 'n_patients', 'sum_exposure' .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. ... additional arguments lower level functions. df (data.frame) data set containing analysis variables. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .N_col (integer(1)) column-wise N (column count) full column analyzed typically passed rtables. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"analyze_patients_exposure_in_cols() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted data rows, statistics s_count_patients_sum_exposure() arranged columns, table layout. summarize_patients_exposure_in_cols() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted content rows, statistics s_count_patients_sum_exposure() arranged columns, table layout. s_count_patients_sum_exposure() returns named list statistics: n_patients: Number unique patients df. sum_exposure: Sum ex_var across patients df. a_count_patients_sum_exposure() returns formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"analyze_patients_exposure_in_cols(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::split_cols_by_multivar() rtables::analyze_colvars(). summarize_patients_exposure_in_cols(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::split_cols_by_multivar() rtables::summarize_row_groups(). s_count_patients_sum_exposure(): Statistics function counts numbers patients sum exposure across patients. a_count_patients_sum_exposure(): Analysis function used afun rtables::analyze_colvars() within analyze_patients_exposure_in_cols() cfun rtables::summarize_row_groups() within summarize_patients_exposure_in_cols().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"opposed summarize_patients_exposure_in_cols() generates content rows, analyze_patients_exposure_in_cols() generates data rows repeated multiple pages pagination used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/summarize_patients_exposure_in_cols.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count number of patients and sum exposure across all patients in columns — summarize_patients_exposure_in_cols","text":"","code":"set.seed(1) df <- data.frame( USUBJID = c(paste(\"id\", seq(1, 12), sep = \"\")), ARMCD = c(rep(\"ARM A\", 6), rep(\"ARM B\", 6)), SEX = c(rep(\"Female\", 6), rep(\"Male\", 6)), AVAL = as.numeric(sample(seq(1, 20), 12)), stringsAsFactors = TRUE ) adsl <- data.frame( USUBJID = c(paste(\"id\", seq(1, 12), sep = \"\")), ARMCD = c(rep(\"ARM A\", 2), rep(\"ARM B\", 2)), SEX = c(rep(\"Female\", 2), rep(\"Male\", 2)), stringsAsFactors = TRUE ) lyt <- basic_table() %>% split_cols_by(\"ARMCD\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>% summarize_patients_exposure_in_cols(var = \"AVAL\", col_split = TRUE) %>% analyze_patients_exposure_in_cols(var = \"SEX\", col_split = FALSE) result <- build_table(lyt, df = df, alt_counts_df = adsl) result #> ARM A ARM B Total #> Patients Person time Patients Person time Patients Person time #> ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total patients numbers/person time 6 (100.0%) 46 6 (100.0%) 68 12 (100.0%) 114 #> Female 6 (100.0%) 46 0 (0.0%) 0 6 (50.0%) 46 #> Male 0 (0.0%) 0 6 (100.0%) 68 6 (50.0%) 68 lyt2 <- basic_table() %>% split_cols_by(\"ARMCD\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>% summarize_patients_exposure_in_cols( var = \"AVAL\", col_split = TRUE, .stats = \"n_patients\", custom_label = \"some custom label\" ) %>% analyze_patients_exposure_in_cols(var = \"SEX\", col_split = FALSE, ex_var = \"AVAL\") result2 <- build_table(lyt2, df = df, alt_counts_df = adsl) result2 #> ARM A ARM B Total #> Patients Patients Patients #> ————————————————————————————————————————————————————————— #> some custom label 6 (100.0%) 6 (100.0%) 12 (100.0%) #> Female 6 (100.0%) 0 (0.0%) 6 (50.0%) #> Male 0 (0.0%) 6 (100.0%) 6 (50.0%) lyt3 <- basic_table() %>% analyze_patients_exposure_in_cols(var = \"SEX\", col_split = TRUE, ex_var = \"AVAL\") result3 <- build_table(lyt3, df = df, alt_counts_df = adsl) result3 #> Patients Person time #> ———————————————————————————————— #> Female 6 (50.0%) 46 #> Male 6 (50.0%) 68 # Adding total levels and custom label lyt4 <- basic_table( show_colcounts = TRUE ) %>% analyze_patients_exposure_in_cols( var = \"ARMCD\", col_split = TRUE, add_total_level = TRUE, custom_label = \"TOTAL\" ) %>% append_topleft(c(\"\", \"Sex\")) result4 <- build_table(lyt4, df = df, alt_counts_df = adsl) result4 #> Patients Person time #> Sex (N=12) (N=12) #> ————————————————————————————————— #> ARM A 6 (50.0%) 46 #> ARM B 6 (50.0%) 68 #> TOTAL 12 (100.0%) 114 lyt5 <- basic_table() %>% summarize_patients_exposure_in_cols(var = \"AVAL\", col_split = TRUE) result5 <- build_table(lyt5, df = df, alt_counts_df = adsl) result5 #> Patients Person time #> —————————————————————————————————————————————————————————————— #> Total patients numbers/person time 12 (100.0%) 114 lyt6 <- basic_table() %>% summarize_patients_exposure_in_cols(var = \"AVAL\", col_split = TRUE, .stats = \"sum_exposure\") result6 <- build_table(lyt6, df = df, alt_counts_df = adsl) result6 #> Person time #> ———————————————————————————————————————————————— #> Total patients numbers/person time 114 a_count_patients_sum_exposure( df = df, var = \"SEX\", .N_col = nrow(df), .stats = \"n_patients\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Female 6 (50.0%) 0 Female #> 2 Male 6 (50.0%) 0 Male"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"tabulate_survival_biomarkers() function creates layout element tabulate estimated effects multiple continuous biomarker variables survival across subgroups, returning statistics including median survival time hazard ratio population subgroup. table created df, list data frames returned extract_survival_biomarkers(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"","code":"tabulate_survival_biomarkers( df, vars = c(\"n_tot\", \"n_tot_events\", \"median\", \"hr\", \"ci\", \"pval\"), groups_lists = list(), control = control_coxreg(), label_all = lifecycle::deprecated(), time_unit = NULL, na_str = default_na_str(), .indent_mods = 0L )"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"df (data.frame) containing analysis variables, returned extract_survival_biomarkers(). vars (character) names statistics reported among: n_tot_events: Total number events per group. n_tot: Total number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. control (list) list parameters returned helper function control_coxreg(). label_all please assign label_all parameter within extract_survival_biomarkers() function creating df. time_unit (string) label unit median survival time. Default NULL skips displaying unit. na_str (string) string used replace NA empty values output. .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"rtables table summarizing biomarker effects survival subgroup.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"functions create layout starting data frame contains required statistics. tables typically used input forest plots.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"tabulate_survival_biomarkers(): Table-creating function creates table summarizing biomarker effects survival subgroup.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"contrast tabulate_survival_subgroups() tabulation function start input layout lyt. internally table created combining multiple subtables.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_biomarkers_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate biomarker effects on survival by subgroup — survival_biomarkers_subgroups","text":"","code":"library(dplyr) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) adtte_f <- adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- c(\"AVALU\" = adtte_labels[[\"AVALU\"]], \"is_event\" = \"Event Flag\") formatters::var_labels(adtte_f)[names(labels)] <- labels # Typical analysis of two continuous biomarkers `BMRKR1` and `AGE`, # in multiple regression models containing one covariate `RACE`, # as well as one stratification variable `STRATA1`. The subgroups # are defined by the levels of `BMRKR2`. df <- extract_survival_biomarkers( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), strata = \"STRATA1\", covariates = \"SEX\", subgroups = \"BMRKR2\" ), label_all = \"Total Patients\", data = adtte_f ) df #> biomarker biomarker_label n_tot n_tot_events median hr #> 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.0010939 #> 2 AGE Age 200 141 753.5176 1.0106406 #> 3 BMRKR1 Continuous Level Biomarker 1 70 52 735.4722 0.9905065 #> 4 AGE Age 70 52 735.4722 1.0106279 #> 5 BMRKR1 Continuous Level Biomarker 1 68 42 858.9952 0.9623210 #> 6 AGE Age 68 42 858.9952 1.0360765 #> 7 BMRKR1 Continuous Level Biomarker 1 62 47 727.8043 1.0770946 #> 8 AGE Age 62 47 727.8043 1.0009890 #> lcl ucl conf_level pval pval_label subgroup var #> 1 0.9538978 1.050625 0.95 0.9646086 p-value (Wald) Total Patients ALL #> 2 0.9871004 1.034742 0.95 0.3787395 p-value (Wald) Total Patients ALL #> 3 0.9142220 1.073156 0.95 0.8155443 p-value (Wald) LOW BMRKR2 #> 4 0.9621192 1.061582 0.95 0.6735773 p-value (Wald) LOW BMRKR2 #> 5 0.8708694 1.063376 0.95 0.4509368 p-value (Wald) MEDIUM BMRKR2 #> 6 0.9727439 1.103532 0.95 0.2707796 p-value (Wald) MEDIUM BMRKR2 #> 7 0.9756250 1.189118 0.95 0.1412524 p-value (Wald) HIGH BMRKR2 #> 8 0.9678535 1.035259 0.95 0.9541048 p-value (Wald) HIGH BMRKR2 #> var_label row_type #> 1 Total Patients content #> 2 Total Patients content #> 3 Continuous Level Biomarker 2 analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis # Here we group the levels of `BMRKR2` manually. df_grouped <- extract_survival_biomarkers( variables = list( tte = \"AVAL\", is_event = \"is_event\", biomarkers = c(\"BMRKR1\", \"AGE\"), strata = \"STRATA1\", covariates = \"SEX\", subgroups = \"BMRKR2\" ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) df_grouped #> biomarker biomarker_label n_tot n_tot_events median hr #> 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.0010939 #> 2 AGE Age 200 141 753.5176 1.0106406 #> 3 BMRKR1 Continuous Level Biomarker 1 70 52 735.4722 0.9905065 #> 4 AGE Age 70 52 735.4722 1.0106279 #> 5 BMRKR1 Continuous Level Biomarker 1 138 94 777.8929 0.9801709 #> 6 AGE Age 138 94 777.8929 1.0236283 #> 7 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.0010939 #> 8 AGE Age 200 141 753.5176 1.0106406 #> lcl ucl conf_level pval pval_label subgroup var #> 1 0.9538978 1.050625 0.95 0.9646086 p-value (Wald) All Patients ALL #> 2 0.9871004 1.034742 0.95 0.3787395 p-value (Wald) All Patients ALL #> 3 0.9142220 1.073156 0.95 0.8155443 p-value (Wald) low BMRKR2 #> 4 0.9621192 1.061582 0.95 0.6735773 p-value (Wald) low BMRKR2 #> 5 0.9235465 1.040267 0.95 0.5094582 p-value (Wald) low/medium BMRKR2 #> 6 0.9859367 1.062761 0.95 0.2224475 p-value (Wald) low/medium BMRKR2 #> 7 0.9538978 1.050625 0.95 0.9646086 p-value (Wald) low/medium/high BMRKR2 #> 8 0.9871004 1.034742 0.95 0.3787395 p-value (Wald) low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Continuous Level Biomarker 2 analysis #> 4 Continuous Level Biomarker 2 analysis #> 5 Continuous Level Biomarker 2 analysis #> 6 Continuous Level Biomarker 2 analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis ## Table with default columns. tabulate_survival_biomarkers(df) #> Total n Total Events Median Hazard Ratio 95% Wald CI p-value (Wald) #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Age #> Total Patients 200 141 753.5 1.01 (0.99, 1.03) 0.3787 #> Continuous Level Biomarker 2 #> LOW 70 52 735.5 1.01 (0.96, 1.06) 0.6736 #> MEDIUM 68 42 859.0 1.04 (0.97, 1.10) 0.2708 #> HIGH 62 47 727.8 1.00 (0.97, 1.04) 0.9541 #> Continuous Level Biomarker 1 #> Total Patients 200 141 753.5 1.00 (0.95, 1.05) 0.9646 #> Continuous Level Biomarker 2 #> LOW 70 52 735.5 0.99 (0.91, 1.07) 0.8155 #> MEDIUM 68 42 859.0 0.96 (0.87, 1.06) 0.4509 #> HIGH 62 47 727.8 1.08 (0.98, 1.19) 0.1413 ## Table with a manually chosen set of columns: leave out \"pval\", reorder. tab <- tabulate_survival_biomarkers( df = df, vars = c(\"n_tot_events\", \"ci\", \"n_tot\", \"median\", \"hr\"), time_unit = as.character(adtte_f$AVALU[1]) ) ## Finally produce the forest plot. # \\donttest{ g_forest(tab, xlim = c(0.8, 1.2)) # }"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_coxph_pairwise.html","id":null,"dir":"Reference","previous_headings":"","what":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"analyze function coxph_pairwise() creates layout element analyze pairwise Cox-PH model. function can return statistics including p-value, hazard ratio (HR), HR confidence intervals stratified unstratified Cox-PH models. variable(s) analyzed specified via vars argument stratification factors via strata argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_coxph_pairwise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"","code":"coxph_pairwise( lyt, vars, strata = NULL, control = control_coxph(), na_str = default_na_str(), nested = TRUE, ..., var_labels = \"CoxPH\", show_labels = \"visible\", table_names = vars, .stats = c(\"pvalue\", \"hr\", \"hr_ci\"), .formats = NULL, .labels = NULL, .indent_mods = NULL ) s_coxph_pairwise( df, .ref_group, .in_ref_col, .var, is_event, strata = NULL, strat = lifecycle::deprecated(), control = control_coxph() ) a_coxph_pairwise( df, .ref_group, .in_ref_col, .var, is_event, strata = NULL, strat = lifecycle::deprecated(), control = control_coxph() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_coxph_pairwise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . strata (character NULL) variable names indicating stratification factors. control (list) parameters comparison details, specified using helper function control_coxph(). possible parameter options : pval_method (string) p-value method testing null hypothesis hazard ratio = 1. Default method \"log-rank\" comes survival::survdiff(), can also set \"wald\" \"likelihood\" (survival::coxph()). ties (string) specifying method tie handling. Default \"efron\", can also set \"breslow\" \"exact\". See survival::coxph(). conf_level (proportion) confidence level interval HR. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'pvalue', 'hr', 'hr_ci', 'n_tot', 'n_tot_events' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative. df (data.frame) data set containing analysis variables. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise. .var (string) single variable name passed rtables requested statistics function. is_event (flag)TRUE event, FALSE time event censored. strat Please use strata argument instead.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_coxph_pairwise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"coxph_pairwise() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_coxph_pairwise() table layout. s_coxph_pairwise() returns statistics: pvalue: p-value test null hypothesis hazard ratio = 1. hr: Hazard ratio. hr_ci: Confidence interval hazard ratio. n_tot: Total number observations. n_tot_events: Total number events. a_coxph_pairwise() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_coxph_pairwise.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"coxph_pairwise(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_coxph_pairwise(): Statistics function analyzes HR, CIs HR, p-value Cox-PH model. a_coxph_pairwise(): Formatted analysis function used afun coxph_pairwise().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_coxph_pairwise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Analyze a pairwise Cox-PH model — survival_coxph_pairwise","text":"","code":"library(dplyr) adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate(is_event = CNSR == 0) df <- adtte_f %>% filter(ARMCD == \"ARM A\") df_ref_group <- adtte_f %>% filter(ARMCD == \"ARM B\") basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% coxph_pairwise( vars = \"AVAL\", is_event = \"is_event\", var_labels = \"Unstratified Analysis\" ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ———————————————————————————————————————————————————————————— #> Unstratified Analysis #> p-value (log-rank) 0.0905 0.0086 #> Hazard Ratio 1.41 1.81 #> 95% CI (0.95, 2.09) (1.16, 2.84) basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% coxph_pairwise( vars = \"AVAL\", is_event = \"is_event\", var_labels = \"Stratified Analysis\", strata = \"SEX\", control = control_coxph(pval_method = \"wald\") ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————————————— #> Stratified Analysis #> p-value (wald) 0.0784 0.0066 #> Hazard Ratio 1.44 1.89 #> 95% CI (0.96, 2.15) (1.19, 2.98)"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate survival duration by subgroup — survival_duration_subgroups","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"tabulate_survival_subgroups() function creates layout element tabulate survival duration subgroup, returning statistics including median survival time hazard ratio population subgroup. table created df, list data frames returned extract_survival_subgroups(), statistics include specified via vars parameter. forest plot can created resulting table using g_forest() function.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"","code":"tabulate_survival_subgroups( lyt, df, vars = c(\"n_tot_events\", \"n_events\", \"median\", \"hr\", \"ci\"), groups_lists = list(), label_all = lifecycle::deprecated(), time_unit = NULL, riskdiff = NULL, na_str = default_na_str(), .formats = c(n = \"xx\", n_events = \"xx\", n_tot_events = \"xx\", median = \"xx.x\", n_tot = \"xx\", hr = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\") ) a_survival_subgroups( .formats = list(n = \"xx\", n_events = \"xx\", n_tot_events = \"xx\", median = \"xx.x\", n_tot = \"xx\", hr = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval = \"x.xxxx | (<0.0001)\"), na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"lyt (PreDataTableLayouts) layout analyses added . df (list) list data frames containing analysis variables. List created using extract_survival_subgroups(). vars (character) names statistics reported among: n_tot_events: Total number events per group. n_events: Number events per group. n_tot: Total number observations per group. n: Number observations per group. median: Median survival time. hr: Hazard ratio. ci: Confidence interval hazard ratio. pval: p-value effect. Note, one statistics n_tot n_tot_events, well hr ci required. groups_lists (named list list) optionally contains subgroups variable list, specifies new group levels via names levels belong character vectors elements list. label_all please assign label_all parameter within extract_survival_subgroups() function creating df. time_unit (string) label unit median survival time. Default NULL skips displaying unit. riskdiff (list) risk (proportion) difference column added, list settings apply within column. See control_riskdiff() details. NULL, risk difference column added. riskdiff$arm_x riskdiff$arm_y NULL, first level df$survtime$arm used arm_x second level arm_y. na_str (string) string used replace NA empty values output. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"rtables table summarizing survival subgroup. a_survival_subgroups() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"functions create layout starting data frame contains required statistics. Tables typically used part forest plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"tabulate_survival_subgroups(): Table-creating function creates table summarizing survival subgroup. function wrapper rtables::analyze_colvars() rtables::summarize_row_groups(). a_survival_subgroups(): Formatted analysis function used afun tabulate_survival_subgroups().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_duration_subgroups.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate survival duration by subgroup — survival_duration_subgroups","text":"","code":"library(dplyr) adtte <- tern_ex_adtte # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) adtte_f <- adtte %>% filter( PARAMCD == \"OS\", ARM %in% c(\"B: Placebo\", \"A: Drug X\"), SEX %in% c(\"M\", \"F\") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")), SEX = droplevels(SEX), AVALU = as.character(AVALU), is_event = CNSR == 0 ) labels <- c( \"ARM\" = adtte_labels[[\"ARM\"]], \"SEX\" = adtte_labels[[\"SEX\"]], \"AVALU\" = adtte_labels[[\"AVALU\"]], \"is_event\" = \"Event Flag\" ) formatters::var_labels(adtte_f)[names(labels)] <- labels df <- extract_survival_subgroups( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), label_all = \"Total Patients\", data = adtte_f ) df #> $survtime #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 Total Patients ALL #> 2 A: Drug X 69 44 974.6402 Total Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 LOW BMRKR2 #> 8 A: Drug X 26 15 974.6402 LOW BMRKR2 #> 9 B: Placebo 23 14 731.8352 MEDIUM BMRKR2 #> 10 A: Drug X 26 17 964.2197 MEDIUM BMRKR2 #> 11 B: Placebo 26 22 654.8245 HIGH BMRKR2 #> 12 A: Drug X 17 12 1016.2982 HIGH BMRKR2 #> var_label row_type #> 1 Total Patients content #> 2 Total Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $hr #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 49 31 0.7651261 0.3641277 1.6077269 0.95 0.47860004 #> 6 43 34 0.6662356 0.3257413 1.3626456 0.95 0.26285846 #> pval_label subgroup var var_label #> 1 p-value (log-rank) Total Patients ALL Total Patients #> 2 p-value (log-rank) F SEX Sex #> 3 p-value (log-rank) M SEX Sex #> 4 p-value (log-rank) LOW BMRKR2 Continuous Level Biomarker 2 #> 5 p-value (log-rank) MEDIUM BMRKR2 Continuous Level Biomarker 2 #> 6 p-value (log-rank) HIGH BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 analysis #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis #> df_grouped <- extract_survival_subgroups( variables = list( tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\") ), data = adtte_f, groups_lists = list( BMRKR2 = list( \"low\" = \"LOW\", \"low/medium\" = c(\"LOW\", \"MEDIUM\"), \"low/medium/high\" = c(\"LOW\", \"MEDIUM\", \"HIGH\") ) ) ) df_grouped #> $survtime #> arm n n_events median subgroup var #> 1 B: Placebo 73 57 727.8043 All Patients ALL #> 2 A: Drug X 69 44 974.6402 All Patients ALL #> 3 B: Placebo 40 31 599.1772 F SEX #> 4 A: Drug X 38 24 1016.2982 F SEX #> 5 B: Placebo 33 26 888.4916 M SEX #> 6 A: Drug X 31 20 974.6402 M SEX #> 7 B: Placebo 24 21 735.4722 low BMRKR2 #> 8 A: Drug X 26 15 974.6402 low BMRKR2 #> 9 B: Placebo 47 35 735.4722 low/medium BMRKR2 #> 10 A: Drug X 52 32 964.2197 low/medium BMRKR2 #> 11 B: Placebo 73 57 727.8043 low/medium/high BMRKR2 #> 12 A: Drug X 69 44 974.6402 low/medium/high BMRKR2 #> var_label row_type #> 1 All Patients content #> 2 All Patients content #> 3 Sex analysis #> 4 Sex analysis #> 5 Sex analysis #> 6 Sex analysis #> 7 Continuous Level Biomarker 2 analysis #> 8 Continuous Level Biomarker 2 analysis #> 9 Continuous Level Biomarker 2 analysis #> 10 Continuous Level Biomarker 2 analysis #> 11 Continuous Level Biomarker 2 analysis #> 12 Continuous Level Biomarker 2 analysis #> #> $hr #> arm n_tot n_tot_events hr lcl ucl conf_level pval #> 1 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> 2 78 55 0.5595391 0.3246658 0.9643271 0.95 0.03411759 #> 3 64 46 0.9102874 0.5032732 1.6464678 0.95 0.75582028 #> 4 50 36 0.7617717 0.3854349 1.5055617 0.95 0.43236030 #> 5 99 67 0.7472958 0.4600419 1.2139136 0.95 0.23764314 #> 6 142 101 0.7108557 0.4779138 1.0573368 0.95 0.09049511 #> pval_label subgroup var var_label #> 1 p-value (log-rank) All Patients ALL All Patients #> 2 p-value (log-rank) F SEX Sex #> 3 p-value (log-rank) M SEX Sex #> 4 p-value (log-rank) low BMRKR2 Continuous Level Biomarker 2 #> 5 p-value (log-rank) low/medium BMRKR2 Continuous Level Biomarker 2 #> 6 p-value (log-rank) low/medium/high BMRKR2 Continuous Level Biomarker 2 #> row_type #> 1 content #> 2 analysis #> 3 analysis #> 4 analysis #> 5 analysis #> 6 analysis #> ## Table with default columns. basic_table() %>% tabulate_survival_subgroups(df, time_unit = adtte_f$AVALU[1]) #> B: Placebo A: Drug X #> Baseline Risk Factors Total Events Events Median (DAYS) Events Median (DAYS) Hazard Ratio 95% Wald CI #> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total Patients 101 57 727.8 44 974.6 0.71 (0.48, 1.06) #> Sex #> F 55 31 599.2 24 1016.3 0.56 (0.32, 0.96) #> M 46 26 888.5 20 974.6 0.91 (0.50, 1.65) #> Continuous Level Biomarker 2 #> LOW 36 21 735.5 15 974.6 0.76 (0.39, 1.51) #> MEDIUM 31 14 731.8 17 964.2 0.77 (0.36, 1.61) #> HIGH 34 22 654.8 12 1016.3 0.67 (0.33, 1.36) ## Table with a manually chosen set of columns: adding \"pval\". basic_table() %>% tabulate_survival_subgroups( df = df, vars = c(\"n_tot_events\", \"n_events\", \"median\", \"hr\", \"ci\", \"pval\"), time_unit = adtte_f$AVALU[1] ) #> B: Placebo A: Drug X #> Baseline Risk Factors Total Events Events Median (DAYS) Events Median (DAYS) Hazard Ratio 95% Wald CI p-value (log-rank) #> ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— #> Total Patients 101 57 727.8 44 974.6 0.71 (0.48, 1.06) 0.0905 #> Sex #> F 55 31 599.2 24 1016.3 0.56 (0.32, 0.96) 0.0341 #> M 46 26 888.5 20 974.6 0.91 (0.50, 1.65) 0.7558 #> Continuous Level Biomarker 2 #> LOW 36 21 735.5 15 974.6 0.76 (0.39, 1.51) 0.4324 #> MEDIUM 31 14 731.8 17 964.2 0.77 (0.36, 1.61) 0.4786 #> HIGH 34 22 654.8 12 1016.3 0.67 (0.33, 1.36) 0.2629"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Survival time analysis — survival_time","title":"Survival time analysis — survival_time","text":"analyze function surv_time() creates layout element analyze survival time calculating survival time median, median confidence interval, quantiles, range (, censored, event patients). primary analysis variable vars time variable secondary analysis variable is_event indicates whether event occurred.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Survival time analysis — survival_time","text":"","code":"surv_time( lyt, vars, is_event, control = control_surv_time(), ref_fn_censor = TRUE, na_str = default_na_str(), nested = TRUE, ..., var_labels = \"Time to Event\", show_labels = \"visible\", table_names = vars, .stats = c(\"median\", \"median_ci\", \"quantiles\", \"range\"), .formats = NULL, .labels = NULL, .indent_mods = c(median_ci = 1L) ) s_surv_time(df, .var, is_event, control = control_surv_time()) a_surv_time( df, labelstr = \"\", .var = NULL, .df_row = NULL, is_event, control = control_surv_time(), ref_fn_censor = TRUE, .stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL, na_str = default_na_str() )"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Survival time analysis — survival_time","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . is_event (flag)TRUE event, FALSE time event censored. control (list) parameters comparison details, specified using helper function control_surv_time(). possible parameter options : conf_level (proportion) confidence level interval survival time. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" supported. quantiles (numeric) vector length two specify quantiles survival time. ref_fn_censor (flag) whether referential footnotes indicating censored observations printed range statistic included. na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". table_names (character) can customized case vars analyzed multiple times, avoid warnings rtables. .stats (character) statistics select table. Options : 'median', 'median_ci', 'median_ci_3d', 'quantiles', 'quantiles_lower', 'quantiles_upper', 'range_censor', 'range_event', 'range' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. labelstr (string) label level parent split currently summarized (must present second argument Content Row Functions). See rtables::summarize_row_groups() information. .df_row (data.frame) data frame across columns given row split.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Survival time analysis — survival_time","text":"surv_time() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_surv_time() table layout. s_surv_time() returns statistics: median: Median survival time. median_ci: Confidence interval median time. median_ci_3d: Median confidence interval median time. quantiles: Survival time two specified quantiles. quantiles_lower: quantile confidence interval first specified quantile. quantiles_upper: quantile confidence interval second specified quantile. range_censor: Survival time range censored observations. range_event: Survival time range observations events. range: Survival time range observations. a_surv_time() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_time.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Survival time analysis — survival_time","text":"surv_time(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_surv_time(): Statistics function analyzes survival times. a_surv_time(): Formatted analysis function used afun surv_time().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Survival time analysis — survival_time","text":"","code":"library(dplyr) adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) df <- adtte_f %>% filter(ARMCD == \"ARM A\") basic_table() %>% split_cols_by(var = \"ARMCD\") %>% add_colcounts() %>% surv_time( vars = \"AVAL\", var_labels = \"Survival Time (Months)\", is_event = \"is_event\", control = control_surv_time(conf_level = 0.9, conf_type = \"log-log\") ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————— #> Survival Time (Months) #> Median 32.0 23.9 20.8 #> 90% CI (22.6, 46.5) (18.3, 29.2) (12.9, 25.9) #> 25% and 75%-ile 17.4, 65.3 9.8, 42.0 7.3, 37.1 #> Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 a_surv_time( df, .df_row = df, .var = \"AVAL\", is_event = \"is_event\" ) #> RowsVerticalSection (in_rows) object print method: #> ---------------------------- #> row_name formatted_cell indent_mod row_label #> 1 Median 32.0 0 Median #> 2 95% CI (22.5, 49.3) 0 95% CI #> 3 Median (95% CI) 32.0 (22.5 - 49.3) 0 Median (95% CI) #> 4 25% and 75%-ile 17.4, 65.3 0 25% and 75%-ile #> 5 25%-ile (95% CI) 17.4 (10.1 - 22.5) 0 25%-ile (95% CI) #> 6 75%-ile (95% CI) 65.3 (49.3 - 87.2) 0 75%-ile (95% CI) #> 7 Range (censored) 0.8 to 63.5 0 Range (censored) #> 8 Range (event) 0.3 to 155.5 0 Range (event) #> 9 Range 0.3 to 155.5 0 Range"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_timepoint.html","id":null,"dir":"Reference","previous_headings":"","what":"Survival time point analysis — survival_timepoint","title":"Survival time point analysis — survival_timepoint","text":"analyze function surv_timepoint() creates layout element analyze patient survival rates difference survival rates groups given time point. primary analysis variable vars time variable. required inputs time_point, numeric time point interest, is_event, variable indicates whether event occurred. method argument used specify whether want analyze survival estimations (\"surv\"), difference survival control (\"surv_diff\"), (\"\").","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_timepoint.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Survival time point analysis — survival_timepoint","text":"","code":"surv_timepoint( lyt, vars, time_point, is_event, control = control_surv_timepoint(), method = c(\"surv\", \"surv_diff\", \"both\"), na_str = default_na_str(), nested = TRUE, ..., table_names_suffix = \"\", var_labels = \"Time\", show_labels = \"visible\", .stats = c(\"pt_at_risk\", \"event_free_rate\", \"rate_ci\", \"rate_diff\", \"rate_diff_ci\", \"ztest_pval\"), .formats = NULL, .labels = NULL, .indent_mods = if (method == \"both\") { c(rate_diff = 1L, rate_diff_ci = 2L, ztest_pval = 2L) } else { c(rate_diff_ci = 1L, ztest_pval = 1L) } ) s_surv_timepoint( df, .var, time_point, is_event, control = control_surv_timepoint() ) a_surv_timepoint( df, .var, time_point, is_event, control = control_surv_timepoint() ) s_surv_timepoint_diff( df, .var, .ref_group, .in_ref_col, time_point, control = control_surv_timepoint(), ... ) a_surv_timepoint_diff( df, .var, .ref_group, .in_ref_col, time_point, control = control_surv_timepoint(), ... )"},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_timepoint.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Survival time point analysis — survival_timepoint","text":"lyt (PreDataTableLayouts) layout analyses added . vars (character) variable names primary analysis variable iterated . time_point (numeric(1)) survival time point interest. is_event (flag)TRUE event, FALSE time event censored. control (list) parameters comparison details, specified using helper function control_surv_timepoint(). possible parameter options : conf_level (proportion) confidence level interval survival rate. conf_type (string) confidence interval type. Options \"plain\" (default), \"log\", \"log-log\", see survival::survfit(). Note option \"none\" longer supported. method (string)\"surv\" (survival estimations), \"surv_diff\" (difference survival control), \"\". na_str (string) string used replace NA empty values output. nested (flag) whether layout instruction applied within existing layout structure _if possible (TRUE, default) new top-level element (FALSE). Ignored nest split. underneath analyses, allowed. ... additional arguments lower level functions. table_names_suffix (string) optional suffix table_names used rtables avoid warnings duplicate table names. var_labels (character) variable labels. show_labels (string) label visibility: one \"default\", \"visible\" \"hidden\". .stats (character) statistics select table. Options : 'pt_at_risk', 'event_free_rate', 'rate_se', 'rate_ci', 'rate_diff', 'rate_diff_ci', 'ztest_pval', 'event_free_rate_3d' .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. element vector name-value pair name corresponding statistic specified .stats value indentation statistic's row label. df (data.frame) data set containing analysis variables. .var (string) single variable name passed rtables requested statistics function. .ref_group (data.frame vector) data corresponding reference group. .in_ref_col (flag)TRUE working reference level, FALSE otherwise.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_timepoint.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Survival time point analysis — survival_timepoint","text":"surv_timepoint() returns layout object suitable passing layouting functions, rtables::build_table(). Adding function rtable layout add formatted rows containing statistics s_surv_timepoint() /s_surv_timepoint_diff() table layout depending value method. s_surv_timepoint() returns statistics: pt_at_risk: Patients remaining risk. event_free_rate: Event-free rate (%). rate_se: Standard error event free rate. rate_ci: Confidence interval event free rate. event_free_rate_3d: Event-free rate (%) Confidence interval. a_surv_timepoint() returns corresponding list formatted rtables::CellValue(). s_surv_timepoint_diff() returns statistics: rate_diff: Event-free rate difference two groups. rate_diff_ci: Confidence interval difference. rate_diff_ci_3d: Event-free rate difference confidence interval two groups. ztest_pval: p-value test difference 0. a_surv_timepoint_diff() returns corresponding list formatted rtables::CellValue().","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_timepoint.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Survival time point analysis — survival_timepoint","text":"surv_timepoint(): Layout-creating function can take statistics function arguments additional format arguments. function wrapper rtables::analyze(). s_surv_timepoint(): Statistics function analyzes survival rate. a_surv_timepoint(): Formatted analysis function used afun surv_timepoint() method = \"surv\". s_surv_timepoint_diff(): Statistics function analyzes difference two survival rates. a_surv_timepoint_diff(): Formatted analysis function used afun surv_timepoint() method = \"surv_diff\".","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/survival_timepoint.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Survival time point analysis — survival_timepoint","text":"","code":"library(dplyr) adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) # Survival at given time points. basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% surv_timepoint( vars = \"AVAL\", var_labels = \"Months\", is_event = \"is_event\", time_point = 7 ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————————————————— #> 7 Months #> Patients remaining at risk 54 57 42 #> Event Free Rate (%) 84.89 79.43 75.50 #> 95% CI (76.24, 93.53) (70.15, 88.71) (64.33, 86.67) # Difference in survival at given time points. basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% surv_timepoint( vars = \"AVAL\", var_labels = \"Months\", is_event = \"is_event\", time_point = 9, method = \"surv_diff\", .indent_mods = c(\"rate_diff\" = 0L, \"rate_diff_ci\" = 2L, \"ztest_pval\" = 2L) ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————————————————————————————— #> 9 Months #> Difference in Event Free Rate -9.64 -13.03 #> 95% CI (-22.80, 3.52) (-27.59, 1.53) #> p-value (Z-test) 0.1511 0.0794 # Survival and difference in survival at given time points. basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>% add_colcounts() %>% surv_timepoint( vars = \"AVAL\", var_labels = \"Months\", is_event = \"is_event\", time_point = 9, method = \"both\" ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> —————————————————————————————————————————————————————————————————————————————————— #> 9 Months #> Patients remaining at risk 53 53 39 #> Event Free Rate (%) 84.89 75.25 71.86 #> 95% CI (76.24, 93.53) (65.32, 85.17) (60.14, 83.57) #> Difference in Event Free Rate -9.64 -13.03 #> 95% CI (-22.80, 3.52) (-27.59, 1.53) #> p-value (Z-test) 0.1511 0.0794"},{"path":"https://insightsengineering.github.io/tern/main/reference/tern-package.html","id":null,"dir":"Reference","previous_headings":"","what":"tern Package — tern-package","title":"tern Package — tern-package","text":"Package create tables, listings graphs analyze clinical trials data.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/tern-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"tern Package — tern-package","text":"Maintainer: Joe Zhu joe.zhu@roche.com Authors: Daniel Sabanés Bové daniel.sabanes_bove@roche.com Jana Stoilova jana.stoilova@roche.com Davide Garolini davide.garolini@roche.com Emily de la Rua emily.de_la_rua@contractors.roche.com Abinaya Yogasekaram abinaya.yogasekaram@contractors.roche.com Heng Wang wang.heng@gene.com Francois Collin Adrian Waddell adrian.waddell@gene.com Pawel Rucki pawel.rucki@roche.com Chendi Liao chendi.liao@roche.com Jennifer Li li.jing@gene.com contributors: F. Hoffmann-La Roche AG [copyright holder, funder]","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.glm.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom tidy method for binomial GLM results — tidy.glm","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"Helper method (broom::tidy()) prepare data frame glm object binomial family.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.glm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"","code":"# S3 method for class 'glm' tidy(x, conf_level = 0.95, at = NULL, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.glm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"x (glm) logistic regression model fitted stats::glm() \"binomial\" family. conf_level (proportion) confidence level interval. (numeric NULL) optional values interaction variable. Otherwise median used. ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.glm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"data.frame containing tidied model.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.glm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom tidy method for binomial GLM results — tidy.glm","text":"","code":"library(dplyr) library(broom) adrs_f <- tern_ex_adrs %>% filter(PARAMCD == \"BESRSPI\") %>% filter(RACE %in% c(\"ASIAN\", \"WHITE\", \"BLACK OR AFRICAN AMERICAN\")) %>% mutate( Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0), RACE = factor(RACE), SEX = factor(SEX) ) formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = \"Response\") mod1 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\") ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred mod2 <- fit_logistic( data = adrs_f, variables = list( response = \"Response\", arm = \"ARMCD\", covariates = c(\"AGE\", \"RACE\"), interaction = \"AGE\" ) ) #> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred df <- tidy(mod1, conf_level = 0.99) df2 <- tidy(mod2, conf_level = 0.99)"},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.step.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom tidy method for STEP results — tidy.step","title":"Custom tidy method for STEP results — tidy.step","text":"Tidy STEP results tibble format ready plotting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.step.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom tidy method for STEP results — tidy.step","text":"","code":"# S3 method for class 'step' tidy(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.step.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom tidy method for STEP results — tidy.step","text":"x (matrix) results fit_survival_step(). ... used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.step.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom tidy method for STEP results — tidy.step","text":"tibble one row per STEP subgroup. estimates CIs HR scale, respectively. Additional attributes carry metadata also used plotting.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy.step.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom tidy method for STEP results — tidy.step","text":"","code":"library(survival) lung$sex <- factor(lung$sex) vars <- list( time = \"time\", event = \"status\", arm = \"sex\", biomarker = \"age\" ) step_matrix <- fit_survival_step( variables = vars, data = lung, control = c(control_coxph(), control_step(num_points = 10, degree = 2)) ) broom::tidy(step_matrix) #> # A tibble: 10 × 12 #> `Percentile Center` `Percentile Lower` `Percentile Upper` `Interval Center` #> * #> 1 0.0909 0 0.341 50 #> 2 0.182 0 0.432 54 #> 3 0.273 0.0227 0.523 57 #> 4 0.364 0.114 0.614 59.5 #> 5 0.455 0.205 0.705 62 #> 6 0.545 0.295 0.795 64 #> 7 0.636 0.386 0.886 67 #> 8 0.727 0.477 0.977 69 #> 9 0.818 0.568 1 71 #> 10 0.909 0.659 1 74 #> # ℹ 8 more variables: `Interval Lower` , `Interval Upper` , n , #> # events , `Hazard Ratio` , se , ci_lower , #> # ci_upper "},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy_coxreg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"","code":"# S3 method for class 'summary.coxph' tidy(x, ...) # S3 method for class 'coxreg.univar' tidy(x, ...) # S3 method for class 'coxreg.multivar' tidy(x, ...)"},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy_coxreg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"x (list) result Cox regression model fitted fit_coxreg_univar() (univariate models) fit_coxreg_multivar() (multivariate models). ... additional arguments lower level functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy_coxreg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"broom::tidy() returns: summary.coxph objects, data.frame columns: Pr(>|z|), exp(coef), exp(-coef), lower .95, upper .95, level, n. coxreg.univar objects, data.frame columns: effect, term, term_label, level, n, hr, lcl, ucl, pval, ci. coxreg.multivar objects, data.frame columns: term, pval, term_label, hr, lcl, ucl, level, ci.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy_coxreg.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"tidy(summary.coxph): Custom tidy method survival::coxph() summary results. Tidy survival::coxph() results data.frame extract model results. tidy(coxreg.univar): Custom tidy method univariate Cox regression. Tidy result Cox regression model fitted fit_coxreg_univar(). tidy(coxreg.multivar): Custom tidy method multivariate Cox regression. Tidy result Cox regression model fitted fit_coxreg_multivar().","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/tidy_coxreg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom tidy methods for Cox regression — tidy_coxreg","text":"","code":"library(survival) library(broom) set.seed(1, kind = \"Mersenne-Twister\") dta_bladder <- with( data = bladder[bladder$enum < 5, ], data.frame( time = stop, status = event, armcd = as.factor(rx), covar1 = as.factor(enum), covar2 = factor( sample(as.factor(enum)), levels = 1:4, labels = c(\"F\", \"F\", \"M\", \"M\") ) ) ) labels <- c(\"armcd\" = \"ARM\", \"covar1\" = \"A Covariate Label\", \"covar2\" = \"Sex (F/M)\") formatters::var_labels(dta_bladder)[names(labels)] <- labels dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE) formula <- \"survival::Surv(time, status) ~ armcd + covar1\" msum <- summary(coxph(stats::as.formula(formula), data = dta_bladder)) tidy(msum) #> Pr(>|z|) exp(coef) exp(-coef) lower .95 upper .95 level n #> 1 1.287954e-02 0.6110123 1.636628 0.41442417 0.9008549 armcd2 340 #> 2 6.407916e-04 0.4460731 2.241785 0.28061816 0.7090818 covar12 340 #> 3 5.272933e-06 0.3075864 3.251119 0.18517346 0.5109230 covar13 340 #> 4 2.125359e-08 0.1808795 5.528541 0.09943722 0.3290258 covar14 340 ## Cox regression: arm + 1 covariate. mod1 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = \"covar1\" ), data = dta_bladder, control = control_coxreg(conf_level = 0.91) ) ## Cox regression: arm + 1 covariate + interaction, 2 candidate covariates. mod2 <- fit_coxreg_univar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder, control = control_coxreg(conf_level = 0.91, interaction = TRUE) ) tidy(mod1) #> effect term term_label level n hr lcl #> ref Treatment: armcd 2 vs control (1) 2 340 0.6386426 0.4557586 #> covar1 Covariate: covar1 A Covariate Label 2 340 0.607037 0.4324571 #> ucl pval ci #> ref 0.8949131 0.02423805 0.4557586, 0.8949131 #> covar1 0.8520935 0.01257339 0.4324571, 0.8520935 tidy(mod2) #> effect term term_label level n hr #> ref Treatment: armcd 2 vs control (1) 2 340 0.6386426 #> covar1.1 Covariate: covar1 A Covariate Label 340 #> covar1.armcd2/covar11 Covariate: covar1 1 1 0.6284569 #> covar1.armcd2/covar12 Covariate: covar1 2 2 0.5806499 #> covar1.armcd2/covar13 Covariate: covar1 3 3 0.5486103 #> covar1.armcd2/covar14 Covariate: covar1 4 4 0.6910725 #> covar2.1 Covariate: covar2 Sex (F/M) 340 #> covar2.armcd2/covar2F Covariate: covar2 F F 0.6678243 #> covar2.armcd2/covar2M Covariate: covar2 M M 0.5954021 #> lcl ucl pval pval_inter #> ref 0.4557586 0.8949131 0.02423805 #> covar1.1 NA NA 0.9883021 #> covar1.armcd2/covar11 0.3450471 1.1446499 #> covar1.armcd2/covar12 0.2684726 1.2558239 #> covar1.armcd2/covar13 0.2226814 1.3515868 #> covar1.armcd2/covar14 0.2308006 2.0692373 #> covar2.1 NA NA 0.7759013 #> covar2.armcd2/covar2F 0.3649842 1.2219413 #> covar2.armcd2/covar2M 0.3572772 0.9922368 #> ci #> ref 0.4557586, 0.8949131 #> covar1.1 #> covar1.armcd2/covar11 0.3450471, 1.1446499 #> covar1.armcd2/covar12 0.2684726, 1.2558239 #> covar1.armcd2/covar13 0.2226814, 1.3515868 #> covar1.armcd2/covar14 0.2308006, 2.0692373 #> covar2.1 #> covar2.armcd2/covar2F 0.3649842, 1.2219413 #> covar2.armcd2/covar2M 0.3572772, 0.9922368 multivar_model <- fit_coxreg_multivar( variables = list( time = \"time\", event = \"status\", arm = \"armcd\", covariates = c(\"covar1\", \"covar2\") ), data = dta_bladder ) broom::tidy(multivar_model) #> term pval term_label #> armcd.1 armcd ARM (reference = 1) #> armcd.2 ARM 0.01232761 2 #> covar1.1 covar1 7.209956e-09 A Covariate Label (reference = 1) #> covar1.2 A Covariate Label 0.001120332 2 #> covar1.3 A Covariate Label 6.293725e-06 3 #> covar1.4 A Covariate Label 3.013875e-08 4 #> covar2.1 covar2 Sex (F/M) (reference = F) #> covar2.2 Sex (F/M) 0.1910521 M #> hr lcl ucl level ci #> armcd.1 NA NA #> armcd.2 0.6062777 0.40970194 0.8971710 2 0.4097019, 0.8971710 #> covar1.1 NA NA #> covar1.2 0.4564763 0.28481052 0.7316115 2 0.2848105, 0.7316115 #> covar1.3 0.3069612 0.18386073 0.5124813 3 0.1838607, 0.5124813 #> covar1.4 0.1817017 0.09939435 0.3321668 4 0.09939435, 0.33216684 #> covar2.1 NA NA #> covar2.2 1.289373 0.88087820 1.8873019 M 0.8808782, 1.8873019"},{"path":"https://insightsengineering.github.io/tern/main/reference/to_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Replicate entries of a vector if required — to_n","title":"Replicate entries of a vector if required — to_n","text":"Replicate entries vector required.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replicate entries of a vector if required — to_n","text":"","code":"to_n(x, n)"},{"path":"https://insightsengineering.github.io/tern/main/reference/to_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replicate entries of a vector if required — to_n","text":"x (numeric) vector numbers want analyze. n (integer(1)) number entries needed.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Replicate entries of a vector if required — to_n","text":"x required length already NULL, otherwise scalar replicated version n entries.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_n.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Replicate entries of a vector if required — to_n","text":"function fail x length n /scalar.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_string_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert table into matrix of strings — to_string_matrix","title":"Convert table into matrix of strings — to_string_matrix","text":"Helper function use mostly within tests. with_spacesparameter allows test content also indentation table structure. print_txt_to_copy instead facilitate testing development returning well formatted text needs copied pasted expected output.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_string_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert table into matrix of strings — to_string_matrix","text":"","code":"to_string_matrix( x, widths = NULL, max_width = NULL, hsep = formatters::default_hsep(), with_spaces = TRUE, print_txt_to_copy = FALSE )"},{"path":"https://insightsengineering.github.io/tern/main/reference/to_string_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert table into matrix of strings — to_string_matrix","text":"x (VTableTree)rtables table object. widths (numeric NULL) Proposed widths columns x. expected length numeric vector can retrieved ncol(x) + 1 column row names must also considered. max_width (integer(1), string NULL) width title footer (including footnotes) materials word-wrapped . NULL, set current print width session (getOption(\"width\")). set \"auto\", width table (plus table inset) used. Parameter ignored tf_wrap = FALSE. hsep (string) character repeat create header/body separator line. NULL, object value used. \" \", empty separator printed. See default_hsep() information. with_spaces (flag) whether tested table keep indentation relevant spaces. print_txt_to_copy (flag) utility way copy input table directly expected variable instead copying manually.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_string_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert table into matrix of strings — to_string_matrix","text":"matrix strings. print_txt_to_copy = TRUE well formatted printout table printed console, ready copied expected value.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/to_string_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert table into matrix of strings — to_string_matrix","text":"","code":"tbl <- basic_table() %>% split_rows_by(\"SEX\") %>% split_cols_by(\"ARM\") %>% analyze(\"AGE\") %>% build_table(tern_ex_adsl) to_string_matrix(tbl, widths = ceiling(propose_column_widths(tbl) / 2)) #> [1] \" A: \" \" Drug B: Pl C: Comb\" #> [3] \" X acebo ination\" \"—————————————————————————————\" #> [5] \"F \" \" M 33.68 35.98 36.02 \" #> [7] \" e \" \" a \" #> [9] \" n \" \"M \" #> [11] \" M 34.70 35.68 36.28 \" \" e \" #> [13] \" a \" \" n \""},{"path":"https://insightsengineering.github.io/tern/main/reference/try_car_anova.html","id":null,"dir":"Reference","previous_headings":"","what":"tryCatch around car::Anova — try_car_anova","title":"tryCatch around car::Anova — try_car_anova","text":"Captures warnings executing car::Anova.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/try_car_anova.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"tryCatch around car::Anova — try_car_anova","text":"","code":"try_car_anova(mod, test.statistic)"},{"path":"https://insightsengineering.github.io/tern/main/reference/try_car_anova.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"tryCatch around car::Anova — try_car_anova","text":"mod lm, aov, glm, multinom, polr mlm, coxph, coxme, lme, mer, merMod, svyglm, svycoxph, rlm, clm, clmm, suitable model object. test.statistic generalized linear model, whether calculate \"LR\" (likelihood-ratio), \"Wald\", \"F\" tests; Cox Cox mixed-effects model, whether calculate \"LR\" (partial-likelihood ratio) \"Wald\" tests (\"LR\" tests unavailable Cox models using tt argument); default case linear mixed models fit lmer, whether calculate Wald \"Chisq\" Kenward-Roger \"F\" tests Satterthwaite degrees freedom (warning: KR F-tests can time-consuming). multivariate linear model, multivariate test statistic compute — one \"Pillai\", \"Wilks\", \"Hotelling-Lawley\", \"Roy\", \"Pillai\" default. summary method Anova.mlm objects permits specification one multivariate test statistic, default report four.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/try_car_anova.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"tryCatch around car::Anova — try_car_anova","text":"list item aov result model error_text captured warnings.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/try_car_anova.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"tryCatch around car::Anova — try_car_anova","text":"","code":"# `car::Anova` on cox regression model including strata and expected # a likelihood ratio test triggers a warning as only Wald method is # accepted. library(survival) mod <- coxph( formula = Surv(time = futime, event = fustat) ~ factor(rx) + strata(ecog.ps), data = ovarian )"},{"path":"https://insightsengineering.github.io/tern/main/reference/ungroup_stats.html","id":null,"dir":"Reference","previous_headings":"","what":"Ungroup non-numeric statistics — ungroup_stats","title":"Ungroup non-numeric statistics — ungroup_stats","text":"Ungroups grouped non-numeric statistics within input vectors .formats, .labels, .indent_mods.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/ungroup_stats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ungroup non-numeric statistics — ungroup_stats","text":"","code":"ungroup_stats(x, .formats, .labels, .indent_mods)"},{"path":"https://insightsengineering.github.io/tern/main/reference/ungroup_stats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ungroup non-numeric statistics — ungroup_stats","text":"x (named list numeric) list numeric statistics containing statistics ungroup. .formats (named character list) formats statistics. See Details analyze_vars information \"auto\" setting. .labels (named character) labels statistics (without indent). .indent_mods (named integer) indent modifiers labels. Defaults 0, corresponds unmodified default behavior. Can negative.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/ungroup_stats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ungroup non-numeric statistics — ungroup_stats","text":"list modified elements x, .formats, .labels, .indent_mods.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/univariate.html","id":null,"dir":"Reference","previous_headings":"","what":"Univariate formula special term — univariate","title":"Univariate formula special term — univariate","text":"special term univariate indicate model fitted individually every variable included univariate.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/univariate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Univariate formula special term — univariate","text":"","code":"univariate(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/univariate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Univariate formula special term — univariate","text":"x (character) vector variable names separated commas.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/univariate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Univariate formula special term — univariate","text":"used within model formula, produces univariate models variable provided.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/univariate.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Univariate formula special term — univariate","text":"provided alongside pairwise specification, model y ~ ARM + univariate(SEX, AGE, RACE) lead study comparison models y ~ ARM y ~ ARM + SEX y ~ ARM + AGE y ~ ARM + RACE","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/unlist_and_blank_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Blank for missing input — unlist_and_blank_na","title":"Blank for missing input — unlist_and_blank_na","text":"Helper function use tabulating model results.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/unlist_and_blank_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Blank for missing input — unlist_and_blank_na","text":"","code":"unlist_and_blank_na(x)"},{"path":"https://insightsengineering.github.io/tern/main/reference/unlist_and_blank_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Blank for missing input — unlist_and_blank_na","text":"x (vector) input cell.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/unlist_and_blank_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Blank for missing input — unlist_and_blank_na","text":"empty character vector entries x missing (NA), otherwise unlisted version x.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/update_weights_strat_wilson.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"function wraps iteration procedure allows estimate weights proportional strata. assumes minimize weighted squared length confidence interval.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/update_weights_strat_wilson.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"","code":"update_weights_strat_wilson( vars, strata_qnorm, initial_weights, n_per_strata, max_iterations = 50, conf_level = 0.95, tol = 0.001 )"},{"path":"https://insightsengineering.github.io/tern/main/reference/update_weights_strat_wilson.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"vars (numeric) normalized proportions strata. strata_qnorm (numeric(1)) initial estimation identical weights quantiles. initial_weights (numeric) initial weights used calculate strata_qnorm. can optimized future need estimate better initial weights. n_per_strata (numeric) number elements strata. max_iterations (integer(1)) maximum number iterations tried. Convergence always checked. conf_level (proportion) confidence level interval. tol (numeric(1)) tolerance threshold convergence.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/update_weights_strat_wilson.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"list 3 elements: n_it, weights, diff_v.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/update_weights_strat_wilson.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Helper function for the estimation of weights for prop_strat_wilson() — update_weights_strat_wilson","text":"","code":"vs <- c(0.011, 0.013, 0.012, 0.014, 0.017, 0.018) sq <- 0.674 ws <- rep(1 / length(vs), length(vs)) ns <- c(22, 18, 17, 17, 14, 12) update_weights_strat_wilson(vs, sq, ws, ns, 100, 0.95, 0.001) #> $n_it #> [1] 3 #> #> $weights #> [1] 0.2067191 0.1757727 0.1896962 0.1636346 0.1357615 0.1284160 #> #> $diff_v #> [1] 1.458717e-01 1.497223e-03 1.442189e-06 #>"},{"path":"https://insightsengineering.github.io/tern/main/reference/util_handling_additional_fun_params.html","id":null,"dir":"Reference","previous_headings":"","what":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"Important additional parameters, useful modify behavior analysis summary functions listed rtables::additional_fun_params. utility functions can retrieve curated list parameters environment, pass analysis functions dedicated ...; notice final s_* function get argument matching.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/util_handling_additional_fun_params.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"","code":"retrieve_extra_afun_params(extra_afun_params) get_additional_afun_params(add_alt_df = FALSE)"},{"path":"https://insightsengineering.github.io/tern/main/reference/util_handling_additional_fun_params.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"extra_afun_params (list) list additional parameters (character) retrieved environment. Curated list present rtables::additional_fun_params. add_alt_df (logical) TRUE, function also add .alt_df .alt_df_row parameters.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/util_handling_additional_fun_params.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"retrieve_extra_afun_params returns list values parameters environment. get_additional_afun_params returns list additional parameters.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/util_handling_additional_fun_params.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Utilities to handle extra arguments in analysis functions — util_handling_additional_fun_params","text":"retrieve_extra_afun_params(): Retrieve additional parameters environment. get_additional_afun_params(): Curated list additional parameters analysis functions. Please check rtables::additional_fun_params precise descriptions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/utils_split_funs.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom split functions — utils_split_funs","title":"Custom split functions — utils_split_funs","text":"Collection useful functions expanding core list functions provided rtables. See rtables::custom_split_funs rtables::make_split_fun() information make custom split function. functions work rtables::split_rows_by() argument split_fun modify way split happens. split functions, consider consulting rtables::split_funcs.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/utils_split_funs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom split functions — utils_split_funs","text":"","code":"ref_group_position(position = \"first\") level_order(order)"},{"path":"https://insightsengineering.github.io/tern/main/reference/utils_split_funs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom split functions — utils_split_funs","text":"position (string integer) position use reference group facet. Can \"first\", \"last\", specific position. order (character numeric) vector ordering indices split facets.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/utils_split_funs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom split functions — utils_split_funs","text":"ref_group_position() returns utility function puts reference group first, last certain position needs assigned split_fun. level_order() returns utility function changes original levels' order, depending input order split levels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/reference/utils_split_funs.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Custom split functions — utils_split_funs","text":"ref_group_position(): Split function place reference group facet specific position post-processing stage. level_order(): Split function change level order based integer vector character vector represent split variable's factor levels.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/reference/utils_split_funs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom split functions — utils_split_funs","text":"","code":"library(dplyr) dat <- data.frame( x = factor(letters[1:5], levels = letters[5:1]), y = 1:5 ) # With rtables layout functions basic_table() %>% split_cols_by(\"x\", ref_group = \"c\", split_fun = ref_group_position(\"last\")) %>% analyze(\"y\") %>% build_table(dat) #> e d b a c #> ——————————————————————————————————————— #> Mean 5.00 4.00 2.00 1.00 3.00 # With tern layout funcitons adtte_f <- tern_ex_adtte %>% filter(PARAMCD == \"OS\") %>% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM B\", split_fun = ref_group_position(\"first\")) %>% add_colcounts() %>% surv_time( vars = \"AVAL\", var_labels = \"Survival Time (Months)\", is_event = \"is_event\", ) %>% build_table(df = adtte_f) #> ARM B ARM A ARM C #> (N=73) (N=69) (N=58) #> ——————————————————————————————————————————————————————————————————— #> Survival Time (Months) #> Median 23.9 32.0 20.8 #> 95% CI (18.3, 32.9) (22.5, 49.3) (12.9, 26.0) #> 25% and 75%-ile 9.8, 42.0 17.4, 65.3 7.3, 37.1 #> Range 0.1 to 154.1 0.3 to 155.5 0.6 to 80.7 basic_table() %>% split_cols_by(var = \"ARMCD\", ref_group = \"ARM B\", split_fun = ref_group_position(2)) %>% add_colcounts() %>% surv_time( vars = \"AVAL\", var_labels = \"Survival Time (Months)\", is_event = \"is_event\", ) %>% build_table(df = adtte_f) #> ARM A ARM B ARM C #> (N=69) (N=73) (N=58) #> ——————————————————————————————————————————————————————————————————— #> Survival Time (Months) #> Median 32.0 23.9 20.8 #> 95% CI (22.5, 49.3) (18.3, 32.9) (12.9, 26.0) #> 25% and 75%-ile 17.4, 65.3 9.8, 42.0 7.3, 37.1 #> Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 # level_order -------- # Even if default would bring ref_group first, the original order puts it last basic_table() %>% split_cols_by(\"Species\", split_fun = level_order(c(1, 3, 2))) %>% analyze(\"Sepal.Length\") %>% build_table(iris) #> setosa virginica versicolor #> —————————————————————————————————————— #> Mean 5.01 6.59 5.94 # character vector new_order <- level_order(levels(iris$Species)[c(1, 3, 2)]) basic_table() %>% split_cols_by(\"Species\", ref_group = \"virginica\", split_fun = new_order) %>% analyze(\"Sepal.Length\") %>% build_table(iris) #> setosa virginica versicolor #> —————————————————————————————————————— #> Mean 5.01 6.59 5.94"},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-6-9015","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.6.9015","text":"Added denom parameter s_count_cumulative(), s_count_missed_doses(), s_count_occurrences_by_grade(). Added \"N_row\" optional input denom s_count_occurrences(). Refactored a_count_occurrences_by_grade(), a_count_patients_with_event(), a_count_patients_with_flags() longer use make_afun(). Added rel_height_plot parameter g_lineplot() control line plot height relative annotation table height. Updated table_font_size parameter g_lineplot() control size text annotation table, including labels. Added as_list parameter g_lineplot() allow users return line plot annotation table elements list instead stacked complex customization. Refactored summarize_change() work without make_afun() access additional function parameter. Added vignette “Understanding tern functions” future reference.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-6-9015","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.6.9015","text":"Fixed bug a_summary() causing non-unique row_name values occur multiple statistics selected count variables.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-6-9015","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.6.9015","text":"Reverted deprecation quick get functions summary_formats() summary_labels(). Added disclaimer underlying use get_stats. Corrected handling extra arguments NA summarize_change().","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-096","dir":"Changelog","previous_headings":"","what":"tern 0.9.6","title":"tern 0.9.6","text":"CRAN release: 2024-09-24","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-6","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.6","text":"Added median_ci_3d s_summary includes estimate confidence interval one statistic. Added median_ci_3d, quantiles_lower quantiles_upper s_surv_time includes estimate confidence interval one statistic. Added hr_ci_3d s_coxph_pairwise includes estimate confidence interval one statistic. Added event_free_rate_3d s_surv_timepoint includes estimate confidence interval one statistic. Added rate_diff_ci_3d s_surv_timepoint_diff includes estimate confidence interval one statistic. Added errorbar_width linetype parameters g_lineplot. Added .formats argument tabulate_rsp_subgroups tabulate_survival_subgroups allow users specify formats. Added riskdiff argument tabulate_rsp_subgroups tabulate_survival_subgroups allow users add risk difference table column, function control_riskdiff specify settings risk difference column. Added warning tabulate_rsp_subgroups pval statistic selected df correctly generated add p-values output table. Added n_rate statistic non-default option estimate_incidence_rate returns number events observed estimated incidence rate. Added n_unique statistic non-default option estimate_incidence_rate returns total number patients least one event observed. Refactored estimate_incidence_rate work analyze function summarize function, controlled added summarize parameter. summarize = TRUE, labels can fine-tuned via new label_fmt argument function. Added fraction statistic analyze_var_count method group. Improved summarize_glm_count() documentation associated functions better describe results functions’ purpose. Added method argument s_odds_ratio() estimate_odds_ratio() control whether exact approximate conditional likelihood calculations used.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-6","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.6","text":"Added defaults d_count_cumulative parameters described documentation. Fixed bug empty levels g_lineplot x-axis shown either plots. Fixed bug a_surv_time threw error split \"is_event\". Fixed disappearing line g_lineplot using one group strata level. Fixed defaults formats labels get_formats_from_stats get_labels_from_stats. Fixed bug linear scaling factor (scale parameter) applied response rate h_glm_count distributions logarithmic link function. Fixed bug decorate_grob handle well empty strings NULL values title footers. Fixed bug g_km caused error multiple records data estimates max time. Fixed issue wrong wrapping due different \\n vector behavior cope well split_string().","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-6","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.6","text":"Began deprecation confusing functions summary_formats summary_labels. Enhanced general descriptions analyze summarize functions throughout package documentation. Finalized deprecation strata cohort_id arguments g_lineplot. Moved incidence rate helper functions separate h_incidence_rate.R file.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-095","dir":"Changelog","previous_headings":"","what":"tern 0.9.5","title":"tern 0.9.5","text":"CRAN release: 2024-06-21","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.5","text":"Added facet_var g_lineplot allow plot faceting factor variable. Added examples tests label_all parameter extract_survival_biomarkers extract_survival_subgroups. Added xticks, xlim, ylim arguments g_lineplot allow customization x y axes. Updated g_lineplot legend follow factor levels set users.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-5","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.5","text":"Fixed bug s_ancova prevented statistics printed arm levels include special characters. Fixed bug decorate_grob prevented right margins respected adding title footers decorations.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-5","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.5","text":"Began deprecation unused label_all parameter tabulate_survival_biomarkers tabulate_survival_subgroups, redirection parameter associated extract_* functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-094","dir":"Changelog","previous_headings":"","what":"tern 0.9.4","title":"tern 0.9.4","text":"CRAN release: 2024-04-17","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-9-4","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.4","text":"Added h_glm_negbin h_glm_count enable count data analysis using negative binomial model. Added argument grade_groups_only count_occurrences_by_grade allow users display rows specified grade groups. Added internal function df2gg converts data.frame objects ggplot objects. Added functions control_surv_med_annot control_coxph_annot configure g_km annotation table sizes/positions. Refactored g_km output ggplot object instead grob object. Refactored g_forest output ggplot object instead grob object.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.4","text":"Default format mean p-values (mean_pval) updated \"xx.xx\" \"x.xxxx | (<0.0001)\".","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-4","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.4","text":"Fixed nested column split label overlay issue rtable2gg clean appearance text labels. Fixed bug s_ancova causing incorrect difference calculations arm variables irregular levels. Fixed bug format_count_fraction_fixed_dp print fraction 1 (100%). Fixed bug g_lineplot causing default labels update according specified control settings. Fixed bug causing error automatic value formatting applied NA values.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-4","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.4","text":"Added function expect_snapshot_ggplot test setup file process plot snapshot tests allow plot dimensions set. Adapted argument renames introduced ggplot2 3.5.0. Renamed individual_patient_plot.R g_ipp.R. Removed instances deprecated parameters time_unit_input, time_unit_output, na_level indent_mod. Removed deprecated functions summarize_vars, control_summarize_vars, a_compare, create_afun_summary, create_afun_compare, summary_custom. Removed vdiffr package Suggests DESCRIPTION file. Began deprecation named element strat, renamed strata, within variables argument h_rsp_to_logistic_variables, h_logistic_mult_cont_df, h_odds_ratio_subgroups_df, h_coxreg_mult_cont_df, h_coxph_subgroups_df, h_tbl_coxph_pairwise, extract_rsp_biomarkers, extract_rsp_subgroups, extract_survival_biomarkers, extract_survival_subgroups. Began deprecation strat argument s_coxph_pairwise replaced strata argument. Began deprecation forest_grob, forest_dot_line, forest_viewport, vp_forest_table_part, grid.forest functions. Began deprecation longer used Kaplan-Meier helper functions h_ggkm, h_decompose_gg, h_km_layout, h_grob_tbl_at_risk, h_grob_median_surv, h_grob_y_annot, h_grob_coxph. Began deprecation grob/grid related functions stack_grobs, arrange_grobs, draw_grob longer used tern.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-093","dir":"Changelog","previous_headings":"","what":"tern 0.9.3","title":"tern 0.9.3","text":"CRAN release: 2023-12-08","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-9-3","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.3","text":"Added ref_group_position function place reference group facet last, first certain position. Added keep_level_order split function retain original order levels split. Added level_order split function reorder manually levels. Added function get_indents_from_stats format return indent modifiers given set statistics. Added internal utility function apply_auto_formatting check \"auto\" formats replace implementation format_auto analyze functions. Added utility function labels_use_control modify labels control specifications. Added list containing default statistics method group, tern_default_stats. Added summarize function version count_occurrences analyze function, summarize_occurrences. Added referential footnotes surv_time censored range observations, controlled via ref_fn_censor parameter. Added helper function h_adlb_abnormal_by_worst_grade prepare ADLB data use input count_abnormal_by_worst_grade. Added s_bland_altman function assess agreement two numerical vectors. Added function rtable2gg converts rtable objects ggplot objects. Added helper function set default na_str globally set_default_na_str() added default_na_str() interested functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.3","text":"Added ref_group_coxph parameter g_km specify reference group used pairwise Cox-PH calculations annot_coxph = TRUE. Added annot_coxph_ref_lbls parameter g_km enable printing reference group table labels annot_coxph = TRUE. Added x_lab parameter g_lineplot customize x-axis label. Remove 25% padding y-axis g_lineplot. Added support creating multiple risk difference columns, comparing single comparison group. Multiple comparison groups can specified vector via arm_y argument. Allowed numeric vector count_by input analyze_num_patients summarize_num_patients. Aligned plot table vertically g_lineplot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-3","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.3","text":"Fixed bug decorate_grob preventing text wrapping accounting font size. Fixed implementation na_str argument column-wise analysis tabulation functions.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-3","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.3","text":"Specified minimal version package dependencies. Upgraded to_string_matrix take account widths printing parameters.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-9-2","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.2","text":"Added na_str argument analyze & summarize_row_groups wrapper functions count_abnormal, count_abnormal_by_baseline, count_abnormal_by_marked, count_abnormal_by_worst_grade, count_abnormal_lab_worsen_by_baseline, count_cumulative, count_missed_doses, count_occurrences, count_occurrences_by_grade, summarize_occurrences_by_grade, summarize_patients_events_in_cols, count_patients_with_event, count_patients_with_flags, count_values, estimate_multinomial_response, estimate_proportion, h_tab_one_biomarker, estimate_incidence_rate, logistic_summary_by_flag, estimate_odds_ratio, estimate_proportion_diff, test_proportion_diff, summarize_ancova, summarize_change, summarize_glm_count, summarize_num_patients, analyze_num_patients, summarize_patients_exposure_in_cols, coxph_pairwise, tabulate_survival_subgroups, surv_time, surv_timepoint.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.2","text":"Added formatting function format_count_fraction_lt10 formatting count_fraction special consideration count less 10. Updated s_summary.logical output count_fraction denominator zero display NA instead 0 tables. Updated analyze_vars_in_cols allow character input indicate whether nominal time point post-dose pre-dose applying 1/3 imputation rule.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-2","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.2","text":"Fixed bug g_km causing error converting certain annotation width units.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-2","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.2","text":"Began deprecation na_level argument s_count_abnormal_by_baseline, a_summary, analyze_vars, analyze_vars_in_cols, compare_vars, h_map_for_count_abnormal, h_stack_by_baskets, summarize_colvars, a_coxreg, summarize_coxreg replaced na_str argument. strata cohort_id parameters renamed group_var subject_var respectively g_lineplot control_lineplot_vars .","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-9-1","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.1","text":"Added imputation_rule function apply imputation rule data. Added new format function format_sigfig allow numeric value formatting specified number significant figures. Added vectors containing default statistic formats labels tern_default_formats tern_default_labels, respectively. Added function get_stats return methods given statistical method groups. Added function get_formats_from_stats return formats get_labels_from_stats return labels given set statistics. Added \"auto\" option .formats. uses format_auto determine automatically number digits. Added title argument h_grob_tbl_at_risk annot_at_risk_title argument g_km h_km_layout allows user add “Patients Risk” title Kaplan-Meier risk annotation table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-1","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.1","text":"Refactored tabulate_rsp_subgroups pass sanitation checks preventing creation degenerate subtables. Updated analyze_vars_in_cols use caching, allow implementation imputation rule via imp_rule argument, allow user specify cell alignment via .aligns argument. Updated add_rowcounts allow addition row counts alt_counts_df using alt_counts argument. Added gp argument g_forest control graphical parameters font size.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-1","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.1","text":"Grouped functions relating valid method names default formats labels new source file utils_defaults_handling.R. Started deprecation summary_custom() a_summary() S3 method. Renamed statistical method p-value discrete case pval_counts. Removed a_summary_internal() favor one main a_summary().","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-090","dir":"Changelog","previous_headings":"","what":"tern 0.9.0","title":"tern 0.9.0","text":"CRAN release: 2023-09-01","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-9-0","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.9.0","text":"Added stat_propdiff_ci function calculate proportion/risk difference CI. Added risk difference column functionality via riskdiff argument functions count_occurrences, count_occurrences_by_grade, count_patients_with_event, count_patients_with_flags, analyze_num_patients, summarize_num_patients.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-9-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.9.0","text":"Refactored function a_summary longer use helper function create_afun_summary. Refactored functions summarize_vars compare_vars use refactored a_summary function. Created new internal helper functions ungroup_stats ungroup statistics calculated factor variables, a_summary_internal perform calculations a_summary.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-9-0","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.9.0","text":"Fixed bug s_count_occurrences_by_grade “missing” grade always appears final level. Fixed bug analyze_vars_in_cols categorical data used. Fixed bug s_count_occurrences_by_grade levels relabeled reordering account “missing” grades.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-9-0","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.9.0","text":"Fixed swapped descriptions .N_row .N_col parameters. Removed internal calls df_explicit_na. Changes NA values happen externally tern functions, depending users’ needs. Reinstated correct soft deprecation create_afun_summary create_afun_compare.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-8-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.5","text":"Added ylim argument g_km allow user set custom limits y-axis. Added assertion g_km checks whether one arm present data annot_coxph true. Added flag_labels argument s_count_patients_with_flags enable label handling options count_patients_by_flags. Added nested argument analyze wrapper functions count_abnormal, count_abnormal_by_baseline, count_abnormal_by_marked, count_abnormal_by_worst_grade, count_abnormal_lab_worsen_by_baseline, count_cumulative, count_missed_doses, count_occurrences, count_occurrences_by_grade, count_patients_with_event, count_patients_with_flags, count_values, estimate_multinomial_response, estimate_proportion, estimate_incidence_rate, estimate_odds_ratio, estimate_proportion_diff, test_proportion_diff, summarize_ancova, summarize_change, summarize_glm_count, analyze_num_patients, coxph_pairwise, surv_time, surv_timepoint.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-8-5","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.5","text":"Started deprecation cycle summarize_vars control_summarize_vars. Renamed analyze_vars control_analyze_vars reflect underlying rtables machinery keeping backward compatibility aliases.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-084","dir":"Changelog","previous_headings":"","what":"tern 0.8.4","title":"tern 0.8.4","text":"CRAN release: 2023-06-27","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-8-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.4","text":"Added method character class h_coxreg_inter_effect enabling character covariates summarize_coxreg.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-8-4","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.4","text":"Began deprecation time_unit_input time_unit_output arguments replaced input_time_unit num_pt_year, respectively, control_incidence_rate. Removed deprecated pairwise function. Deprecated a_compare replaced a_summary argument compare = TRUE. Deprecated helper functions create_afun_summary create_afun_compare longer used a_summary a_compare respectively.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-8-4","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.4","text":"Fixed long double assertion check sum(weights) M1mac installation.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-083","dir":"Changelog","previous_headings":"","what":"tern 0.8.3","title":"tern 0.8.3","text":"CRAN release: 2023-06-19","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-8-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.3","text":"Added explicit zero counts g_km plot “risk” annotation tables. Added flag total level split analyze_patients_exposure_in_cols. Implemented .indent_mods argument functions h_tab_one_biomarker, h_tab_rsp_one_biomarker, h_tab_surv_one_biomarker, summarize_logistic, logistic_summary_by_flag, tabulate_rsp_biomarkers, a_coxreg, summarize_coxreg, tabulate_survival_biomarkers, surv_time, surv_timepoint, cfun_by_flag. Updated summarize_coxreg print covariates data rows univariate Cox regression interactions content rows otherwise. Removed “baseline status” text d_count_abnormal_by_baseline labels. Improved default sizing annotation tables g_km added dynamic scaling surv_med coxph annotation tables, customization via width_annots argument.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-8-3","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.3","text":"Fixed bug split_text_grob preventing titles footnotes properly formatted printed decorate_grob. Fixed bug g_lineplot preventing addition lines plot midpoint statistic calculations result NA value(s). Fixed tern:::tidy.glm formals respect broom:::tidy.default formals.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-8-3","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.3","text":"Updated README include installation instructions CRAN. Remove examples unexported functions. Export functions has_count_in_cols, has_counts_difference, combine_counts, h_tab_rsp_one_biomarker, arrange_grobs, a_count_patients_sum_exposure, a_coxreg, groups_list_to_df, forest_viewport. Updated README include installation instructions CRAN. Began deprecation indent_mod argument replaced .indent_mods argument summarize_num_patients analyze_num_patients.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"breaking-changes-0-8-2","dir":"Changelog","previous_headings":"","what":"Breaking Changes","title":"tern 0.8.2","text":"Refactored s_coxreg summarize_coxregto work new analysis function a_coxreg.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-8-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.2","text":"Added section_div na_level arguments summarize_vars. Added median_range numeric variable statistic option summarize_vars. Corrected ordering factor levels d_onco_rsp_label. Added new “Analyze Functions”, “Summarize Functions”, “Analyze Functions Columns” overview pages. Consolidated KM plot documentation within g_km function. Added a_count_patients_sum_exposure summarize_patients_exposure_in_cols new analyze function analyze_patients_exposure_in_cols. Added informative error user selects invalid method unstratified analyses s_proportion_diff. Updated s_summary s_compare allow NA values input variables. factor variables NAs, na.rm = FALSE explicit NA level automatically added. na.rm = TRUE also consider \"\" values exclude . Updated purpose na_level parameter s_summary s_compare align tern functions. Instead string consider NA setting na.rm = TRUE, now defines string print place NA values output table.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-8-2","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.2","text":"Fixed missing label TRTEDTM tern datasets. Fixed improper implementation na_level argument summarize_vars preventing effect.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-8-2","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.2","text":"Implemented lubridate package date variables tern datasets. Organized .gitignore .Rbuildignore files. Removed deprecated footnotes functions related files. Started deprecation cycle pairwise function. Moved count_patients_with_flags functions count_patients_with_event.R count_patients_with_flags.R.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-8-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.8.0","text":"Added summarize_glm_count function analyze count data using linear model. Added legend g_step. Added formatting functions format_fraction_fixed_dp format_count_fraction_fixed_dp fixed single decimal place percentages. Added na_level labelstr arguments summarize_vars_in_cols. Added analyze_num_patients include summary beginning repeat paginating. Added h_row_first_values function general helper function retrieve first values specific rows. Added option remove \"(n)\" suffix unique_count labels s_num_patients. Added options g_km annotate statistics (annot_stats) add corresponding vertical lines (annot_stats_lines).","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-8-0","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.8.0","text":"Fixed bug causing incorrect ordering numeric grade levels missing grades present s_count_occurrences_by_grade. Refactored summarize_vars_in_cols work pagination machinery. Fixed bug allow passing conf_level argument emmeans::contrast() s_ancova. Fixed bugs rtables_access.R caused checking specific combinations (also standard values never used) column indices names. Fixed single applicable record bug count_abnormal_by_grade. Fixed bug add_rowcounts caused row count row values count zero. Fixed bug h_col_indices causing error pruning combination columns. Fixed bug test_proportion_diff missing argument var_labels.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"documentation-and-tests-0-8-0","dir":"Changelog","previous_headings":"","what":"Documentation and Tests","title":"tern 0.8.0","text":"Added tests increase code coverage. Created separate documentation files functions different sections pkgdown reference. Created separate .R files logistic regression cox regression helper functions. Fixed table tests using analyze_num_patients generate initial summary repetition paginating. Updated tests use testthat 3rd edition replaced applicable tests snapshot testing. Updated summarize_ancova examples use iris dataset instead scda data. Created vignette saves cached synthetic CDISC dataset files data/ folder generated cached synthetic datasets. Updated examples/tests use datasets data/ folder instead scda datasets. Removed template tests tern. tests internal repo scda.test.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-8-0","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.8.0","text":"Renamed summarize_vars_in_cols analyze_vars_in_cols reflect appropriate analyze logic. Removed redundant summary_in_cols helper functions. Exported function format_xx. Replaced deprecated ggplot2 functions/arguments fix warnings. Replaced deprecated function forcats::fct_explicit_na forcats::fct_na_value_to_level. Removed deprecated wrap_text function related files. Started deprecation cycle footnotes functions.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-7-10","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.7.10","text":"Added stratified Newcombe stratified Wilson statistics estimate_proportion estimate_proportion_diff relative tests. Added stat_mean_pval, new summary statistic calculate p-value mean. Added statistic mean_se (mean standard error) summarize_variables related functions. Introduced Rdpack references.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-10","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.10","text":"Redesign data handling tests removing repetitive data loads library calls. Added DescTools::BinomDiffCI function within tern. Added new parameter summarize_logistic specify pivoted value use analysis. Updated s_coxph_pairwise generate log-rank p-value using original log-rank test instead Cox Proportional-Hazards Model. Implemented nestcolor examples adapting g_km, g_ipp, g_waterfall, g_step, g_lineplot, g_forest. Added parameters interaction_y interaction_item ANCOVA make interaction calculations available. Added new parameter footnotes add footnotes g_km.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"migration-from-assertthat-to-checkmate-0-7-10","dir":"Changelog","previous_headings":"","what":"Migration from assertthat to checkmate","title":"tern 0.7.10","text":"Implemented checkmate::assert_vector, checkmate::assert_set_equal, checkmate::assert_int check vector type, length, values. Replaced standard assertions checkmate following functions: all_elements_in_ref, is_df_with_nlevels_factor, is_df_with_no_na_level, is_proportion_vector, is_quantiles_vector, is_character_or_factor, is_nonnegative_count, is_valid_character, assert_character_or_factor, assert_equal_length has_tabletree_colnames. Modified is_proportion, is_equal_length, is_df_with_no_na_level, is_df_with_nlevels_factor, is_variables, is_df_with_variables, is_df_with_factors, is_valid_factor use assertion logic. Added verbose warnings as_factor_keep_attributes. Made assert_df_with_factors assert_proportion_value internal functions. Renamed assertthat.R test-assertthat.R utils_checkmate.R test-utils_checkmate.R.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"documentation-and-namespace-polishing-0-7-10","dir":"Changelog","previous_headings":"","what":"Documentation and NAMESPACE Polishing","title":"tern 0.7.10","text":"count_abnormal_by_marked (reference abnormal_by_marked), count_abnormal_lab_worsen_by_baseline h_adlb_worsen (reference abnormal_by_worst_grade_worsen_from_baseline), count_abnormal_by_worst_grade (reference abnormal_by_worst_grade), to_string_matrix, tidy.summary.coxph, tidy.step, surv_timepoint, (reference survival_timepoint), surv_time (reference survival_time), coxph_pairwise (reference survival_coxph_pairwise), extract_survival_subgroups tabulate_survival_subgroups (reference survival_duration_subgroups), extract_survival_biomarkers tabulate_survival_biomarkers (reference survival_biomarkers_subgroups), control_summarize_vars, s_summary a_summary (reference summarize_variables) kept S3 method tree. summarize_patients_exposure_in_cols, summarize_num_patients s_num_patients, s_num_patients_content, summarize_num_patients. count_cumulative, count_missed_doses, count_patients_events_in_cols, summarize_colvars, summarize_change, summarize_ancova,.rtable, color_palette, add_footnotes. (statistical function controls) control_coxreg, control_coxph, control_incidence_rate, control_lineplot_vars, control_surv_time, control_surv_timepoint, control_logisitic, control_step. stat_mean_ci, stat_median_ci, split_cols_by_groups, explicit_na, sas_na, extract_rsp_subgroups, tabulate_rsp_subgroups, extract_rsp_biomarkers, tabulate_rsp_biomarkers, keep_rows, keep_content_rows, has_count_in_any_col, has_fraction_in_cols, has_fraction_in_any_col, has_fractions_difference, test_proportion_diff, pairwise, logistic_regression, estimate_incidence_rate, control_incidence_rate (reference incidence_rate), cut_quantile_bins, estimate_multinomial_rsp, decorate_grob_set, extreme_format, fit_rsp_step, fit_survival_step, footnotes, footnotes-set, format_count_fraction, format_fraction_threshold, formatting_functions, format_fraction, combination_function (S4 method), compare_variables (S3 method), kaplan_meier. (chain functions, reference abnormal_by_marked) s_count_abnormal_by_marked, a_count_abnormal_by_marked. (chain functions, reference abnormal_by_worst_grade_worsen_from_baseline) a_count_abnormal_lab_worsen_by_baseline, s_count_abnormal_lab_worsen_by_baseline. (chain functions, reference abnormal_by_worst_grade) s_count_abnormal_by_worst_grade, a_count_abnormal_by_worst_grade. (chain functions, reference survival_timepoint) s_surv_timepoint, s_surv_timepoint_diff, a_surv_timepoint, a_surv_timepoint_diff. (chain functions, reference survival_time) s_surv_time, a_surv_time. (chain functions, reference survival_coxph_pairwise) s_coxph_pairwise, a_coxph_pairwise. (chain functions, reference survival_duration_subgroups) a_survival_subgroups. (chain functions, reference count_cumulative) s_count_cumulative, a_count_cumulative. (chain functions, reference count_missed_doses) s_count_nonmissing, s_count_missed_doses, a_count_missed_doses. (chain functions, reference count_patients_events_in_cols) s_count_patients_and_multiple_events, summarize_patients_events_in_cols. (chain functions, reference incidence_rate) s_incidence_rate, a_incidence_rate. (cox regression helper) cox_regression_inter, decorate_grob_factory, draw_grob, estimate_coef. summary_labels, summary_formats, s_count_patients_sum_exposure, a_change_from_baseline s_change_from_baseline, a_ancova, s_ancova, arrange_grobs, as_factor_keep_attributes, combine_levels, split_text_grob, groups_list_to_df, s_cox_multivariate, is_leaf_table, a_response_subgroups, range_noinf, has_count_in_cols, has_counts_difference, prop_chisq, prop_cmh, prop_schouten, prop_fisher, s_test_proportion_diff, a_test_proportion_diff, fct_discard, fct_explicit_na_if.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-7-10","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.10","text":"Fixed retrieval method stats::ancova output due version inconsistency. Fixed tests respect new standard print NA coming rtables. Fixed error tests coming changes formatters::var_labels. Fixed prop_diff functions respect success responses (TRUE values). Fixed error coming comparing factors vector characters vector. Fixed empty vector exception cut_quantile_bins. Fixed exception error empty strings present pivoted columns (rtables split functions) Fixed bug s_ancova causing error first level arm factor control arm. Fixed bug s_abnormal_by_worst_grade one PARAM level. Fixed bug prop_diff_wald selecting responders, updated tests accordingly. Fixed bug h_ancova caused error deselecting covariates.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-10","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.10","text":"Added deprecated badge g_mmrm. Removed internal function calls examples (tern:::) added dontrun internal function examples. Removed warnings messages console occurring examples tests. Deprecated functions color_palette h_set_nest_theme favor nestcolor::color_palette nestcolor::theme_nest, respectively. Removed deprecated functions: color_palette, color_palette_core, h_set_nest_theme, s_cox_univariate. Removed deprecated MMRM functions: fit_mmrm, g_mmrm_diagnostic, g_mmrm_lsmeans, .rtable.mmrm, h_mmrm_fixed, h_mmrm_cov, h_mmrm_diagnostic, tidy.mmrm, s_mmrm_lsmeans, s_mmrm_lsmeans_single, summarize_lsmeans. Renamed functions arm study_arm extract extract_by_name. Renamed rtables.R utils_rtables.R. Extracted cox_regression_inter separate file cox_regression. Renamed estimate_incidence_rate.R incidence_rate.R match documentation grouping name. Extracted control_incidence_rate separate file produces separate documentation file. Added @md removed @order incidence_rate.R. Modified examples accordingly. Removed hyperlink prop_schouten function documentation. Exported draw_grob function.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"fix-0-7-8","dir":"Changelog","previous_headings":"","what":"Fix","title":"tern 0.7.8","text":"h_split_by_subgroups documentation warning fix wrong placing example block","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"documentation-and-namespace-polishing-0-7-8","dir":"Changelog","previous_headings":"","what":"Documentation and NAMESPACE polishing","title":"tern 0.7.8","text":"Adopting standard badges @description instead every @descriptionIn function. Corrected accordingly summarize_variables_in_cols Added stable badge g_lineplot, g_step, g_waterfall, cox_regression, score_occurrences, add_rowcounts, odds_ratio, count_occurrences, count_occurrences_by_grade, explicit_na, df_explicit_na, count_patients_with_event, decorate_grob, combine_groups, append_varlabels, univariate, stack_grobs, count_abnormal (reference abnormal), count_abnormal_by_baseline (reference abnormal_by_baseline). (helper functions) h_format_row, h_map_for_count_abnormal (utils functions) make_names, month2day, day2month empty_vector_if_na, aesi_label, n_available, format_xx, arm. count_values_funs, prop_difference, combine_counts. (chain functions) s_count_abnormal, a_count_abnormal. (chain functions) s_count_abnormal_by_baseline, a_count_abnormal_by_baseline, d_count_abnormal_by_baseline. Deprecated s_cox_univariate function now deprecated badge.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-8","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.8","text":"Enhanced g_lineplot table automatically scale table height return ggplot object. Enhanced g_ipp caption argument adjust position. Enhanced prop_diff, tern function related functions able apply continuity correction Newcombe method. Enhanced summarize_numeric_in_columns summarize_variables allow factor/character summary able summarize number BLQs AVALC ADPC dataset. Updated order summarize variables stats manual order consistency. Added sum option summarize_variables. Use consistent color palette plotting (stream default). Enhanced h_pkparam_sort function argument key_var allow data different column names.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-8","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.8","text":"Updated test-table_aet02.R variant 12. Changed scda data version ‘2022-02-28’. Added template pkgdown site. Removed package dependencies grDevices, stringr, viridisLite. Renaming summarize_numeric_in_columns summarize_variables_in_columns. Renaming summarize_vars_numeric_in_cols summarize_vars_in_cols. Fixed bug points g_lineplot plot connected missing values. Updated package authors.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"breaking-changes-0-7-7","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tern 0.7.7","text":"Move MMRM separate package tern.mmrm.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-7-7","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.7","text":"Added h_pkparam_sort order PK PARAM value based order dataset generated d_pkparam(). Added d_pkparam generate PK parameter map sorting.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-7","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.7","text":"Changed nudge_y argument h_g_ipp dependent data, fixing issue whereby baseline labels offset incorrectly. Enhanced stat_mean_ci s_summary.numeric calculate geometric mean confidence intervals.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-7","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.7","text":"Updated dependencies internal adjustments rtables package refactor. Removed with_label, var_labels, var_labels<- resolve conflict formatters package, new dependency. Added new “Introduction tern” “tern tabulation” vignettes.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-7-6","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.6","text":"Added h_map_for_count_abnormal create map used trim_levels_to_map split function calling helper function. supports two methods: one observed mapping, one least low limit zero least one non missing high limit. Added s_summary_numeric_in_cols summarize_vars_numeric_in_cols functions generate summary statistics columns, mainly used PK datasets. Added five statistics s_summary.numeric use s_summary_numeric_in_cols.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-6","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.6","text":"Enhanced functions tabulate_survival_subgroups tabulate_rsp_subgroups (Survival Duration Best Response analyses) calculate N-s based records considered create model. Enhanced function estimate_proportion related functions able apply continuity correction Wilson method. Refactored count_abnormal_by_marked related statistics formatting functions use efficient layout .spl_context argument used determining denominators trim_levels_to_map split function split_rows_by show desired levels table. breaking change. Refactored count_abnormal_by_worst_grade related statistics formatting functions use efficient layout .spl_context argument used determining denominators trim_levels_to_map split function split_rows_by show desired levels table. breaking change. Refactored count_abnormal function related statistics formatting functions use efficient layout trim_levels_to_map split function split_rows_by show desired levels table. Also updated abnormal argument able consider one level direction. breaking change. Enhanced function estimate_incidence_rate related functions consider week time unit data input.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-7-6","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tern 0.7.6","text":"Fixed bug assertthat functions output wrong data frame names limited length failure message outputs.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-6","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.6","text":"Removed dependency utils.nest using checkmate purrr packages validation moved get_free_cores skip_if_too_deep functions utils.nest tern.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-7-5","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.5","text":"Added functions estimate continuous biomarker effects across subgroups survival binary response endpoints, used produce corresponding forest plots, see survival_biomarkers_subgroups response_biomarkers_subgroups. Added g_lineplot plot function, including new h_format_row helper function control_lineplot_vars function. Removed g_summary_by. Added new safety helper function h_stack_by_baskets stack events SMQ /CQ basket flag ADAE data set.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.5","text":"Added couple new statistics s_summary.numeric. Added names attribute element final list returned s_summary.numeric function. Added summary_formats summary_labels helper functions. Added option also convert logical variables factor variables df_explicit_na. Refactored h_append_grade_groups improve flexibility, robustness clearness, make sure result ordering according order grade_groups. Also, added remove_single argument controls whether elements one-element grade groups output removed. Added var_labels show_labels arguments count_occurrences count_patients_with_flags allow creation title row. Added na_level argument count_abnormal_by_baseline. Updated h_append_grade_groups longer fill-empty grade groups zeros.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-7-5","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.5","text":"Fixed prop_diff_cmh handle edge case FALSE (TRUE) responses. Enhanced g_mmrm_diagnostic improve error handling data amenable Locally Weighted Scatterplot Smoothing. Plot can now display combination annotation tables number patients risk, median survival time, Cox-PH summary. Function return warning instead error arm variable includes single level annot_coxph = TRUE. Lines plot now start time 0 probability 1. Category labels can include equals sign.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-5","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.5","text":"Fixed day2month month2day work NA data. Added parameters stat_mean_ci stat_median_ci may return different outputs. Added functionality h_row_counts handle analysis rows NULL cells. Updated LICENCE README new package references. Added error_on_lint: TRUE .lintr.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-7-4","dir":"Changelog","previous_headings":"","what":"New features","title":"tern 0.7.4","text":"count_abnormal_by_marked tabulates marked laboratory abnormalities. summarize_patients_exposure_in_cols tabulates patient counts sum exposure across patients.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.4","text":"Enhanced MMRM-related functions fitting models without arm variable. Updated cox_regression work without covariates. Also case interaction model summary, p-values main effect coefficients longer displayed. Descriptive statistics returned summarize_vars now include quantiles. summarize_vars now accepts control function control_summarize_vars specify details confidence level mean median quantile details. control argument replaces conf_level. Added var_labels show_labels arguments count_occurrences_by_grade. Changed indent argument append_varlabels accept non-negative integer represent indent space defined user. Previous calls Boolean indent integer conversion produce warning.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-7-4","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.4","text":"Corrected tabulate_survival_subgroups related survival forest plot functions use total number events, instead observations, default scaling symbol sizes plot. (user might still use total number observations manually wish .) Helper function h_adsl_adlb_merge_using_worst_flag now impute BTOXGR missing visits.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-4","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.4","text":"Deleted count_abnormal_by_worst_grade_by_baseline related statistic analysis functions simpler design create lab abnormality tables. Switched data examples use scda instead random.cdisc.data package.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-features-0-7-3","dir":"Changelog","previous_headings":"","what":"New Features","title":"tern 0.7.3","text":"Added Subgroup Treatment Effect Pattern (STEP) model fitting functions fit_rsp_step fit_survival_step, corresponding tidy method tidy.step well graph function g_step. Added new layout function compare_vars compares variables different types columns produces p-value comparison reference column. Function built top summarize_vars functionality. cut_quantile_bins cuts numeric vector quantile bins. fct_collapse_only collapses levels factor keeps order provided. fct_explicit_na_if inserts explicit missings factor based condition. range_noinf kind wrapper function base::range. returns c(NA, NA) instead c(-Inf, Inf) zero-length data.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"enhancements-0-7-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"tern 0.7.3","text":"Cox regression via fit_coxreg_univar fit_coxreg_multivar now also possible without treatment arm. univariate case means fits separate univariate models provided covariates tabulation corresponding effect estimates can later occur. Added fraction result returned s_count_occurrences. contains list numerators denominators one element per occurrence. Updated sum_num_patients count_occurrences result unique count_fraction return (0, 0) input empty. Added new argument groups_lists extract_survival_subgroups, extract_rsp_subgroups associated helper functions allows group factor levels subgroup variables manually defined groups, enhancing flexibility resulting forest graphs. Forest graph function g_forest now extracts default arguments attributes input table produced tabulate_rsp_subgroups tabulate_survival_subgroups user manually anymore. Remove arm variable name arm labels plot legend annotation tables. Show symbol used mark censored cases match order arm variable factor levels legend. Display hazard ratio confidence interval two decimal places. Updated default position hazard ratio table stay left bottom corner x-axis. Use arm value strata name treatment arm variable single level. Updated s_surv_time function use newly created function range_noinf instead base::range. New argument no_fillin_visits added h_adsl_adlb_merge_using_worst_flag specify excluded visits post-baseline worst toxicity grade output. Improved h_adsl_adlb_merge_using_worst_flag include variables shared adsl adlb, along PARAM, PARAMCD, ATOXGR, BTOXGR optionally AVISIT, AVISITN by_visit = TRUE. Prior output contained USUBJID, ARMCD, PARAMCD, ATOXGR, BTOXGR.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"bug-fixes-0-7-3","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"tern 0.7.3","text":"Fix bug s_surv_timepoint cases zero patients risk. Modified stat_median_ci function passing empty var empty name, row names contain missing values error show.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"miscellaneous-0-7-3","dir":"Changelog","previous_headings":"","what":"Miscellaneous","title":"tern 0.7.3","text":"Deprecated s_cox_univariate function, use fit_coxreg_univar function instead. Updated default formats hr hr_ci a_coxph_pairwise median s_surv_time align STREAM. Updated pre-processing code files test-table_ttet01.R test-table_dort01.R make sure analysis variable EVNT1 levels factor defined. Improved error message number levels factor variable data frame expected.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-072","dir":"Changelog","previous_headings":"","what":"tern 0.7.2","title":"tern 0.7.2","text":"Fixed column label internal test errors.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-071","dir":"Changelog","previous_headings":"","what":"tern 0.7.1","title":"tern 0.7.1","text":"New argument position_surv_med added g_km move position annotation table median survival times. Fixed bug g_km related ignored arguments pch size passed helper function h_ggkm. Updated xticks max_time arguments g_km greater functionality. max_time added argument h_xticks allow . Fixed bug prop_diff_cmh led NaN weighted proportion difference estimates missing confidence intervals. change, including patients one treatment arm least one stratum estimation lead numeric results. Fixed bug prop_cmh giving error case least one stratum containing less two observations. New argument n_events added estimate_incidence_rate. New argument denom added count_occurrences. New arguments yval ci_ribbon added g_km. Add new individual patient plot function g_ipp along helpers h_g_ipp h_set_nest_theme. Fixed bug count_patients_with_events, now shows zero counts without percentage. Fixed bug get_mmrm_lsmeans allow MMRM analysis 3000 observations. Updated stat_mean_ci stat_median_ci handle edge cases number elements input series equal 1. cases, NA_real_ now returned, instead NA +/-Inf confidence interval (CI) estimates. Rename n_lim argument stat_mean_ci n_min better reflect desired meaning.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-070","dir":"Changelog","previous_headings":"","what":"tern 0.7.0","title":"tern 0.7.0","text":"version tern introduces major rewriting tern due change layout based tabulation rtables. tern now build tables directly anymore, instead provides analysis functions build tables, see examples. * Counting patients abnormal values post-baseline count_abnormal. * Counting patients graded abnormal values count_abnormal_by_worst_grade. * Counting patients abnormal values baseline status count_abnormal_by_baseline. * Counting patients missed doses s_count_missed_doses count_missed_doses. * Counting patients event flags count_patients_with_event count_patients_with_flags. * Summarizing variables summarize_vars (supports numeric, factor, character logical variables). Note factors need NAs converted na_level use. * Summarizing change baseline summarize_change. * Summarizing variables columns summarize_colvars. * Estimating difference responder proportions estimate_proportion_diff. * Estimating difference Odds Ratio estimate_odds_ratio. * Testing difference responder proportions test_proportion_diff. * Estimating responder proportion level factor estimate_multinomial_response. * Fitting tabulating results Cox regressions fit_coxreg_univar, fit_coxreg_multivar summarize_coxreg, respectively. * Pruning occurrence tables (tables counts fractions) flexible rules, see ?prune_occurrences details. * Sorting occurrence tables using different options, see ?score_occurrences details. * Fitting tabulating MMRM models fit_mmrm .rtable summarize_lsmeans, see ?tabulate_mmrm details. * Counting number unique non-unique patients summarize_num_patients. * Counting occurrences count_occurrences. * Counting occurrences grade summarize_occurrences_by_grade count_occurrences_by_grade. * Counting patients events columns summarize_patients_events_in_cols. * Tabulating binary outcome response subgroup extract_rsp_subgroups tabulate_rsp_subgroups. * Tabulating survival duration subgroup extract_survival_subgroups tabulate_survival_subgroups.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-069","dir":"Changelog","previous_headings":"","what":"tern 0.6.9","title":"tern 0.6.9","text":"Removing used imports.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-068","dir":"Changelog","previous_headings":"","what":"tern 0.6.8","title":"tern 0.6.8","text":"Improved handling missing data aggregation functions: a_mean_sd, a_median, a_n_true_and_freq, a_count, a_q1q3, a_iqr, a_range. New default p-value method s_test_proportion_diff: Chi-Squared Test Schouten Correction. Add new function t_contingency contingency tables. Renamed class splitText dynamicSplitText resolve name conflict package ggpubr. Add rreplace_format tabulation post-processing. Add new tern function t_ancova create ANCOVA tables, well corresponding elementary table function t_el_ancova summary function s_ancova. Add new tern function s_odds_ratio estimate Odds Ratio response categories, well corresponding elementary table function t_el_odds_ratio. Added new CI methods (agresti-coull, jeffreys) s_proportion. Added new CI methods anderson-hauck newcombe s_proportion_diff. Added new p-value methods (Fisher’s Exact, Chi-Squared Test Schouten Correction) s_test_proportion_diff. binary summary table function t_binary_outcome takes now lists (instead character vectors) specified helper function control_binary_comparison arguments strat_analysis unstrat_analysis. Odds Ratio estimates CIs now removable included default, similarly subsections arm comparison analyses. Also added argument rsp_multinomial. Add new table function t_el_multinomial_proportion. Add new table function t_abn_shift. Add new MMRM analysis function s_mmrm, well corresponding table functions t_mmrm_lsmeans, t_mmrm_cov, t_mmrm_diagnostic, t_mmrm_fixed, plot functions g_mmrm_lsmeans, g_mmrm_diagnostic. results match SAS results (numeric precision). Deprecated old MMRM functions a_mmrm t_mmrm (give deprecation warning still work) remove next release. reason results functions don’t match SAS results. Fix bug g_km related numbers patients risk table correct numbers integer time--event variable inputs.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-067","dir":"Changelog","previous_headings":"","what":"tern 0.6.7","title":"tern 0.6.7","text":"functions row_by argument, inputs longer require use nested_by. Add stat_mean_ci stat_median_ci error bars ggplot2. Add new tern function t_coxreg single interface diverse cox regression types. Add compound table binary endpoint: t_binary_endpoint elementary functions: t_el_proportion, t_el_proportion_diff t_el_test_proportion_diff. supporting summary functions added : s_proportion, s_adj_proportion_diff, s_proportion_diff s_test_proportion_diff. Added new tern function t_events_patyear create event table adjusted person-years. Added new tern function t_abnormality elementary table function t_el_abnormality. Removed grade_levels argument t_events_term_grade_id functions. Post-processing reordering leaves table tree creates different ordering rows required. Creating helper function occur later time. Added prune_zero_rows argument t_events_per_term_grade_id t_max_grade_per_id show rows zeros can clutter visualization Shiny app make slower. Fixed position (N=xx) t_summary_by output summarizing numeric columns parallel compare_in_header. Rename t_coxph t_coxph_pairwise reflect model process, add details documentation. Remove test.nest dependency. Keep column labels splitting data tree.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-066","dir":"Changelog","previous_headings":"","what":"tern 0.6.6","title":"tern 0.6.6","text":"Remove test.nest dependency.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-065","dir":"Changelog","previous_headings":"","what":"tern 0.6.5","title":"tern 0.6.5","text":"Change default option denominator N t_summary. Fix IQR bug: IQR Q3 minus Q1. Add new function t_logistic multi-variable logistic regression table. Add new function df_explicit_na replace NA explicit values. Added possibility t_tte specify confidence level independent survfit, coxph, ztest, see manual. Fixed bug t_rsp showing p-value, odds ratio CIs strata_data NULL. Added stratified analysis t_forest_rsp t_forest_tte, footnotes g_forest. Added footnotes, footnotes<- add_footnotes<- functions deal footnotes. Added argument conf_int confidence interval level t_el_forest_rps, t_forest_rsp, t_el_forest_tte, t_forest_tte. Added argument col_symbol_size g_forest control relative size symbols used plot. Added s_coxph_pairwise function perform pairwise testing, used t_tte t_coxph. Added methods t_count_true replacing t_summary_true. Updated t_count_unique create analysis subsets, added t_el_count_unique vectors. Fixed bug t_events_term_id table sort order decreasing frequency instead alphabetical. Added function color_palette new nest color palette.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-064","dir":"Changelog","previous_headings":"","what":"tern 0.6.4","title":"tern 0.6.4","text":"Refactored renaming functions utils.nest. Added event_type argument t_events_per_term_grade_id. Added one/two-arm t-test functions. Improvements t_summary_by. Internal code refactoring.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-063","dir":"Changelog","previous_headings":"","what":"tern 0.6.3","title":"tern 0.6.3","text":"related tree functions see reference trees. Moved label functions rtables. Deleted keys keys<- functions. Exported tabulate_pairwise. get_N, col_N_add_total, check_id. na_as_level. as_factor_keep_attributes. r_by. Disposition elementary table t_el_disposition. t_el_forest_tte, t_el_forest_rsp. Added table_tree argument returns node object. Added f_numeric choose statistics calculate. denominator now also allows omit wanting omit percentages. Renamed row_by. Changed functionality group_data using row_by_list. Removed na_omit_group. Removed indent argument, use indent function rtables. instead","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-062","dir":"Changelog","previous_headings":"","what":"tern 0.6.2","title":"tern 0.6.2","text":"Use cached data random.cdisc.data speed testing. Added t_summary.Date method. Added save_join.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-061","dir":"Changelog","previous_headings":"","what":"tern 0.6.1","title":"tern 0.6.1","text":"Fixed colors Kaplan-Meier Plot Changed width_row.names argument g_forest function width_row_names. Changed censor.show argument g_km function censor_show. Changed col.legend.title argument g_waterfall function col_legend_title. Changed na.rm argument t_count_unique function na_rm. Changed row.name argument t_count_unique function row_name. Changed na.omit.group argument t_forest_rsp function na_omit_group. Changed na.omit.group argument t_forest_tte function na_omit_group. Changed row.name.TRUE row.name.FALSE arguments t_summary.logical row_name_true row_name_false respectively. Rename splotTextGrob split_text_grob. Fix examples. Refactor internal functions code.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-060","dir":"Changelog","previous_headings":"","what":"tern 0.6.0","title":"tern 0.6.0","text":"Removed functions addTable, t_summarize_by_visit, t_summarize_variables. Added t_summary_by function. Refactor g_km function, renamed kmGrob kmCurveGrob. Refactor t_events_* family functions. Updated examples.","code":""},{"path":[]},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-tlgs-0-5-0-3","dir":"Changelog","previous_headings":"","what":"New TLGs","title":"tern 0.5.0.3","text":"t_summary methods data.frame, numeric, logical, character, factor, Date objects. t_events_per_term_id, t_events_per_term_grade_id: Adverse Events & Concomitant Treatment Tables. t_max_grade_per_id, t_count_unique, t_events_summary elementary tables used Adverse Events & Concomitant Treatment Tables. g_waterfall: Horizontal Waterfall Plot.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"new-helper-functions-0-5-0-3","dir":"Changelog","previous_headings":"","what":"New Helper Functions","title":"tern 0.5.0.3","text":"decorate_grob, decorate_grob_set, decorate_grob_factory, splitTextGrob. stack_grobs, arrange_grobs, draw_grob.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tlg-changes-0-5-0-3","dir":"Changelog","previous_headings":"","what":"TLG changes","title":"tern 0.5.0.3","text":"t_tte now shows two rows ranges event censored times, respectively. g_km works one arm survfit objects. forest plot functions, added formatting display extreme values “>999.9”. t_summarise_variables uses now n instead N denominator calculating percentages factors default. t_rsp now works response values TRUE FALSE.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"deprecated-functions-0-5-0-3","dir":"Changelog","previous_headings":"","what":"Deprecated Functions","title":"tern 0.5.0.3","text":"Deprecated t_summarize_variables t_summary powerful. Replacing t_summarize_by_visit t_summary_by occur upcoming release.","code":""},{"path":"https://insightsengineering.github.io/tern/main/news/index.html","id":"tern-050","dir":"Changelog","previous_headings":"","what":"tern 0.5.0","title":"tern 0.5.0","text":"First version harmonized analysis functions names arguments.","code":""}]