Skip to content

Commit

Permalink
Merge branch 'main' into 1329_list_stat_options@main
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua authored Oct 18, 2024
2 parents 5dc2b98 + d89bba0 commit 4ff9421
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 123 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tern
Title: Create Common TLGs Used in Clinical Trials
Version: 0.9.6.9005
Date: 2024-10-09
Version: 0.9.6.9006
Date: 2024-10-18
Authors@R: c(
person("Joe", "Zhu", , "[email protected]", role = c("aut", "cre")),
person("Daniel", "Sabanés Bové", , "[email protected]", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tern 0.9.6.9005
# tern 0.9.6.9006

### Bug Fixes
* Fixed bug in `a_summary()` causing non-unique `row_name` values to occur when multiple statistics are selected for count variables.
Expand Down
47 changes: 29 additions & 18 deletions R/bland_altman.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@
#'
#' @description `r lifecycle::badge("experimental")`
#'
#' Functions that use the Bland-Altman method to assess the agreement between two numerical vectors.
#' Statistics function that uses the Bland-Altman method to assess the agreement between two numerical vectors
#' and calculates a variety of statistics.
#'
#' @inheritParams argument_convention
#' @param y (`numeric`)\cr vector of numbers we want to analyze, to be compared with `x`.
#'
#' @name bland_altman
NULL

#' @describeIn bland_altman Statistics function that compares two numeric vectors using the Bland-Altman method
#' and calculates a variety of statistics.
#'
#' @return
#' * `s_bland_altman()` returns a named list of the 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`, and `n`.
#' A named list of the 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`
#'
#' @examples
#' x <- seq(1, 60, 5)
#' y <- seq(5, 50, 4)
#' conf_level <- 0.9
#'
#' # Derive statistics that are needed for Bland-Altman plot
#' s_bland_altman(x, y, conf_level = conf_level)
#' s_bland_altman(x, y, conf_level = 0.9)
#'
#' @export
s_bland_altman <- function(x, y, conf_level = 0.95) {
Expand Down Expand Up @@ -75,16 +78,24 @@ s_bland_altman <- function(x, y, conf_level = 0.95) {
)
}

#' @describeIn bland_altman Graphing function that produces a Bland-Altman plot.
#' Bland-Altman plot
#'
#' @return
#' * `g_bland_altman()` returns a `ggplot` Bland-Altman plot.
#' @description `r lifecycle::badge("experimental")`
#'
#' Graphing function that produces a Bland-Altman plot.
#'
#' @inheritParams s_bland_altman
#'
#' @return A `ggplot` Bland-Altman plot.
#'
#' @examples
#' # Create a Bland-Altman plot
#' g_bland_altman(x = x, y = y, conf_level = conf_level)
#' x <- seq(1, 60, 5)
#' y <- seq(5, 50, 4)
#'
#' g_bland_altman(x = x, y = y, conf_level = 0.9)
#'
#' @export
#' @aliases bland_altman
g_bland_altman <- function(x, y, conf_level = 0.95) {
result_tem <- s_bland_altman(x, y, conf_level = conf_level)
xpos <- max(result_tem$df$average) * 0.9 + min(result_tem$df$average) * 0.1
Expand Down
2 changes: 0 additions & 2 deletions R/formatting_functions.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#' Formatting functions
#'
#' @description `r lifecycle::badge("stable")`
#'
#' See below for the list of formatting functions created in `tern` to work with `rtables`.
#'
#' Other available formats can be listed via [`formatters::list_valid_format_labels()`]. Additional
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Data visualizations:
- STEP graphs ([`g_step`](https://insightsengineering.github.io/tern/latest-tag/reference/g_step.html))
- Individual patient plots ([`g_ipp`](https://insightsengineering.github.io/tern/latest-tag/reference/g_ipp.html))
- Waterfall plots ([`g_waterfall`](https://insightsengineering.github.io/tern/latest-tag/reference/g_waterfall.html))
- Bland-Altman plots ([`g_bland_altman`](https://insightsengineering.github.io/tern/latest-tag/reference/g_bland_altman.html))

Statistical model fit summaries:

Expand Down Expand Up @@ -80,7 +81,7 @@ See package vignettes `browseVignettes(package = "tern")` for usage of this pack

## Acknowledgment

This package is a result of a joint efforts by many developers and stakeholders. We would like to thank everyone who has contributed so far!
This package is the result of the joint efforts by many developers and stakeholders. We would like to thank everyone who has contributed so far!

## Stargazers and Forkers

Expand Down
50 changes: 26 additions & 24 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ navbar:
github:
icon: fa-github
href: https://github.com/insightsengineering/tern
aria-label: GitHub

reference:
- title: Overview Pages
Expand All @@ -31,13 +32,6 @@ reference:
- summarize_functions
- formatting_functions

- title: Control Functions
desc: 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.
contents:
- starts_with("control_")

- title: Analysis Functions
desc: |
Analyze functions with their corresponding statistics functions and
Expand All @@ -61,6 +55,7 @@ reference:
- compare_vars
- starts_with("count_", internal = TRUE)
- starts_with("estimate_", internal = TRUE)
- s_bland_altman
- starts_with("summarize_", internal = TRUE)
- starts_with("surv_", internal = TRUE)
- starts_with("tabulate_", internal = TRUE)
Expand All @@ -70,6 +65,30 @@ reference:
- -estimate_coef
- -summarize_functions

- title: Model-Specific Functions
desc: These functions help with fitting or extracting results from specific
models.
contents:
- estimate_coef
- starts_with("extract_")
- starts_with("fit_")
- get_smooths
- starts_with("logistic_")
- starts_with("tidy.")
- univariate

- title: Graphs
desc: These function create graphical type output.
contents:
- starts_with("g_")

- title: Control Functions
desc: 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.
contents:
- starts_with("control_")

- title: Analysis Helper Functions
desc: These functions are useful in defining an analysis.
contents:
Expand All @@ -88,23 +107,6 @@ reference:
- -h_xticks
- -prop_diff

- title: Model-Specific Functions
desc: These functions help with fitting or extracting results from specific
models.
contents:
- estimate_coef
- starts_with("extract_")
- starts_with("fit_")
- get_smooths
- starts_with("logistic_")
- starts_with("tidy.")
- univariate

- title: Graphs
desc: These function create graphical type output.
contents:
- starts_with("g_")

- title: rtables Helper Functions
desc: These functions help to work with the `rtables` package and may be
moved there later.
Expand Down
55 changes: 0 additions & 55 deletions man/bland_altman.Rd

This file was deleted.

5 changes: 2 additions & 3 deletions man/formatting_functions.Rd

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

31 changes: 31 additions & 0 deletions man/g_bland_altman.Rd

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

45 changes: 45 additions & 0 deletions man/s_bland_altman.Rd

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

Loading

0 comments on commit 4ff9421

Please sign in to comment.