Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bugfix globals #1

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Description: Provide a library of methods that can be used to calculate differen
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Suggests:
covr,
pkgdown,
Expand All @@ -41,6 +41,10 @@ Imports:
stats,
data.table (>= 1.14.2),
magrittr,
checkmate
checkmate,
cli,
usethis
Remotes:
hta-pharma/chef
Config/testthat/edition: 3
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions R/across_strata_across_trt.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @param strata_var character. Variable in the analysis data to stratify by specific for this call.
#' @param odds_ratio numeric. Odds Ration (default = NA).
#' @param correct logical. If TRUE Tarones correction is returned (default = FALSE).
#' @param ... Optional parameters.
#'
#' @return A data.table containing the statistics for p-value interaction tests.
#' @export
Expand Down
8 changes: 6 additions & 2 deletions R/by_strata_across_trt.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @param treatment_var character. The name of the treatment variable in the data.
#' @param treatment_refval character. The reference value of the treatment variable in the data.
#' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID").
#' @param ... Optional parameters.
#'
#' @return A data.table containing Relative Risk statistics.
#' @export
Expand Down Expand Up @@ -70,6 +71,7 @@ RR <- function(dat,
#' @param treatment_var character. The name of the treatment variable in the data.
#' @param treatment_refval character. The reference value of the treatment variable in the data.
#' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID").
#' @param ... Optional parameters.
#'
#' @return A data.table containing Odds Ratio statistics.
#' @export
Expand Down Expand Up @@ -127,6 +129,8 @@ OR <- function(dat,
#' @param treatment_var character. The name of the treatment variable in the data.
#' @param treatment_refval character. The reference value of the treatment variable in the data.
#' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID").
#' @param as_pct Boolean.
#' @param ... Optional parameters.
#'
#' @return A data.table containing Risk Difference statistics.
#' @export
Expand Down Expand Up @@ -183,13 +187,13 @@ RD <- function(dat,
#' analyzed. See the "Endpoint Events" vignette in {ramnog}
#' for more information.
#' @param safe_mode Boolean determing if the function should fail when given
#' input that cannot be calculated (`safe_mode = TRUE`), or if it should
#' input that cannot be calculated (`safe_mode = TRUE`), or if it should silently return a `NA` value (default).
#' @param treatment_var character. The name of the treatment variable in the data.
#' @param treatment_refval character. The reference value of the treatment variable in the data.
#' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID").
#' @param threshold_lower numeric. Lower threshold limit for selecting Fischer vs. Barnard.
#' @param threshold_upper numeric. Upper threshold limit for selecting Fischer vs. Barnard.
#' silently return a `NA` value (default).
#' @param ... Optional parameters.
#' @return A data.table containing p-value statistics.
#' @export
p_val <-
Expand Down
4 changes: 3 additions & 1 deletion R/by_strata_by_trt.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ total_missing_counts <- function(dat_cell, stratify_by) {
#' analyzed. See the "Endpoint Events" vignette in {ramnog}
#' for more information.
#' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID").
#' @param treatment_var character. Name of the treatment variable in the data.
#' @param var character. Name of the variable in the analysis data that is subject to the statistics.
#' @param ... Optional parameters.
#'
#' @return A data.table containing the percentage of subjects with events by treatment.
Expand Down Expand Up @@ -344,6 +344,8 @@ mean_value <- function(dat,
#' for more information.
#' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID").
#' @param treatment_var character. Name of the treatment variable in the data.
#' @param treatment_value character. Value of the treatment variable in the data.
#' @param ... Optional parameters.
#'
#' @return A data.table containing the percentage of subjects with events by treatment.
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ utils::globalVariables(
"stat_var",
"value",
"N_sub",
"N_no_event",
"N_no_event"
)
)
36 changes: 18 additions & 18 deletions R/two_by_two_x.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
#'
#' Only observations that have a Treatment value recorded are returned.

#'@param dat The ADaM table produced by baker
#'@param treatment_var character. The name of the treatment variable
#'@param treatment_refval character. The reference value of the treatment
#'@param keepflg_var character. The name of the variable in the enriched ADaM
#' data.table that contains the flag indicating whether each record fulfilled
#' the criteria for being considered an event for the specific endpoint
#'
#' @return A matrix
#' @param dat data.table. The analysis data set.
#' @param event_index vector of integers that index the rows in `dat` that match
#' the definition of an 'event'. Matching is done via the `INDEX_` column in
#' `dat`.
#' @param cell_index A vector of integers referencing the rows of `dat` (as
#' specified by the `INDEX_` column in `dat`) that match the population to be
#' analyzed. See the "Endpoint Events" vignette in {ramnog}
#' for more information.
#' @param treatment_var character. The name of the treatment variable in `dat`.
#' @param treatment_refval character. The reference value of the treatment variable in `dat`.
#' @param subjectid_var character. Name of the subject identifier variable in `dat` (default is "USUBJID").
#'@return A matrix
#' @export
#'
mk_two_by_two <-
Expand Down Expand Up @@ -120,16 +124,12 @@ ensure_complete_two_by_two <- function(two_by_two_long, treatment_var) {
#' generalized
#'
#'
#' @param dat data.table. An enriched ADaM table
#' @param treatment_refval character. The treatment reference group
#' @param treatment_var character. The name of the column containing the
#' treatment value
#' @param subjectid_var character. The name of the column in the enriched ADaM
#' dataset containing the unique subject id (default = `USUBJID`).
#' @param event_index
#' @param cell_index
#' @param strata_var
#'
#' @param dat data.table. The analysis data set.
#' @param event_index vector of integers that index the rows in `dat` that match the definition of an 'event'. Matching is done via the `INDEX_` column in `dat`.
#' @param strata_var character. Variable in `dat` to stratify by specific for this call.
#' @param treatment_var character. The name of the treatment variable in `dat`.
#' @param treatment_refval character. The reference value of the treatment variable in `dat`.
#' @param subjectid_var character. Name of the subject identifier variable in `dat` (default is "USUBJID").
#' @return A two-by-two-by-k array where k represents the number of subgroups
#' (strata).
#' @export
Expand Down
1 change: 0 additions & 1 deletion R/use_chefStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#' @return Nothing, run for side-effect (writes file to disk)
#' @export
#'
#' @examples
use_chefStats <-
function(fn_name,
fn_type = c(
Expand Down
2 changes: 2 additions & 0 deletions man/OR.Rd

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

4 changes: 4 additions & 0 deletions man/RD.Rd

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

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

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

14 changes: 7 additions & 7 deletions man/make_two_by_two_by_k.Rd

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

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

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

19 changes: 13 additions & 6 deletions man/mk_two_by_two.Rd

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

4 changes: 4 additions & 0 deletions man/p_subj_event_by_trt.Rd

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

7 changes: 4 additions & 3 deletions man/p_val.Rd

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

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

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

2 changes: 2 additions & 0 deletions tests/testthat/_snaps/demographics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
actual_total
Output
label qualifiers value description
<char> <fctr> <num> <char>
1: n_non_missing AGEGR1 85 Demographics
2: n_missing AGEGR1 1 Demographics
3: n_non_missing SEX 82 Demographics
Expand All @@ -15,5 +16,6 @@
actual_f
Output
label description qualifiers value
<char> <char> <char> <num>
1: n_non_missing Demographics <NA> 52

Loading